# HG changeset patch # User duke # Date 1499284709 -7200 # Node ID 5bf88dce615f6804f9e101a96ffa7c9dfb4fbbbe # Parent 123eacab39eceaa8721d3e590f96d9378beac566# Parent 5a66e43d8cbd7a3ec7feef96619a3fe53f598a63 Merge diff -r 5a66e43d8cbd -r 5bf88dce615f .hgtags-top-repo --- a/.hgtags-top-repo Wed Jul 05 21:57:12 2017 +0200 +++ b/.hgtags-top-repo Wed Jul 05 21:58:29 2017 +0200 @@ -369,3 +369,4 @@ f80c841ae2545eaf9acd2724bccc305d98cefbe2 jdk-9+124 9aa7d40f3a453f51e47f4c1b19eff5740a74a9f8 jdk-9+125 3a58466296d36944454756ef01e7513ac5e14a16 jdk-9+126 +8fa686245bd2a072ece3392743460030f0854520 jdk-9+127 diff -r 5a66e43d8cbd -r 5bf88dce615f corba/.hgtags --- a/corba/.hgtags Wed Jul 05 21:57:12 2017 +0200 +++ b/corba/.hgtags Wed Jul 05 21:58:29 2017 +0200 @@ -369,3 +369,4 @@ 45121d5afb9d5bfadab75378572ad96832e0809e jdk-9+124 1d48e67d1b91eb9f72e49e69a4021edb85e357fc jdk-9+125 c7f5ba08fcd4b8416e62c21229f9a07c95498919 jdk-9+126 +8fab452b6f4710762ba1d8e55fd62db00b1355fe jdk-9+127 diff -r 5a66e43d8cbd -r 5bf88dce615f hotspot/.hgtags --- a/hotspot/.hgtags Wed Jul 05 21:57:12 2017 +0200 +++ b/hotspot/.hgtags Wed Jul 05 21:58:29 2017 +0200 @@ -529,3 +529,4 @@ 479631362b4930be985245ea063d87d821a472eb jdk-9+124 bb640b49741af3f57f9994129934c46fc173219f jdk-9+125 adc8c84b7cf8c540d920182f78a2bc982366432a jdk-9+126 +352357128f602dcf0426b1cbe011a4685a4d9f97 jdk-9+127 diff -r 5a66e43d8cbd -r 5bf88dce615f hotspot/make/gensrc/GensrcDtrace.gmk --- a/hotspot/make/gensrc/GensrcDtrace.gmk Wed Jul 05 21:57:12 2017 +0200 +++ b/hotspot/make/gensrc/GensrcDtrace.gmk Wed Jul 05 21:58:29 2017 +0200 @@ -45,7 +45,8 @@ $(DTRACE_GENSRC_DIR)/%.h: $(DTRACE_SOURCE_DIR)/%.d $(call LogInfo, Generating dtrace header file $(@F)) $(call MakeDir, $(@D) $(DTRACE_SUPPORT_DIR)) - $(call ExecuteWithLog, $(DTRACE_SUPPORT_DIR)/$(@F).d, $(CC) -E $(DTRACE_CPP_FLAGS) $< > $(DTRACE_SUPPORT_DIR)/$(@F).d) + $(call ExecuteWithLog, $(DTRACE_SUPPORT_DIR)/$(@F).d, \ + ( $(CC) -E $(DTRACE_CPP_FLAGS) $< > $(DTRACE_SUPPORT_DIR)/$(@F).d ) ) $(call ExecuteWithLog, $@, $(DTRACE) $(DTRACE_FLAGS) -h -o $@ -s $(DTRACE_SUPPORT_DIR)/$(@F).d) # Process all .d files in DTRACE_SOURCE_DIR. They are: diff -r 5a66e43d8cbd -r 5bf88dce615f hotspot/make/lib/CompileDtracePostJvm.gmk --- a/hotspot/make/lib/CompileDtracePostJvm.gmk Wed Jul 05 21:57:12 2017 +0200 +++ b/hotspot/make/lib/CompileDtracePostJvm.gmk Wed Jul 05 21:58:29 2017 +0200 @@ -68,7 +68,7 @@ $1: $$(BUILD_DTRACE_GEN_OFFSETS) $$(call LogInfo, Generating dtrace $2 file $$(@F)) $$(call MakeDir, $$(@D)) - $$(call ExecuteWithLog, $$@, $$(DTRACE_GEN_OFFSETS_TOOL) -$$(strip $2) > $$@) + $$(call ExecuteWithLog, $$@, ( $$(DTRACE_GEN_OFFSETS_TOOL) -$$(strip $2) > $$@ ) ) TARGETS += $1 endef diff -r 5a66e43d8cbd -r 5bf88dce615f hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/UncommonTrap.java --- a/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/UncommonTrap.java Wed Jul 05 21:57:12 2017 +0200 +++ b/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/UncommonTrap.java Wed Jul 05 21:58:29 2017 +0200 @@ -16,9 +16,9 @@ * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. + * Please 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.hotspot.tools.compiler; diff -r 5a66e43d8cbd -r 5bf88dce615f hotspot/src/share/vm/classfile/classLoaderData.cpp --- a/hotspot/src/share/vm/classfile/classLoaderData.cpp Wed Jul 05 21:57:12 2017 +0200 +++ b/hotspot/src/share/vm/classfile/classLoaderData.cpp Wed Jul 05 21:58:29 2017 +0200 @@ -501,13 +501,26 @@ } } -/** - * Returns true if this class loader data is for the platform class loader. - */ +// Returns true if this class loader data is for the system class loader. +bool ClassLoaderData::is_system_class_loader_data() const { + return SystemDictionary::is_system_class_loader(class_loader()); +} + +// Returns true if this class loader data is for the platform class loader. bool ClassLoaderData::is_platform_class_loader_data() const { return SystemDictionary::is_platform_class_loader(class_loader()); } +// Returns true if this class loader data is one of the 3 builtin +// (boot, application/system or platform) class loaders. Note, the +// builtin loaders are not freed by a GC. +bool ClassLoaderData::is_builtin_class_loader_data() const { + Handle classLoaderHandle = class_loader(); + return (is_the_null_class_loader_data() || + SystemDictionary::is_system_class_loader(classLoaderHandle) || + SystemDictionary::is_platform_class_loader(classLoaderHandle)); +} + Metaspace* ClassLoaderData::metaspace_non_null() { assert(!DumpSharedSpaces, "wrong metaspace!"); // If the metaspace has not been allocated, create a new one. Might want @@ -957,12 +970,6 @@ data = _head; while (data != NULL) { if (data->is_alive(is_alive_closure)) { - if (data->packages_defined()) { - data->packages()->purge_all_package_exports(); - } - if (data->modules_defined()) { - data->modules()->purge_all_module_reads(); - } // clean metaspace if (walk_all_metadata) { data->classes_do(InstanceKlass::purge_previous_versions); @@ -990,6 +997,23 @@ } if (seen_dead_loader) { + // Walk a ModuleEntry's reads and a PackageEntry's exports lists + // to determine if there are modules on those lists that are now + // dead and should be removed. A module's life cycle is equivalent + // to its defining class loader's life cycle. Since a module is + // considered dead if its class loader is dead, these walks must + // occur after each class loader's aliveness is determined. + data = _head; + while (data != NULL) { + if (data->packages_defined()) { + data->packages()->purge_all_package_exports(); + } + if (data->modules_defined()) { + data->modules()->purge_all_module_reads(); + } + data = data->next(); + } + post_class_unload_events(); } diff -r 5a66e43d8cbd -r 5bf88dce615f hotspot/src/share/vm/classfile/classLoaderData.hpp --- a/hotspot/src/share/vm/classfile/classLoaderData.hpp Wed Jul 05 21:57:12 2017 +0200 +++ b/hotspot/src/share/vm/classfile/classLoaderData.hpp Wed Jul 05 21:58:29 2017 +0200 @@ -270,7 +270,9 @@ bool is_the_null_class_loader_data() const { return this == _the_null_class_loader_data; } + bool is_system_class_loader_data() const; bool is_platform_class_loader_data() const; + bool is_builtin_class_loader_data() const; // The Metaspace is created lazily so may be NULL. This // method will allocate a Metaspace if needed. diff -r 5a66e43d8cbd -r 5bf88dce615f hotspot/src/share/vm/classfile/compactHashtable.cpp --- a/hotspot/src/share/vm/classfile/compactHashtable.cpp Wed Jul 05 21:57:12 2017 +0200 +++ b/hotspot/src/share/vm/classfile/compactHashtable.cpp Wed Jul 05 21:58:29 2017 +0200 @@ -248,7 +248,7 @@ } else { u4*entry_max = _entries + BUCKET_OFFSET(_buckets[i + 1]); while (entry < entry_max) { - iterator.do_value(_base_address, entry[0]); + iterator.do_value(_base_address, entry[1]); entry += 2; } } diff -r 5a66e43d8cbd -r 5bf88dce615f hotspot/src/share/vm/classfile/moduleEntry.cpp --- a/hotspot/src/share/vm/classfile/moduleEntry.cpp Wed Jul 05 21:57:12 2017 +0200 +++ b/hotspot/src/share/vm/classfile/moduleEntry.cpp Wed Jul 05 21:58:29 2017 +0200 @@ -40,7 +40,6 @@ ModuleEntry* ModuleEntryTable::_javabase_module = NULL; - void ModuleEntry::set_location(Symbol* location) { if (_location != NULL) { // _location symbol's refcounts are managed by ModuleEntry, @@ -115,10 +114,35 @@ // Lazily create a module's reads list _reads = new (ResourceObj::C_HEAP, mtModule)GrowableArray(MODULE_READS_SIZE, true); } + + // Determine, based on this newly established read edge to module m, + // if this module's read list should be walked at a GC safepoint. + set_read_walk_required(m->loader_data()); + + // Establish readability to module m _reads->append_if_missing(m); } } +// If the module's loader, that a read edge is being established to, is +// not the same loader as this module's and is not one of the 3 builtin +// class loaders, then this module's reads list must be walked at GC +// safepoint. Modules have the same life cycle as their defining class +// loaders and should be removed if dead. +void ModuleEntry::set_read_walk_required(ClassLoaderData* m_loader_data) { + assert_locked_or_safepoint(Module_lock); + if (!_must_walk_reads && + loader_data() != m_loader_data && + !m_loader_data->is_builtin_class_loader_data()) { + _must_walk_reads = true; + if (log_is_enabled(Trace, modules)) { + ResourceMark rm; + log_trace(modules)("ModuleEntry::set_read_walk_required(): module %s reads list must be walked", + (name() != NULL) ? name()->as_C_string() : UNNAMED_MODULE); + } + } +} + bool ModuleEntry::has_reads() const { assert_locked_or_safepoint(Module_lock); return ((_reads != NULL) && !_reads->is_empty()); @@ -127,14 +151,28 @@ // Purge dead module entries out of reads list. void ModuleEntry::purge_reads() { assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint"); - if (has_reads()) { + + if (_must_walk_reads && has_reads()) { + // This module's _must_walk_reads flag will be reset based + // on the remaining live modules on the reads list. + _must_walk_reads = false; + + if (log_is_enabled(Trace, modules)) { + ResourceMark rm; + log_trace(modules)("ModuleEntry::purge_reads(): module %s reads list being walked", + (name() != NULL) ? name()->as_C_string() : UNNAMED_MODULE); + } + // Go backwards because this removes entries that are dead. int len = _reads->length(); for (int idx = len - 1; idx >= 0; idx--) { ModuleEntry* module_idx = _reads->at(idx); - ClassLoaderData* cld = module_idx->loader(); - if (cld->is_unloading()) { + ClassLoaderData* cld_idx = module_idx->loader_data(); + if (cld_idx->is_unloading()) { _reads->delete_at(idx); + } else { + // Update the need to walk this module's reads based on live modules + set_read_walk_required(cld_idx); } } } @@ -248,7 +286,7 @@ entry->set_module(loader_data->add_handle(module_handle)); } - entry->set_loader(loader_data); + entry->set_loader_data(loader_data); entry->set_version(version); entry->set_location(location); @@ -375,11 +413,11 @@ void ModuleEntry::print(outputStream* st) { ResourceMark rm; - st->print_cr("entry "PTR_FORMAT" name %s module "PTR_FORMAT" loader %s version %s location %s strict %s next "PTR_FORMAT, + st->print_cr("entry " PTR_FORMAT " name %s module " PTR_FORMAT " loader %s version %s location %s strict %s next " PTR_FORMAT, p2i(this), name() == NULL ? UNNAMED_MODULE : name()->as_C_string(), p2i(module()), - loader()->loader_name(), + loader_data()->loader_name(), version() != NULL ? version()->as_C_string() : "NULL", location() != NULL ? location()->as_C_string() : "NULL", BOOL_TO_STR(!can_read_all_unnamed()), p2i(next())); @@ -401,5 +439,5 @@ } void ModuleEntry::verify() { - guarantee(loader() != NULL, "A module entry must be associated with a loader."); + guarantee(loader_data() != NULL, "A module entry must be associated with a loader."); } diff -r 5a66e43d8cbd -r 5bf88dce615f hotspot/src/share/vm/classfile/moduleEntry.hpp --- a/hotspot/src/share/vm/classfile/moduleEntry.hpp Wed Jul 05 21:57:12 2017 +0200 +++ b/hotspot/src/share/vm/classfile/moduleEntry.hpp Wed Jul 05 21:58:29 2017 +0200 @@ -43,6 +43,7 @@ // It contains: // - Symbol* containing the module's name. // - pointer to the java.lang.reflect.Module for this module. +// - pointer to the java.security.ProtectionDomain shared by classes defined to this module. // - ClassLoaderData*, class loader of this module. // - a growable array containg other module entries that this module can read. // - a flag indicating if this module can read all unnamed modules. @@ -54,56 +55,58 @@ jobject _module; // java.lang.reflect.Module jobject _pd; // java.security.ProtectionDomain, cached // for shared classes from this module - ClassLoaderData* _loader; + ClassLoaderData* _loader_data; GrowableArray* _reads; // list of modules that are readable by this module Symbol* _version; // module version number Symbol* _location; // module location bool _can_read_all_unnamed; bool _has_default_read_edges; // JVMTI redefine/retransform support + bool _must_walk_reads; // walk module's reads list at GC safepoints to purge out dead modules TRACE_DEFINE_TRACE_ID_FIELD; enum {MODULE_READS_SIZE = 101}; // Initial size of list of modules that the module can read. public: void init() { _module = NULL; - _loader = NULL; + _loader_data = NULL; _pd = NULL; _reads = NULL; _version = NULL; _location = NULL; _can_read_all_unnamed = false; _has_default_read_edges = false; + _must_walk_reads = false; } - Symbol* name() const { return literal(); } - void set_name(Symbol* n) { set_literal(n); } + Symbol* name() const { return literal(); } + void set_name(Symbol* n) { set_literal(n); } - jobject module() const { return _module; } - void set_module(jobject j) { _module = j; } + jobject module() const { return _module; } + void set_module(jobject j) { _module = j; } // The shared ProtectionDomain reference is set once the VM loads a shared class // originated from the current Module. The referenced ProtectionDomain object is // created by the ClassLoader when loading a class (shared or non-shared) from the // Module for the first time. This ProtectionDomain object is used for all // classes from the Module loaded by the same ClassLoader. - Handle shared_protection_domain(); - void set_shared_protection_domain(ClassLoaderData *loader_data, - Handle pd); + Handle shared_protection_domain(); + void set_shared_protection_domain(ClassLoaderData *loader_data, Handle pd); - ClassLoaderData* loader() const { return _loader; } - void set_loader(ClassLoaderData* l) { _loader = l; } + ClassLoaderData* loader_data() const { return _loader_data; } + void set_loader_data(ClassLoaderData* l) { _loader_data = l; } + + Symbol* version() const { return _version; } + void set_version(Symbol* version); - Symbol* version() const { return _version; } - void set_version(Symbol* version); - - Symbol* location() const { return _location; } - void set_location(Symbol* location); + Symbol* location() const { return _location; } + void set_location(Symbol* location); - bool can_read(ModuleEntry* m) const; - bool has_reads() const; - void add_read(ModuleEntry* m); + bool can_read(ModuleEntry* m) const; + bool has_reads() const; + void add_read(ModuleEntry* m); + void set_read_walk_required(ClassLoaderData* m_loader_data); - bool is_named() const { return (literal() != NULL); } + bool is_named() const { return (name() != NULL); } bool can_read_all_unnamed() const { assert(is_named() || _can_read_all_unnamed == true, @@ -178,7 +181,7 @@ ModuleEntry* _unnamed_module; ModuleEntry* new_entry(unsigned int hash, Handle module_handle, Symbol* name, Symbol* version, - Symbol* location, ClassLoaderData* class_loader); + Symbol* location, ClassLoaderData* loader_data); void add_entry(int index, ModuleEntry* new_entry); int entry_size() const { return BasicHashtable::entry_size(); } diff -r 5a66e43d8cbd -r 5bf88dce615f hotspot/src/share/vm/classfile/modules.cpp --- a/hotspot/src/share/vm/classfile/modules.cpp Wed Jul 05 21:57:12 2017 +0200 +++ b/hotspot/src/share/vm/classfile/modules.cpp Wed Jul 05 21:58:29 2017 +0200 @@ -113,7 +113,7 @@ const char *package_name = java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(package)); if (package_name == NULL) return NULL; TempNewSymbol pkg_symbol = SymbolTable::new_symbol(package_name, CHECK_NULL); - PackageEntryTable* package_entry_table = module_entry->loader()->packages(); + PackageEntryTable* package_entry_table = module_entry->loader_data()->packages(); assert(package_entry_table != NULL, "Unexpected null package entry table"); return package_entry_table->lookup_only(pkg_symbol); } @@ -868,7 +868,7 @@ package_name, module_entry->name()->as_C_string()); TempNewSymbol pkg_symbol = SymbolTable::new_symbol(package_name, CHECK); - PackageEntryTable* package_table = module_entry->loader()->packages(); + PackageEntryTable* package_table = module_entry->loader_data()->packages(); assert(package_table != NULL, "Missing package_table"); bool pkg_exists = false; diff -r 5a66e43d8cbd -r 5bf88dce615f hotspot/src/share/vm/classfile/packageEntry.cpp --- a/hotspot/src/share/vm/classfile/packageEntry.cpp Wed Jul 05 21:57:12 2017 +0200 +++ b/hotspot/src/share/vm/classfile/packageEntry.cpp Wed Jul 05 21:58:29 2017 +0200 @@ -25,6 +25,7 @@ #include "precompiled.hpp" #include "classfile/moduleEntry.hpp" #include "classfile/packageEntry.hpp" +#include "logging/log.hpp" #include "memory/resourceArea.hpp" #include "oops/symbol.hpp" #include "runtime/handles.inline.hpp" @@ -53,12 +54,40 @@ if (!has_qual_exports_list()) { // Lazily create a package's qualified exports list. // Initial size is small, do not anticipate export lists to be large. - _qualified_exports = - new (ResourceObj::C_HEAP, mtModule) GrowableArray(QUAL_EXP_SIZE, true); + _qualified_exports = new (ResourceObj::C_HEAP, mtModule) GrowableArray(QUAL_EXP_SIZE, true); } + + // Determine, based on this newly established export to module m, + // if this package's export list should be walked at a GC safepoint. + set_export_walk_required(m->loader_data()); + + // Establish exportability to module m _qualified_exports->append_if_missing(m); } +// If the module's loader, that an export is being established to, is +// not the same loader as this module's and is not one of the 3 builtin +// class loaders, then this package's export list must be walked at GC +// safepoint. Modules have the same life cycle as their defining class +// loaders and should be removed if dead. +void PackageEntry::set_export_walk_required(ClassLoaderData* m_loader_data) { + assert_locked_or_safepoint(Module_lock); + ModuleEntry* this_pkg_mod = module(); + if (!_must_walk_exports && + (this_pkg_mod == NULL || this_pkg_mod->loader_data() != m_loader_data) && + !m_loader_data->is_builtin_class_loader_data()) { + _must_walk_exports = true; + if (log_is_enabled(Trace, modules)) { + ResourceMark rm; + assert(name() != NULL, "PackageEntry without a valid name"); + log_trace(modules)("PackageEntry::set_export_walk_required(): package %s defined in module %s, exports list must be walked", + name()->as_C_string(), + (this_pkg_mod == NULL || this_pkg_mod->name() == NULL) ? + UNNAMED_MODULE : this_pkg_mod->name()->as_C_string()); + } + } +} + // Set the package's exported states based on the value of the ModuleEntry. void PackageEntry::set_exported(ModuleEntry* m) { MutexLocker m1(Module_lock); @@ -96,14 +125,34 @@ // Remove dead module entries within the package's exported list. void PackageEntry::purge_qualified_exports() { assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint"); - if (_qualified_exports != NULL) { + if (_must_walk_exports && + _qualified_exports != NULL && + !_qualified_exports->is_empty()) { + ModuleEntry* pkg_module = module(); + + // This package's _must_walk_exports flag will be reset based + // on the remaining live modules on the exports list. + _must_walk_exports = false; + + if (log_is_enabled(Trace, modules)) { + ResourceMark rm; + assert(name() != NULL, "PackageEntry without a valid name"); + ModuleEntry* pkg_mod = module(); + log_trace(modules)("PackageEntry::purge_qualified_exports(): package %s defined in module %s, exports list being walked", + name()->as_C_string(), + (pkg_mod == NULL || pkg_mod->name() == NULL) ? UNNAMED_MODULE : pkg_mod->name()->as_C_string()); + } + // Go backwards because this removes entries that are dead. int len = _qualified_exports->length(); for (int idx = len - 1; idx >= 0; idx--) { ModuleEntry* module_idx = _qualified_exports->at(idx); - ClassLoaderData* cld = module_idx->loader(); - if (cld->is_unloading()) { + ClassLoaderData* cld_idx = module_idx->loader_data(); + if (cld_idx->is_unloading()) { _qualified_exports->delete_at(idx); + } else { + // Update the need to walk this package's exports based on live modules + set_export_walk_required(cld_idx); } } } @@ -297,8 +346,8 @@ void PackageEntry::print(outputStream* st) { ResourceMark rm; - st->print_cr("package entry "PTR_FORMAT" name %s module %s classpath_index " - INT32_FORMAT " is_exported_unqualified %d is_exported_allUnnamed %d " "next "PTR_FORMAT, + st->print_cr("package entry " PTR_FORMAT " name %s module %s classpath_index " + INT32_FORMAT " is_exported_unqualified %d is_exported_allUnnamed %d " "next " PTR_FORMAT, p2i(this), name()->as_C_string(), (module()->is_named() ? module()->name()->as_C_string() : UNNAMED_MODULE), _classpath_index, _is_exported_unqualified, _is_exported_allUnnamed, p2i(next())); diff -r 5a66e43d8cbd -r 5bf88dce615f hotspot/src/share/vm/classfile/packageEntry.hpp --- a/hotspot/src/share/vm/classfile/packageEntry.hpp Wed Jul 05 21:57:12 2017 +0200 +++ b/hotspot/src/share/vm/classfile/packageEntry.hpp Wed Jul 05 21:58:29 2017 +0200 @@ -69,6 +69,7 @@ s2 _classpath_index; bool _is_exported_unqualified; bool _is_exported_allUnnamed; + bool _must_walk_exports; GrowableArray* _exported_pending_delete; // transitioned from qualified to unqualified, delete at safepoint GrowableArray* _qualified_exports; TRACE_DEFINE_TRACE_ID_FIELD; @@ -82,6 +83,7 @@ _classpath_index = -1; _is_exported_unqualified = false; _is_exported_allUnnamed = false; + _must_walk_exports = false; _exported_pending_delete = NULL; _qualified_exports = NULL; } @@ -147,6 +149,7 @@ // add the module to the package's qualified exports void add_qexport(ModuleEntry* m); + void set_export_walk_required(ClassLoaderData* m_loader_data); PackageEntry* next() const { return (PackageEntry*)HashtableEntry::next(); diff -r 5a66e43d8cbd -r 5bf88dce615f hotspot/src/share/vm/classfile/systemDictionary.cpp --- a/hotspot/src/share/vm/classfile/systemDictionary.cpp Wed Jul 05 21:57:12 2017 +0200 +++ b/hotspot/src/share/vm/classfile/systemDictionary.cpp Wed Jul 05 21:58:29 2017 +0200 @@ -175,9 +175,18 @@ return false; } -/** - * Returns true if the passed class loader is the platform class loader. - */ +// Returns true if the passed class loader is the builtin application class loader +// or a custom system class loader. A customer system class loader can be +// specified via -Djava.system.class.loader. +bool SystemDictionary::is_system_class_loader(Handle class_loader) { + if (class_loader.is_null()) { + return false; + } + return (class_loader->klass() == SystemDictionary::jdk_internal_loader_ClassLoaders_AppClassLoader_klass() || + class_loader() == _java_system_loader); +} + +// Returns true if the passed class loader is the platform class loader. bool SystemDictionary::is_platform_class_loader(Handle class_loader) { if (class_loader.is_null()) { return false; diff -r 5a66e43d8cbd -r 5bf88dce615f hotspot/src/share/vm/classfile/systemDictionary.hpp --- a/hotspot/src/share/vm/classfile/systemDictionary.hpp Wed Jul 05 21:57:12 2017 +0200 +++ b/hotspot/src/share/vm/classfile/systemDictionary.hpp Wed Jul 05 21:58:29 2017 +0200 @@ -660,6 +660,7 @@ static instanceKlassHandle load_shared_class(Symbol* class_name, Handle class_loader, TRAPS); + static bool is_system_class_loader(Handle class_loader); static bool is_platform_class_loader(Handle class_loader); protected: diff -r 5a66e43d8cbd -r 5bf88dce615f hotspot/src/share/vm/gc/shared/preservedMarks.cpp --- a/hotspot/src/share/vm/gc/shared/preservedMarks.cpp Wed Jul 05 21:57:12 2017 +0200 +++ b/hotspot/src/share/vm/gc/shared/preservedMarks.cpp Wed Jul 05 21:58:29 2017 +0200 @@ -48,10 +48,10 @@ #ifndef PRODUCT void PreservedMarks::assert_empty() { - assert(_stack.is_empty(), "stack expected to be empty, size = "SIZE_FORMAT, + assert(_stack.is_empty(), "stack expected to be empty, size = " SIZE_FORMAT, _stack.size()); assert(_stack.cache_size() == 0, - "stack expected to have no cached segments, cache size = "SIZE_FORMAT, + "stack expected to have no cached segments, cache size = " SIZE_FORMAT, _stack.cache_size()); } #endif // ndef PRODUCT diff -r 5a66e43d8cbd -r 5bf88dce615f hotspot/src/share/vm/interpreter/rewriter.cpp --- a/hotspot/src/share/vm/interpreter/rewriter.cpp Wed Jul 05 21:57:12 2017 +0200 +++ b/hotspot/src/share/vm/interpreter/rewriter.cpp Wed Jul 05 21:58:29 2017 +0200 @@ -419,21 +419,20 @@ InstanceKlass* klass = method->method_holder(); u2 bc_index = Bytes::get_Java_u2(bcp + prefix_length + 1); constantPoolHandle cp(method->constants()); - Symbol* field_name = cp->name_ref_at(bc_index); - Symbol* field_sig = cp->signature_ref_at(bc_index); Symbol* ref_class_name = cp->klass_name_at(cp->klass_ref_index_at(bc_index)); if (klass->name() == ref_class_name) { + Symbol* field_name = cp->name_ref_at(bc_index); + Symbol* field_sig = cp->signature_ref_at(bc_index); + fieldDescriptor fd; klass->find_field(field_name, field_sig, &fd); if (fd.access_flags().is_final()) { if (fd.access_flags().is_static()) { - assert(c == Bytecodes::_putstatic, "must be putstatic"); if (!method->is_static_initializer()) { fd.set_has_initialized_final_update(true); } } else { - assert(c == Bytecodes::_putfield, "must be putfield"); if (!method->is_object_initializer()) { fd.set_has_initialized_final_update(true); } diff -r 5a66e43d8cbd -r 5bf88dce615f hotspot/src/share/vm/runtime/arguments.cpp --- a/hotspot/src/share/vm/runtime/arguments.cpp Wed Jul 05 21:57:12 2017 +0200 +++ b/hotspot/src/share/vm/runtime/arguments.cpp Wed Jul 05 21:58:29 2017 +0200 @@ -584,27 +584,26 @@ // Parses a size specification string. bool Arguments::atojulong(const char *s, julong* result) { julong n = 0; - int args_read = 0; - bool is_hex = false; - // Skip leading 0[xX] for hexadecimal - if (*s =='0' && (*(s+1) == 'x' || *(s+1) == 'X')) { - s += 2; - is_hex = true; - args_read = sscanf(s, JULONG_FORMAT_X, &n); - } else { - args_read = sscanf(s, JULONG_FORMAT, &n); - } - if (args_read != 1) { + + // First char must be a digit. Don't allow negative numbers or leading spaces. + if (!isdigit(*s)) { return false; } - while (*s != '\0' && (isdigit(*s) || (is_hex && isxdigit(*s)))) { - s++; - } - // 4705540: illegal if more characters are found after the first non-digit - if (strlen(s) > 1) { + + bool is_hex = (s[0] == '0' && (s[1] == 'x' || s[1] == 'X')); + char* remainder; + errno = 0; + n = strtoull(s, &remainder, (is_hex ? 16 : 10)); + if (errno != 0) { return false; } - switch (*s) { + + // Fail if no number was read at all or if the remainder contains more than a single non-digit character. + if (remainder == s || strlen(remainder) > 1) { + return false; + } + + switch (*remainder) { case 'T': case 't': *result = n * G * K; // Check for overflow. diff -r 5a66e43d8cbd -r 5bf88dce615f hotspot/src/share/vm/utilities/vmError.cpp --- a/hotspot/src/share/vm/utilities/vmError.cpp Wed Jul 05 21:57:12 2017 +0200 +++ b/hotspot/src/share/vm/utilities/vmError.cpp Wed Jul 05 21:58:29 2017 +0200 @@ -205,16 +205,39 @@ static void print_oom_reasons(outputStream* st) { st->print_cr("# Possible reasons:"); st->print_cr("# The system is out of physical RAM or swap space"); - st->print_cr("# In 32 bit mode, the process size limit was hit"); + if (UseCompressedOops) { + st->print_cr("# The process is running with CompressedOops enabled, and the Java Heap may be blocking the growth of the native heap"); + } + if (LogBytesPerWord == 2) { + st->print_cr("# In 32 bit mode, the process size limit was hit"); + } st->print_cr("# Possible solutions:"); st->print_cr("# Reduce memory load on the system"); st->print_cr("# Increase physical memory or swap space"); st->print_cr("# Check if swap backing store is full"); - st->print_cr("# Use 64 bit Java on a 64 bit OS"); + if (LogBytesPerWord == 2) { + st->print_cr("# Use 64 bit Java on a 64 bit OS"); + } st->print_cr("# Decrease Java heap size (-Xmx/-Xms)"); st->print_cr("# Decrease number of Java threads"); st->print_cr("# Decrease Java thread stack sizes (-Xss)"); st->print_cr("# Set larger code cache with -XX:ReservedCodeCacheSize="); + if (UseCompressedOops) { + switch (Universe::narrow_oop_mode()) { + case Universe::UnscaledNarrowOop: + st->print_cr("# JVM is running with Unscaled Compressed Oops mode in which the Java heap is"); + st->print_cr("# placed in the first 4GB address space. The Java Heap base address is the"); + st->print_cr("# maximum limit for the native heap growth. Please use -XX:HeapBaseMinAddress"); + st->print_cr("# to set the Java Heap base and to place the Java Heap above 4GB virtual address."); + break; + case Universe::ZeroBasedNarrowOop: + st->print_cr("# JVM is running with Zero Based Compressed Oops mode in which the Java heap is"); + st->print_cr("# placed in the first 32GB address space. The Java Heap base address is the"); + st->print_cr("# maximum limit for the native heap growth. Please use -XX:HeapBaseMinAddress"); + st->print_cr("# to set the Java Heap base and to place the Java Heap above 32GB virtual address."); + break; + } + } st->print_cr("# This output file may be truncated or incomplete."); } diff -r 5a66e43d8cbd -r 5bf88dce615f hotspot/test/TEST.groups --- a/hotspot/test/TEST.groups Wed Jul 05 21:57:12 2017 +0200 +++ b/hotspot/test/TEST.groups Wed Jul 05 21:58:29 2017 +0200 @@ -395,6 +395,17 @@ :hotspot_fast_gc_gcold \ :hotspot_fast_runtime \ :hotspot_fast_serviceability + +hotspot_runtime_tier2 = \ + runtime/ \ + serviceability/ \ + -:hotspot_fast_runtime \ + -:hotspot_fast_serviceability \ + -:hotspot_runtime_tier2_platform_agnostic + +hotspot_runtime_tier2_platform_agnostic = \ + runtime/SelectionResolution \ + -:hotspot_fast_runtime #All tests that depends on nashorn extension. # diff -r 5a66e43d8cbd -r 5bf88dce615f hotspot/test/gc/g1/humongousObjects/TestNoAllocationsInHRegions.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/test/gc/g1/humongousObjects/TestNoAllocationsInHRegions.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,234 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 gc.g1.humongousObjects; + +import jdk.test.lib.Utils; +import sun.hotspot.WhiteBox; + +import java.util.LinkedList; +import java.util.List; +import java.util.Random; +import java.util.stream.Collectors; + +/** + * @test TestNoAllocationsInHRegions + * @summary Checks that no additional allocations are made in humongous regions + * @requires vm.gc.G1 + * @library /testlibrary /test/lib / + * @modules java.management java.base/jdk.internal.misc + * @build sun.hotspot.WhiteBox + * gc.testlibrary.Helpers + * gc.g1.humongousObjects.TestNoAllocationsInHRegions + * + * @run driver ClassFileInstaller sun.hotspot.WhiteBox + * sun.hotspot.WhiteBox$WhiteBoxPermission + * + * @run main/othervm -XX:+UseG1GC -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. + * -XX:G1HeapRegionSize=1M -Xms200m -Xmx200m -XX:MaxTenuringThreshold=0 + * -Xlog:gc=trace:file=TestNoAllocationsInHRegions10.log + * gc.g1.humongousObjects.TestNoAllocationsInHRegions 30 10 + * + * @run main/othervm -XX:+UseG1GC -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. + * -XX:G1HeapRegionSize=1M -Xms200m -Xmx200m -XX:MaxTenuringThreshold=0 + * -Xlog:gc=trace:file=TestNoAllocationsInHRegions50.log + * gc.g1.humongousObjects.TestNoAllocationsInHRegions 30 50 + * + * @run main/othervm -XX:+UseG1GC -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. + * -XX:G1HeapRegionSize=1M -Xms200m -Xmx200m -XX:MaxTenuringThreshold=0 + * -Xlog:gc=trace:file=TestNoAllocationsInHRegions70.log + * gc.g1.humongousObjects.TestNoAllocationsInHRegions 30 70 + */ +public class TestNoAllocationsInHRegions { + private static final WhiteBox WB = WhiteBox.getWhiteBox(); + private static final Random RND = Utils.getRandomInstance(); + private static final int G1_REGION_SIZE = WB.g1RegionSize(); + private static final int[] HUMONGOUS_SIZES = {G1_REGION_SIZE / 2, G1_REGION_SIZE + 1, G1_REGION_SIZE * 2 + 1}; + private static final int ALLOC_THREAD_COUNT = 5; + + // We fill specified part of heap with humongous objects - we need public static to prevent escape analysis to + // collect this field + public static LinkedList humongousAllocations = new LinkedList<>(); + + private static volatile boolean shouldStop = false; + private static volatile Error error = null; + + static class Allocator implements Runnable { + + private final List liveObjects = new LinkedList<>(); + private int usedMemory = 0; + public final Runnable[] actions; + + /** + * Maximum size of simple allocation + */ + private static final int MAX_ALLOCATION_SIZE = (int) (G1_REGION_SIZE / 2 * 0.9); + + /** + * Maximum size of dead (i.e. one which is made unreachable right after allocation) object + */ + private static final int DEAD_OBJECT_MAX_SIZE = G1_REGION_SIZE / 10; + + public Allocator(int maxAllocationMemory) { + + actions = new Runnable[]{ + // Allocation + () -> { + if (maxAllocationMemory - usedMemory != 0) { + int arraySize = RND.nextInt(Math.min(maxAllocationMemory - usedMemory, + MAX_ALLOCATION_SIZE)); + + if (arraySize != 0) { + byte[] allocation = new byte[arraySize]; + liveObjects.add(allocation); + usedMemory += arraySize; + + // Sanity check + if (WB.g1IsHumongous(allocation)) { + String errorMessage = String.format("Test Bug: Byte array of size" + + " %d is expected to be non-humongous but it is humongous", + allocation.length); + + System.out.println(errorMessage); + error = new Error(errorMessage); + shouldStop = true; + } + + // Test check + if (WB.g1BelongsToHumongousRegion(WB.getObjectAddress(allocation))) { + String errorMessage = String.format("Non-humongous allocation of byte array of " + + "length %d and size %d with address %d was made in Humongous Region", + allocation.length, WB.getObjectSize(allocation), + WB.getObjectAddress(allocation)); + + System.out.println(errorMessage); + error = new Error(errorMessage); + shouldStop = true; + } + } + } + }, + + // Deallocation + () -> { + if (liveObjects.size() != 0) { + int elementNum = RND.nextInt(liveObjects.size()); + int shouldFree = liveObjects.get(elementNum).length; + liveObjects.remove(elementNum); + usedMemory -= shouldFree; + } + }, + + // Dead object allocation + () -> { + int size = RND.nextInt(DEAD_OBJECT_MAX_SIZE); + byte[] deadObject = new byte[size]; + }, + + // Check + () -> { + List wrongHumongousAllocations = liveObjects.stream() + .filter(WB::g1IsHumongous) + .collect(Collectors.toList()); + + if (wrongHumongousAllocations.size() > 0) { + wrongHumongousAllocations.stream().forEach(a -> + System.out.format("Non-humongous allocation of byte array of length %d and" + + " size %d with address %d was made in Humongous Region", + a.length, WB.getObjectSize(a), WB.getObjectAddress(a))); + error = new Error("Some non-humongous allocations were made to humongous region"); + shouldStop = true; + } + } + }; + } + + @Override + public void run() { + while (!shouldStop) { + actions[RND.nextInt(actions.length)].run(); + Thread.yield(); + } + } + } + + public static void main(String[] args) { + if (args.length != 2) { + throw new Error("Test Bug: Expected duration (in seconds) and percent of allocated regions were not " + + "provided as command line argument"); + } + + // test duration + long duration = Integer.parseInt(args[0]) * 1000L; + // part of heap preallocated with humongous objects (in percents) + int percentOfAllocatedHeap = Integer.parseInt(args[1]); + + long startTime = System.currentTimeMillis(); + + long initialFreeRegionsCount = WB.g1NumFreeRegions(); + int regionsToAllocate = (int) ((double) initialFreeRegionsCount / 100.0 * percentOfAllocatedHeap); + long freeRegionLeft = initialFreeRegionsCount - regionsToAllocate; + + System.out.println("Regions to allocate: " + regionsToAllocate + "; regions to left free: " + freeRegionLeft); + + int maxMemoryPerAllocThread = (int) ((Runtime.getRuntime().freeMemory() / 100.0 + * (100 - percentOfAllocatedHeap)) / ALLOC_THREAD_COUNT * 0.5); + + System.out.println("Using " + maxMemoryPerAllocThread / 1024 + "KB for each of " + ALLOC_THREAD_COUNT + + " allocation threads"); + + while (WB.g1NumFreeRegions() > freeRegionLeft) { + try { + humongousAllocations.add(new byte[HUMONGOUS_SIZES[RND.nextInt(HUMONGOUS_SIZES.length)]]); + } catch (OutOfMemoryError oom) { + //We got OOM trying to fill heap with humongous objects + //It probably means that heap is fragmented which is strange since the test logic should avoid it + System.out.println("Warning: OOM while allocating humongous objects - it likely means " + + "that heap is fragmented"); + break; + } + } + + System.out.println("Initial free regions " + initialFreeRegionsCount + "; Free regions left " + + WB.g1NumFreeRegions()); + + LinkedList threads = new LinkedList<>(); + + for (int i = 0; i < ALLOC_THREAD_COUNT; i++) { + threads.add(new Thread(new Allocator(maxMemoryPerAllocThread))); + } + + threads.stream().forEach(Thread::start); + + while ((System.currentTimeMillis() - startTime < duration) && error == null) { + Thread.yield(); + } + + shouldStop = true; + System.out.println("Finished test"); + if (error != null) { + throw error; + } + } +} diff -r 5a66e43d8cbd -r 5bf88dce615f hotspot/test/gc/g1/humongousObjects/objectGraphTest/GC.java --- a/hotspot/test/gc/g1/humongousObjects/objectGraphTest/GC.java Wed Jul 05 21:57:12 2017 +0200 +++ b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/GC.java Wed Jul 05 21:58:29 2017 +0200 @@ -138,6 +138,41 @@ } }, + MIXED_GC { + @Override + public Runnable get() { + return () -> { + WHITE_BOX.youngGC(); + Helpers.waitTillCMCFinished(WHITE_BOX, 0); + WHITE_BOX.youngGC(); + Helpers.waitTillCMCFinished(WHITE_BOX, 0); + + WHITE_BOX.g1StartConcMarkCycle(); + Helpers.waitTillCMCFinished(WHITE_BOX, 0); + + WHITE_BOX.youngGC(); + Helpers.waitTillCMCFinished(WHITE_BOX, 0); + // Provoking Mixed GC + WHITE_BOX.youngGC();// second evacuation pause will be mixed + Helpers.waitTillCMCFinished(WHITE_BOX, 0); + }; + } + + public Consumer> getChecker() { + return getCheckerImpl(true, false, true, false); + } + + @Override + public List shouldContain() { + return Arrays.asList(GCTokens.WB_INITIATED_CMC); + } + + @Override + public List shouldNotContain() { + return Arrays.asList(GCTokens.YOUNG_GC); + } + }, + FULL_GC_MEMORY_PRESSURE { @Override public Runnable get() { diff -r 5a66e43d8cbd -r 5bf88dce615f hotspot/test/gc/g1/humongousObjects/objectGraphTest/README --- a/hotspot/test/gc/g1/humongousObjects/objectGraphTest/README Wed Jul 05 21:57:12 2017 +0200 +++ b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/README Wed Jul 05 21:58:29 2017 +0200 @@ -38,6 +38,9 @@ non-humongous and humongous objects are not collected since we make 2 Young GC to promote all weak references to Old Gen. +6. Mixed GC - weakly referenced non-humongous and humongous objects are collected, softly referenced non-humongous and + humongous objects are not collected. + The test gets gc type as a command line argument. Then the test allocates object graph in heap (currently testing scenarios are pre-generated and stored in TestcaseData.getPregeneratedTestcases()) with TestObjectGraphAfterGC::allocateObjectGraph. diff -r 5a66e43d8cbd -r 5bf88dce615f hotspot/test/gc/g1/humongousObjects/objectGraphTest/TestObjectGraphAfterGC.java --- a/hotspot/test/gc/g1/humongousObjects/objectGraphTest/TestObjectGraphAfterGC.java Wed Jul 05 21:57:12 2017 +0200 +++ b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/TestObjectGraphAfterGC.java Wed Jul 05 21:58:29 2017 +0200 @@ -66,6 +66,12 @@ * sun.hotspot.WhiteBox$WhiteBoxPermission * * @run main/othervm -Xms200M -XX:+UseG1GC -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. + * -XX:+UnlockExperimentalVMOptions -XX:MaxGCPauseMillis=30000 -XX:G1MixedGCLiveThresholdPercent=100 -XX:G1HeapWastePercent=0 + * -XX:G1HeapRegionSize=1M -Xlog:gc=info:file=TestObjectGraphAfterGC_MIXED_GC.gc.log -XX:MaxTenuringThreshold=1 + * -XX:G1MixedGCCountTarget=1 -XX:G1OldCSetRegionThresholdPercent=100 -XX:SurvivorRatio=1 -XX:InitiatingHeapOccupancyPercent=0 + * gc.g1.humongousObjects.objectGraphTest.TestObjectGraphAfterGC MIXED_GC + * + * @run main/othervm -Xms200M -XX:+UseG1GC -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. * -XX:G1HeapRegionSize=1M -Xlog:gc*=debug:file=TestObjectGraphAfterGC_YOUNG_GC.gc.log * gc.g1.humongousObjects.objectGraphTest.TestObjectGraphAfterGC YOUNG_GC * diff -r 5a66e43d8cbd -r 5bf88dce615f hotspot/test/native/runtime/test_arguments.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/test/native/runtime/test_arguments.cpp Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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" +#include "unittest.hpp" +#include "utilities/globalDefinitions.hpp" + +TEST(arguments, atojulong) { + char ullong_max[32]; + int ret = jio_snprintf(ullong_max, sizeof(ullong_max), JULONG_FORMAT, ULLONG_MAX); + ASSERT_NE(-1, ret); + + julong value; + const char* invalid_strings[] = { + "", "-1", "-100", " 1", "2 ", "3 2", "1.0", + "0x4.5", "0x", "0x0x1" "0.001", "4e10", "e" + "K", "M", "G", "1MB", "1KM", "AA", "0B", + "18446744073709551615K", "17179869184G", + "999999999999999999999999999999" + }; + for (uint i = 0; i < ARRAY_SIZE(invalid_strings); i++) { + ASSERT_FALSE(Arguments::atojulong(invalid_strings[i], &value)) + << "Invalid string '" << invalid_strings[i] << "' parsed without error."; + } + + struct { + const char* str; + julong expected_value; + } valid_strings[] = { + { "0", 0 }, + { "4711", 4711 }, + { "1K", 1ULL * K }, + { "1k", 1ULL * K }, + { "2M", 2ULL * M }, + { "2m", 2ULL * M }, + { "4G", 4ULL * G }, + { "4g", 4ULL * G }, + { "0K", 0 }, + { ullong_max, ULLONG_MAX }, + { "0xcafebabe", 0xcafebabe }, + { "0XCAFEBABE", 0xcafebabe }, + { "0XCAFEbabe", 0xcafebabe }, + { "0x10K", 0x10 * K } + }; + for (uint i = 0; i < ARRAY_SIZE(valid_strings); i++) { + ASSERT_TRUE(Arguments::atojulong(valid_strings[i].str, &value)) + << "Valid string '" << valid_strings[i].str << "' did not parse."; + ASSERT_EQ(valid_strings[i].expected_value, value); + } +} diff -r 5a66e43d8cbd -r 5bf88dce615f hotspot/test/runtime/Final/Bad.jasm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/test/runtime/Final/Bad.jasm Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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. + */ + +/* Recoded in jasm to provoke an ICCE assigning a non-static final field with putstatic. +class Bad { + public static final int i; //rewritten + //rewritten to: public final int i; + static { i = 5; } // putstatic instruction +} +*/ + +super class Bad + version 53:0 +{ + +// Remove 'static' keyword +public final Field i:I; + +Method "":"()V" + stack 1 locals 1 +{ + aload_0; + invokespecial Method java/lang/Object."":"()V"; + return; +} + +static Method "":"()V" + stack 1 locals 0 +{ + iconst_5; + putstatic Field i:"I"; + return; +} + +} // end Class Bad diff -r 5a66e43d8cbd -r 5bf88dce615f hotspot/test/runtime/Final/PutfieldError.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/test/runtime/Final/PutfieldError.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 PutfieldError + * @bug 8160551 + * @summary Throw ICCE rather than crashing for nonstatic final field in static initializer + * @compile Bad.jasm + * @run main PutfieldError + */ + +public class PutfieldError { + public static void main(java.lang.String[] unused) { + try { + Bad b = new Bad(); + System.out.println("Bad.i = " + 5); + throw new RuntimeException("ICCE NOT thrown as expected"); + } catch (IncompatibleClassChangeError icce) { + System.out.println("ICCE thrown as expected"); + } + } +} diff -r 5a66e43d8cbd -r 5bf88dce615f hotspot/test/runtime/SharedArchiveFile/SharedStringsDedup.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/test/runtime/SharedArchiveFile/SharedStringsDedup.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 SharedStringsDedup + * @summary Test -Xshare:auto with shared strings and -XX:+UseStringDeduplication + * Feature support: G1GC only, compressed oops/kptrs, 64-bit os, not on windows + * @requires (sun.arch.data.model != "32") & (os.family != "windows") + * @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true) + * @requires vm.gc.G1 + * @library /testlibrary + * @modules java.base/jdk.internal.misc + * java.management + * @run main SharedStringsDedup + */ + +import jdk.test.lib.*; +import java.io.File; + +// The main purpose is to test the interaction between shared strings +// and -XX:+UseStringDeduplication. We run in -Xshare:auto mode so +// we don't need to worry about CDS archive mapping failure (which +// doesn't happen often so it won't impact coverage). +public class SharedStringsDedup { + public static void main(String[] args) throws Exception { + // Dump + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + "-XX:+UnlockDiagnosticVMOptions", + "-XX:SharedArchiveFile=./SharedStringsDedup.jsa", + "-XX:+UseCompressedOops", "-XX:+UseG1GC", + "-XX:+PrintSharedSpaces", + "-Xshare:dump"); + + new OutputAnalyzer(pb.start()) + .shouldContain("Loading classes to share") + .shouldContain("Shared string table stats") + .shouldHaveExitValue(0); + + // Run with -Xshare:auto + pb = ProcessTools.createJavaProcessBuilder( + "-XX:+UnlockDiagnosticVMOptions", + "-XX:SharedArchiveFile=./SharedStringsDedup.jsa", + "-XX:+UseCompressedOops", "-XX:+UseG1GC", + "-XX:+UseStringDeduplication", + "-Xshare:auto", + "-version"); + + new OutputAnalyzer(pb.start()) + .shouldMatch("(java|openjdk) version") + .shouldHaveExitValue(0); + } +} diff -r 5a66e43d8cbd -r 5bf88dce615f hotspot/test/runtime/modules/ModuleStress/CustomSystemClassLoader.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/test/runtime/modules/ModuleStress/CustomSystemClassLoader.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 custom system ClassLoader to define the module "m2" to during iterations of + * differing test runs within the test ModuleStress.java + */ +public class CustomSystemClassLoader extends ClassLoader { + public CustomSystemClassLoader() { + super(); + } + public CustomSystemClassLoader(ClassLoader parent) { + super(parent); + } +} diff -r 5a66e43d8cbd -r 5bf88dce615f hotspot/test/runtime/modules/ModuleStress/ModuleNonBuiltinCLMain.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/test/runtime/modules/ModuleStress/ModuleNonBuiltinCLMain.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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. + */ + +import static jdk.test.lib.Asserts.*; + +import java.lang.reflect.Layer; +import java.lang.module.Configuration; +import java.lang.module.ModuleDescriptor; +import java.lang.module.ModuleFinder; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +// +// ClassLoader1 --> defines m1 --> packages p1 +// ClassLoader2 --> defines m2 --> packages p2 +// Java System Class Loader --> defines m3 --> packages p3 +// +// m1 can read m2 +// package p2 in m2 is exported to m1 and m3 +// +// class p1.c1 defined in m1 tries to access p2.c2 defined in m2 +// Access allowed since m1 can read m2 and package p2 is exported to m1. +// +public class ModuleNonBuiltinCLMain { + + // Create a Layer over the boot layer. + // Define modules within this layer to test access between + // publically defined classes within packages of those modules. + public void createLayerOnBoot() throws Throwable { + + // Define module: m1 + // Can read: java.base, m2 + // Packages: p1 + // Packages exported: p1 is exported to unqualifiedly + ModuleDescriptor descriptor_m1 = + new ModuleDescriptor.Builder("m1") + .requires("java.base") + .requires("m2") + .exports("p1") + .build(); + + // Define module: m2 + // Can read: java.base, m3 + // Packages: p2 + // Packages exported: package p2 is exported to m1 and m3 + Set targets = new HashSet<>(); + targets.add("m1"); + targets.add("m3"); + ModuleDescriptor descriptor_m2 = + new ModuleDescriptor.Builder("m2") + .requires("java.base") + .requires("m3") + .exports("p2", targets) + .build(); + + // Define module: m3 + // Can read: java.base + // Packages: p3 + // Packages exported: none + ModuleDescriptor descriptor_m3 = + new ModuleDescriptor.Builder("m3") + .requires("java.base") + .build(); + + // Set up a ModuleFinder containing all modules for this layer. + ModuleFinder finder = ModuleLibrary.of(descriptor_m1, descriptor_m2, descriptor_m3); + + // Resolves "m1" + Configuration cf = Layer.boot() + .configuration() + .resolveRequires(finder, ModuleFinder.of(), Set.of("m1")); + + // map each module to differing user defined class loaders for this test + Map map = new HashMap<>(); + Loader1 cl1 = new Loader1(); + Loader2 cl2 = new Loader2(); + ClassLoader cl3 = ClassLoader.getSystemClassLoader(); + map.put("m1", cl1); + map.put("m2", cl2); + map.put("m3", cl3); + + // Create Layer that contains m1 & m2 + Layer layer = Layer.boot().defineModules(cf, map::get); + assertTrue(layer.findLoader("m1") == cl1); + assertTrue(layer.findLoader("m2") == cl2); + assertTrue(layer.findLoader("m3") == cl3); + assertTrue(layer.findLoader("java.base") == null); + + // now use the same loader to load class p1.c1 + Class p1_c1_class = cl1.loadClass("p1.c1"); + try { + p1_c1_class.newInstance(); + } catch (IllegalAccessError e) { + throw new RuntimeException("Test Failed, an IAE should not be thrown since p2 is exported qualifiedly to m1"); + } + } + + public static void main(String args[]) throws Throwable { + ModuleNonBuiltinCLMain test = new ModuleNonBuiltinCLMain(); + test.createLayerOnBoot(); + } + + static class Loader1 extends ClassLoader { } + static class Loader2 extends ClassLoader { } +} diff -r 5a66e43d8cbd -r 5bf88dce615f hotspot/test/runtime/modules/ModuleStress/ModuleSameCLMain.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/test/runtime/modules/ModuleStress/ModuleSameCLMain.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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. + */ + +import static jdk.test.lib.Asserts.*; + +import java.lang.reflect.Layer; +import java.lang.module.Configuration; +import java.lang.module.ModuleDescriptor; +import java.lang.module.ModuleFinder; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +// +// ClassLoader1 --> defines m1 --> packages p1 +// ClassLoader1 --> defines m2 --> packages p2 +// +// m1 can read m2 +// package p2 in m2 is exported to m1 +// +// class p1.c1 defined in m1 tries to access p2.c2 defined in m2 +// Access allowed since m1 can read m2 and package p2 is exported to m1. +// +public class ModuleSameCLMain { + + // Create a Layer over the boot layer. + // Define modules within this layer to test access between + // publically defined classes within packages of those modules. + public void createLayerOnBoot() throws Throwable { + + // Define module: m1 + // Can read: java.base, m2 + // Packages: p1 + // Packages exported: p1 is exported to unqualifiedly + ModuleDescriptor descriptor_m1 = + new ModuleDescriptor.Builder("m1") + .requires("java.base") + .requires("m2") + .exports("p1") + .build(); + + // Define module: m2 + // Can read: java.base + // Packages: p2 + // Packages exported: package p2 is exported to m1 + ModuleDescriptor descriptor_m2 = + new ModuleDescriptor.Builder("m2") + .requires("java.base") + .exports("p2", "m1") + .build(); + + // Set up a ModuleFinder containing all modules for this layer. + ModuleFinder finder = ModuleLibrary.of(descriptor_m1, descriptor_m2); + + // Resolves "m1" + Configuration cf = Layer.boot() + .configuration() + .resolveRequires(finder, ModuleFinder.of(), Set.of("m1")); + + // map each module to the same class loader for this test + Map map = new HashMap<>(); + Loader1 cl1 = new Loader1(); + map.put("m1", cl1); + map.put("m2", cl1); + + // Create Layer that contains m1 & m2 + Layer layer = Layer.boot().defineModules(cf, map::get); + assertTrue(layer.findLoader("m1") == cl1); + assertTrue(layer.findLoader("m2") == cl1); + assertTrue(layer.findLoader("java.base") == null); + + // now use the same loader to load class p1.c1 + Class p1_c1_class = cl1.loadClass("p1.c1"); + try { + p1_c1_class.newInstance(); + } catch (IllegalAccessError e) { + throw new RuntimeException("Test Failed, an IAE should not be thrown since p2 is exported qualifiedly to m1"); + } + } + + public static void main(String args[]) throws Throwable { + ModuleSameCLMain test = new ModuleSameCLMain(); + test.createLayerOnBoot(); + } + + static class Loader1 extends ClassLoader { } +} diff -r 5a66e43d8cbd -r 5bf88dce615f hotspot/test/runtime/modules/ModuleStress/ModuleStress.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/test/runtime/modules/ModuleStress/ModuleStress.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 8159262 + * @summary Test differing scenarios where a module's readability list and a package's exportability list should be walked + * @modules java.base/jdk.internal.misc + * @library /testlibrary /test/lib + * @compile ../AccessCheck/ModuleLibrary.java + * @compile ModuleSameCLMain.java + * @compile ModuleNonBuiltinCLMain.java + * @compile CustomSystemClassLoader.java + * @build ModuleStress + * @run main/othervm ModuleStress + */ + +import jdk.test.lib.*; +import java.io.File; + +public class ModuleStress { + + public static void main(String[] args) throws Exception { + + // Test #1: java -version + // All modules' readability lists and packages' exportability + // lists should contain only modules defined to the 3 builtin + // loaders (boot, application, platform). Thus there is + // not a need to walk those lists at a GC safepoint since + // those loaders never die. + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + "-Xbootclasspath/a:.", + "-Xlog:modules=trace", + "-version"); + + OutputAnalyzer oa = new OutputAnalyzer(pb.start()); + oa.shouldNotContain("must be walked") + .shouldNotContain("being walked") + .shouldHaveExitValue(0); + + // Next 2 tests involve the use of class p1.c1 and p2.c2 + String source1 = "package p1;" + + "import p2.c2;" + + "public class c1 {" + + " public c1() {" + + " p2.c2 c2_obj = new p2.c2();" + + " c2_obj.method2();" + + " }" + + "}"; + + String source2 = "package p2;" + + "public class c2 {" + + " public void method2() { }" + + "}"; + + ClassFileInstaller.writeClassToDisk("p2/c2", + InMemoryJavaCompiler.compile("p2.c2", source2), System.getProperty("test.classes")); + + ClassFileInstaller.writeClassToDisk("p1/c1", + InMemoryJavaCompiler.compile("p1.c1", source1), System.getProperty("test.classes")); + + // Test #2: Load two modules defined to the same customer class loader. + // m1's module readability list and package p2's exportability should + // not be walked at a GC safepoint since both modules are defined to + // the same loader and thus have the exact same life cycle. + pb = ProcessTools.createJavaProcessBuilder( + "-Xbootclasspath/a:.", + "-Xlog:modules=trace", + "ModuleSameCLMain"); + + oa = new OutputAnalyzer(pb.start()); + oa.shouldNotContain("must be walked") + .shouldNotContain("being walked") + .shouldHaveExitValue(0); + + // Test #3: Load two modules in differing custom class loaders. + // m1's module readability list and package p2's exportability list must + // be walked at a GC safepoint since both modules are defined to non-builtin + // class loaders which could die and thus be unloaded. + pb = ProcessTools.createJavaProcessBuilder( + "-Xbootclasspath/a:.", + "-Xlog:modules=trace", + "ModuleNonBuiltinCLMain"); + + oa = new OutputAnalyzer(pb.start()); + oa.shouldContain("module m1 reads list must be walked") + .shouldContain("package p2 defined in module m2, exports list must be walked") + .shouldNotContain("module m2 reads list must be walked") + .shouldHaveExitValue(0); + + // Test #4: Load two modules in differing custom class loaders, + // of which one has been designated as the custom system class loader + // via -Djava.system.class.loader=CustomSystemClassLoader. Since + // m3 is defined to the system class loader, m2's module readability + // list does not have to be walked at a GC safepoint, but package p2's + // exportability list does. + pb = ProcessTools.createJavaProcessBuilder( + "-Djava.system.class.loader=CustomSystemClassLoader", + "-Xbootclasspath/a:.", + "-Xlog:modules=trace", + "ModuleNonBuiltinCLMain"); + + oa = new OutputAnalyzer(pb.start()); + oa.shouldContain("package p2 defined in module m2, exports list must be walked") + .shouldNotContain("module m2 reads list must be walked") + .shouldHaveExitValue(0); + + } +} diff -r 5a66e43d8cbd -r 5bf88dce615f hotspot/test/runtime/modules/ModuleStress/ModuleStressGC.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/test/runtime/modules/ModuleStress/ModuleStressGC.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 8159262 + * @summary layers over the boot layer are repeatedly created, during this iteration, GCs are forced to verify correct walk of module and package lists. + * @modules java.base/jdk.internal.misc + * @library /testlibrary /test/lib + * @compile ../CompilerUtils.java + * @build ModuleStressGC + * @run main/othervm ModuleStressGC + */ + +import java.nio.file.Path; +import java.nio.file.Paths; +import jdk.test.lib.*; + +public class ModuleStressGC { + + private static final String TEST_SRC = System.getProperty("test.src"); + private static final String TEST_CLASSES = System.getProperty("test.classes"); + + private static final Path SRC_DIR = Paths.get(TEST_SRC, "src"); + private static final Path MODS_DIR = Paths.get(TEST_CLASSES, "mods"); + + /** + * Compile two module definitions used by the test, jdk.test and jdk.translet. + */ + public static void main(String[] args) throws Exception { + + boolean compiled; + // Compile module jdk.test declaration + compiled = CompilerUtils.compile( + SRC_DIR.resolve("jdk.test"), + MODS_DIR.resolve("jdk.test")); + if (!compiled) { + throw new RuntimeException("Test failed to compile module jdk.test"); + } + + // Compile module jdk.translet declaration + compiled = CompilerUtils.compile( + SRC_DIR.resolve("jdk.translet"), + MODS_DIR.resolve("jdk.translet"), + "-XaddExports:jdk.test/test=jdk.translet", + "-mp", MODS_DIR.toString()); + if (!compiled) { + throw new RuntimeException("Test failed to compile module jdk.translet"); + } + + // Sanity check that the test, jdk.test/test/MainGC.java, + // correctly walks module jdk.test's reads list and package + // test's, defined to module jdk.translet, export list at + // GC safepoints. + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + "-Xlog:modules=trace", + "-mp", MODS_DIR.toString(), + "-m", "jdk.test/test.MainGC"); + OutputAnalyzer oa = new OutputAnalyzer(pb.start()); + oa.shouldContain("package test defined in module jdk.test, exports list being walked") + .shouldContain("module jdk.test reads list being walked") + .shouldHaveExitValue(0); + } +} diff -r 5a66e43d8cbd -r 5bf88dce615f hotspot/test/runtime/modules/ModuleStress/src/jdk.test/test/MainGC.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/test/runtime/modules/ModuleStress/src/jdk.test/test/MainGC.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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; + +import java.lang.module.Configuration; +import java.lang.module.ModuleFinder; +import java.lang.reflect.Layer; +import java.lang.reflect.Method; +import java.lang.reflect.Module; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.*; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + +public class MainGC { + + private static final Path MODS_DIR = Paths.get(System.getProperty("jdk.module.path")); + static final String MODULE_NAME = "jdk.translet"; + + public static void main(String[] args) throws Exception { + + ModuleFinder finder = ModuleFinder.of(MODS_DIR); + Layer layerBoot = Layer.boot(); + + Configuration cf = layerBoot + .configuration() + .resolveRequires(ModuleFinder.of(), finder, Set.of(MODULE_NAME)); + + Module testModule = MainGC.class.getModule(); + ClassLoader scl = ClassLoader.getSystemClassLoader(); + + // Create an unique module/class loader in a layer above the boot layer. + // Export this module to the jdk.test/test package. + // Add a read edge from module jdk.test to this module. + Callable task = new Callable() { + @Override + public Void call() throws Exception { + Layer layer = Layer.boot().defineModulesWithOneLoader(cf, scl); + Module transletModule = layer.findModule(MODULE_NAME).get(); + testModule.addExports("test", transletModule); + testModule.addReads(transletModule); + Class c = layer.findLoader(MODULE_NAME).loadClass("translet.MainGC"); + Method method = c.getDeclaredMethod("go"); + method.invoke(null); + return null; + } + }; + + List> results = new ArrayList<>(); + + // Repeatedly create the layer above stressing the exportation of + // package jdk.test/test to several different modules. + ExecutorService pool = Executors.newFixedThreadPool(Math.min(100, Runtime.getRuntime().availableProcessors()*10)); + try { + for (int i = 0; i < 10000; i++) { + results.add(pool.submit(task)); + // At specified intervals, force a GC. This provides an + // opportunity to verify that both the module jdk.test's reads + // and the package test's, which is defined to jdk.test, exports + // lists are being walked. + if (i == 3000 || i == 6000 || i == 9000) { + System.gc(); + } + } + } finally { + pool.shutdown(); + } + + int passed = 0; + int failed = 0; + + // The failed state should be 0, the created modules in layers above the + // boot layer should be allowed access to the contents of the jdk.test/test + // package since that package was exported to the transletModule above. + for (Future result : results) { + try { + result.get(); + passed++; + } catch (Throwable x) { + x.printStackTrace(); + failed++; + } + } + + System.out.println("passed: " + passed); + System.out.println("failed: " + failed); + } + + public static void callback() { } +} diff -r 5a66e43d8cbd -r 5bf88dce615f hotspot/test/runtime/modules/ModuleStress/src/jdk.translet/translet/MainGC.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/test/runtime/modules/ModuleStress/src/jdk.translet/translet/MainGC.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 translet; + +public class MainGC { + public static void go() { + test.MainGC.callback(); + } +} diff -r 5a66e43d8cbd -r 5bf88dce615f jaxp/.hgtags --- a/jaxp/.hgtags Wed Jul 05 21:57:12 2017 +0200 +++ b/jaxp/.hgtags Wed Jul 05 21:58:29 2017 +0200 @@ -369,3 +369,4 @@ e04a15153cc293f05fcd60bc98236f50e16af46a jdk-9+124 493eb91ec32a6dea7604cfbd86c10045ad9af15b jdk-9+125 15722f71281f034bc696d8b96136da2ef34da44f jdk-9+126 +bdc3c0b737efbf899709eb3121ce760dcfb51151 jdk-9+127 diff -r 5a66e43d8cbd -r 5bf88dce615f jaxws/.hgtags --- a/jaxws/.hgtags Wed Jul 05 21:57:12 2017 +0200 +++ b/jaxws/.hgtags Wed Jul 05 21:58:29 2017 +0200 @@ -372,3 +372,4 @@ 1600da1665cd2cc127014e8c002b328ec33a9147 jdk-9+124 5b0570e3db29f6b8c80a4beac70d51284507b203 jdk-9+125 264a44128cd6286e598d5a849ceeb613c06269d0 jdk-9+126 +06d706c70634775418dc79a2671780ba1c624fd2 jdk-9+127 diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/.hgtags --- a/jdk/.hgtags Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/.hgtags Wed Jul 05 21:58:29 2017 +0200 @@ -369,3 +369,4 @@ 7ff61c55b5c6c124592f09b18953222009a204a6 jdk-9+124 073ab1d4edf5590cf1af7b6d819350c14e425c1a jdk-9+125 6fda66a5bdf2da8994032b9da2078a4137f4d954 jdk-9+126 +7a97b89ba83077ca62e4aa5a05437adc8f315343 jdk-9+127 diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/make/src/classes/build/tools/cldrconverter/CLDRConverter.java --- a/jdk/make/src/classes/build/tools/cldrconverter/CLDRConverter.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/make/src/classes/build/tools/cldrconverter/CLDRConverter.java Wed Jul 05 21:58:29 2017 +0200 @@ -693,6 +693,8 @@ "field.weekday", "field.dayperiod", "field.hour", + "timezone.hourFormat", + "timezone.gmtFormat", "field.minute", "field.second", "field.zone", diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/make/src/classes/build/tools/cldrconverter/CopyrightHeaders.java --- a/jdk/make/src/classes/build/tools/cldrconverter/CopyrightHeaders.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/make/src/classes/build/tools/cldrconverter/CopyrightHeaders.java Wed Jul 05 21:58:29 2017 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. * 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,12 +41,12 @@ " * Copyright (c) 2012, %d, Oracle and/or its affiliates. All rights reserved.\n" + " */\n"; - // Last updated: - 1/16/2015, 1:42:31 PM + // Last updated: - 6/06/2016, 1:42:31 PM private static final String UNICODE = "/*\n" + " * COPYRIGHT AND PERMISSION NOTICE\n" + " *\n" + - " * Copyright (C) 1991-2015 Unicode, Inc. All rights reserved.\n" + + " * Copyright (C) 1991-2016 Unicode, Inc. All rights reserved.\n" + " * Distributed under the Terms of Use in \n" + " * http://www.unicode.org/copyright.html.\n" + " *\n" + diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/make/src/classes/build/tools/cldrconverter/LDMLParseHandler.java --- a/jdk/make/src/classes/build/tools/cldrconverter/LDMLParseHandler.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/make/src/classes/build/tools/cldrconverter/LDMLParseHandler.java Wed Jul 05 21:58:29 2017 +0200 @@ -417,6 +417,12 @@ case "timeZoneNames": pushContainer(qName, attributes); break; + case "hourFormat": + pushStringEntry(qName, attributes, "timezone.hourFormat"); + break; + case "gmtFormat": + pushStringEntry(qName, attributes, "timezone.gmtFormat"); + break; case "zone": { String tzid = attributes.getValue("type"); // Olson tz id diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/java.base/share/classes/com/sun/security/ntlm/NTLM.java --- a/jdk/src/java.base/share/classes/com/sun/security/ntlm/NTLM.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/java.base/share/classes/com/sun/security/ntlm/NTLM.java Wed Jul 05 21:58:29 2017 +0200 @@ -169,7 +169,7 @@ byte[] readSecurityBuffer(int offset) throws NTLMException { int pos = readInt(offset+4); - if (pos == 0) return null; + if (pos == 0) return new byte[0]; try { return Arrays.copyOfRange( internal, pos, pos + readShort(offset)); diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/java.base/share/classes/java/lang/Math.java --- a/jdk/src/java.base/share/classes/java/lang/Math.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/java.base/share/classes/java/lang/Math.java Wed Jul 05 21:58:29 2017 +0200 @@ -1613,6 +1613,8 @@ * @return (a × b + c) * computed, as if with unlimited range and precision, and rounded * once to the nearest {@code double} value + * + * @since 9 */ // @HotSpotIntrinsicCandidate public static double fma(double a, double b, double c) { @@ -1728,6 +1730,8 @@ * @return (a × b + c) * computed, as if with unlimited range and precision, and rounded * once to the nearest {@code float} value + * + * @since 9 */ // @HotSpotIntrinsicCandidate public static float fma(float a, float b, float c) { diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/java.base/share/classes/java/lang/StrictMath.java --- a/jdk/src/java.base/share/classes/java/lang/StrictMath.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/java.base/share/classes/java/lang/StrictMath.java Wed Jul 05 21:58:29 2017 +0200 @@ -1276,6 +1276,8 @@ * @return (a × b + c) * computed, as if with unlimited range and precision, and rounded * once to the nearest {@code double} value + * + * @since 9 */ public static double fma(double a, double b, double c) { return Math.fma(a, b, c); @@ -1328,6 +1330,8 @@ * @return (a × b + c) * computed, as if with unlimited range and precision, and rounded * once to the nearest {@code float} value + * + * @since 9 */ public static float fma(float a, float b, float c) { return Math.fma(a, b, c); diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/java.base/share/classes/java/lang/VersionProps.java.template --- a/jdk/src/java.base/share/classes/java/lang/VersionProps.java.template Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/java.base/share/classes/java/lang/VersionProps.java.template Wed Jul 05 21:58:29 2017 +0200 @@ -67,19 +67,35 @@ System.setProperty("java.runtime.name", java_runtime_name); } - static List versionNumbers() { - List versionNumbers = new ArrayList<>(4); + private static int parseVersionNumber(String version, int prevIndex, int index) { + if (index - prevIndex > 1 && + Character.digit(version.charAt(prevIndex), 10) <= 0) + throw new IllegalArgumentException("Leading zeros not supported (" + + version.substring(prevIndex, index) + ")"); + return Integer.parseInt(version, prevIndex, index, 10); + } + + // This method is reflectively used by regression tests. + static List parseVersionNumbers(String version) { + List verNumbers = new ArrayList<>(4); int prevIndex = 0; - int index = VERSION_NUMBER.indexOf('.'); + int index = version.indexOf('.'); while (index > 0) { - versionNumbers.add( - Integer.parseInt(VERSION_NUMBER, prevIndex, index, 10)); + verNumbers.add(parseVersionNumber(version, prevIndex, index)); prevIndex = index + 1; // Skip the period - index = VERSION_NUMBER.indexOf('.', prevIndex); + index = version.indexOf('.', prevIndex); } - versionNumbers.add(Integer.parseInt(VERSION_NUMBER, - prevIndex, VERSION_NUMBER.length(), 10)); - return versionNumbers; + verNumbers.add(parseVersionNumber(version, prevIndex, version.length())); + + if (verNumbers.get(0) == 0 || verNumbers.get(verNumbers.size() - 1) == 0) + throw new IllegalArgumentException("Leading/trailing zeros not supported (" + + verNumbers + ")"); + + return verNumbers; + } + + static List versionNumbers() { + return parseVersionNumbers(VERSION_NUMBER); } static Optional pre() { diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/java.base/share/classes/java/lang/module/ModulePath.java --- a/jdk/src/java.base/share/classes/java/lang/module/ModulePath.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/java.base/share/classes/java/lang/module/ModulePath.java Wed Jul 05 21:58:29 2017 +0200 @@ -523,7 +523,7 @@ try (JarFile jf = new JarFile(file.toFile(), true, // verify ZipFile.OPEN_READ, - JarFile.Release.RUNTIME)) + JarFile.runtimeVersion())) { ModuleDescriptor md; JarEntry entry = jf.getJarEntry(MODULE_INFO); diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/java.base/share/classes/java/lang/module/ModuleReferences.java --- a/jdk/src/java.base/share/classes/java/lang/module/ModuleReferences.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/java.base/share/classes/java/lang/module/ModuleReferences.java Wed Jul 05 21:58:29 2017 +0200 @@ -201,7 +201,7 @@ return new JarFile(path.toFile(), true, // verify ZipFile.OPEN_READ, - JarFile.Release.RUNTIME); + JarFile.runtimeVersion()); } catch (IOException ioe) { throw new UncheckedIOException(ioe); } diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/java.base/share/classes/java/lang/module/package-info.java --- a/jdk/src/java.base/share/classes/java/lang/module/package-info.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/java.base/share/classes/java/lang/module/package-info.java Wed Jul 05 21:58:29 2017 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2016 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/java.base/share/classes/java/net/URLClassLoader.java --- a/jdk/src/java.base/share/classes/java/net/URLClassLoader.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/java.base/share/classes/java/net/URLClassLoader.java Wed Jul 05 21:58:29 2017 +0200 @@ -59,9 +59,11 @@ /** * This class loader is used to load classes and resources from a search - * path of URLs referring to both JAR files and directories. Any URL that - * ends with a '/' is assumed to refer to a directory. Otherwise, the URL - * is assumed to refer to a JAR file which will be opened as needed. + * path of URLs referring to both JAR files and directories. Any {@code jar:} + * scheme URL (see {@link java.net.JarURLConnection}) is assumed to refer to a + * JAR file. Any {@code file:} scheme URL that ends with a '/' is assumed to + * refer to a directory. Otherwise, the URL is assumed to refer to a JAR file + * which will be opened as needed. *

* The AccessControlContext of the thread that created the instance of * URLClassLoader will be used when subsequently loading classes and @@ -83,9 +85,11 @@ /** * Constructs a new URLClassLoader for the given URLs. The URLs will be * searched in the order specified for classes and resources after first - * searching in the specified parent class loader. Any URL that ends with - * a '/' is assumed to refer to a directory. Otherwise, the URL is assumed - * to refer to a JAR file which will be downloaded and opened as needed. + * searching in the specified parent class loader. Any {@code jar:} + * scheme URL is assumed to refer to a JAR file. Any {@code file:} scheme + * URL that ends with a '/' is assumed to refer to a directory. Otherwise, + * the URL is assumed to refer to a JAR file which will be downloaded and + * opened as needed. * *

If there is a security manager, this method first * calls the security manager's {@code checkCreateClassLoader} method diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/java.base/share/classes/java/nio/file/Files.java --- a/jdk/src/java.base/share/classes/java/nio/file/Files.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/java.base/share/classes/java/nio/file/Files.java Wed Jul 05 21:58:29 2017 +0200 @@ -3290,8 +3290,8 @@ * a size of {@code 0}. All bytes in the byte array are written to the file. * The method ensures that the file is closed when all bytes have been * written (or an I/O error or other runtime exception is thrown). If an I/O - * error occurs then it may do so after the file has created or truncated, - * or after some bytes have been written to the file. + * error occurs then it may do so after the file has been created or + * truncated, or after some bytes have been written to the file. * *

Usage example: By default the method creates a new file or * overwrites an existing file. Suppose you instead want to append bytes @@ -3360,7 +3360,8 @@ * a size of {@code 0}. The method ensures that the file is closed when all * lines have been written (or an I/O error or other runtime exception is * thrown). If an I/O error occurs then it may do so after the file has - * created or truncated, or after some bytes have been written to the file. + * been created or truncated, or after some bytes have been written to the + * file. * * @param path * the path to the file diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/java.base/share/classes/java/security/MessageDigest.java --- a/jdk/src/java.base/share/classes/java/security/MessageDigest.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/java.base/share/classes/java/security/MessageDigest.java Wed Jul 05 21:58:29 2017 +0200 @@ -439,7 +439,12 @@ } /** - * Compares two digests for equality. Does a simple byte compare. + * Compares two digests for equality. Two digests are equal if they have + * the same length and all bytes at corresponding positions are equal. + * + * @implNote + * If the digests are the same length, all bytes are examined to + * determine equality. * * @param digesta one of the digests to compare. * diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/java.base/share/classes/java/util/jar/JarFile.java --- a/jdk/src/java.base/share/classes/java/util/jar/JarFile.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/java.base/share/classes/java/util/jar/JarFile.java Wed Jul 05 21:58:29 2017 +0200 @@ -64,8 +64,8 @@ * file, and as such an entry name is associated with at most one base entry. * The {@code JarFile} may be configured to process a multi-release jar file by * creating the {@code JarFile} with the - * {@link JarFile#JarFile(File, boolean, int, Release)} constructor. The - * {@code Release} object sets a maximum version used when searching for + * {@link JarFile#JarFile(File, boolean, int, Runtime.Version)} constructor. The + * {@code Runtime.Version} object sets a maximum version used when searching for * versioned entries. When so configured, an entry name * can correspond with at most one base entry and zero or more versioned * entries. A search is required to associate the entry name with the latest @@ -74,8 +74,8 @@ * *

Class loaders that utilize {@code JarFile} to load classes from the * contents of {@code JarFile} entries should construct the {@code JarFile} - * by invoking the {@link JarFile#JarFile(File, boolean, int, Release)} - * constructor with the value {@code Release.RUNTIME} assigned to the last + * by invoking the {@link JarFile#JarFile(File, boolean, int, Runtime.Version)} + * constructor with the value {@code Runtime.version()} assigned to the last * argument. This assures that classes compatible with the major * version of the running JVM are loaded from multi-release jar files. * @@ -99,12 +99,12 @@ *

  • * {@code jdk.util.jar.version} can be assigned a value that is the * {@code String} representation of a non-negative integer - * {@code <= Version.current().major()}. The value is used to set the effective + * {@code <= Runtime.version().major()}. The value is used to set the effective * runtime version to something other than the default value obtained by - * evaluating {@code Version.current().major()}. The effective runtime version - * is the version that the {@link JarFile#JarFile(File, boolean, int, Release)} + * evaluating {@code Runtime.version().major()}. The effective runtime version + * is the version that the {@link JarFile#JarFile(File, boolean, int, Runtime.Version)} * constructor uses when the value of the last argument is - * {@code Release.RUNTIME}. + * {@code JarFile.runtimeVersion()}. *
  • *
  • * {@code jdk.util.jar.enableMultiRelease} can be assigned one of the three @@ -116,7 +116,7 @@ * the method {@link JarFile#isMultiRelease()} returns false. The value * force causes the {@code JarFile} to be initialized to runtime * versioning after construction. It effectively does the same as this code: - * {@code (new JarFile(File, boolean, int, Release.RUNTIME)}. + * {@code (new JarFile(File, boolean, int, JarFile.runtimeVersion())}. *
  • * * @@ -129,8 +129,9 @@ */ public class JarFile extends ZipFile { - private final static int BASE_VERSION; - private final static int RUNTIME_VERSION; + private final static Runtime.Version BASE_VERSION; + private final static int BASE_VERSION_MAJOR; + private final static Runtime.Version RUNTIME_VERSION; private final static boolean MULTI_RELEASE_ENABLED; private final static boolean MULTI_RELEASE_FORCED; private SoftReference manRef; @@ -138,10 +139,10 @@ private JarVerifier jv; private boolean jvInitialized; private boolean verify; - private final int version; - private boolean notVersioned; - private final boolean runtimeVersioned; - private boolean isMultiRelease; // is jar multi-release? + private final Runtime.Version version; // current version + private final int versionMajor; // version.major() + private boolean notVersioned; // legacy constructor called + private boolean isMultiRelease; // is jar multi-release? // indicates if Class-Path attribute present private boolean hasClassPathAttribute; @@ -151,17 +152,18 @@ static { // Set up JavaUtilJarAccess in SharedSecrets SharedSecrets.setJavaUtilJarAccess(new JavaUtilJarAccessImpl()); - - BASE_VERSION = 8; // one less than lowest version for versioned entries + // multi-release jar file versions >= 9 + BASE_VERSION = Runtime.Version.parse(Integer.toString(8)); + BASE_VERSION_MAJOR = BASE_VERSION.major(); + String jarVersion = GetPropertyAction.privilegedGetProperty("jdk.util.jar.version"); int runtimeVersion = Runtime.version().major(); - String jarVersion = - GetPropertyAction.privilegedGetProperty("jdk.util.jar.version"); if (jarVersion != null) { int jarVer = Integer.parseInt(jarVersion); runtimeVersion = (jarVer > runtimeVersion) - ? runtimeVersion : Math.max(jarVer, 0); + ? runtimeVersion + : Math.max(jarVer, BASE_VERSION_MAJOR); } - RUNTIME_VERSION = runtimeVersion; + RUNTIME_VERSION = Runtime.Version.parse(Integer.toString(runtimeVersion)); String enableMultiRelease = GetPropertyAction .privilegedGetProperty("jdk.util.jar.enableMultiRelease", "true"); switch (enableMultiRelease) { @@ -181,61 +183,6 @@ } } - /** - * A set of constants that represent the entries in either the base directory - * or one of the versioned directories in a multi-release jar file. It's - * possible for a multi-release jar file to contain versioned directories - * that are not represented by the constants of the {@code Release} enum. - * In those cases, the entries will not be located by this {@code JarFile} - * through the aliasing mechanism, but they can be directly accessed by - * specifying the full path name of the entry. - * - * @since 9 - */ - public enum Release { - /** - * Represents unversioned entries, or entries in "regular", as opposed - * to multi-release jar files. - */ - BASE(BASE_VERSION), - - /** - * Represents entries found in the META-INF/versions/9 directory of a - * multi-release jar file. - */ - VERSION_9(9), - - // fill in the "blanks" for future releases - - /** - * Represents entries found in the META-INF/versions/{n} directory of a - * multi-release jar file, where {@code n} is the effective runtime - * version of the jar file. - * - * @implNote - *
    - * The effective runtime version is determined - * by evaluating {@code Version.current().major()} or by using the value - * of the {@code jdk.util.jar.version} System property if it exists. - *
    - */ - RUNTIME(RUNTIME_VERSION); - - Release(int version) { - this.version = version; - } - - private static Release valueOf(int version) { - return version <= BASE.value() ? BASE : valueOf("VERSION_" + version); - } - - private final int version; - - private int value() { - return this.version; - } - } - private static final String META_INF = "META-INF/"; private static final String META_INF_VERSIONS = META_INF + "versions/"; @@ -246,6 +193,32 @@ public static final String MANIFEST_NAME = META_INF + "MANIFEST.MF"; /** + * The version that represents the unversioned configuration of a multi-release jar file. + * + * @return Runtime.Version that represents the unversioned configuration + * + * @since 9 + */ + public static Runtime.Version baseVersion() { + return BASE_VERSION; + } + + /** + * The version that represents the effective runtime versioned configuration of a + * multi-release jar file. In most cases, {@code runtimeVersion()} is equal to + * {@code Runtime.version()}. However, if the {@code jdk.util.jar.version} property is set, + * {@code runtimeVersion()} is derived from that property and may not be equal to + * {@code Runtime.version()}. + * + * @return Runtime.Version that represents the runtime versioned configuration + * + * @since 9 + */ + public static Runtime.Version runtimeVersion() { + return RUNTIME_VERSION; + } + + /** * Creates a new {@code JarFile} to read from the specified * file {@code name}. The {@code JarFile} will be verified if * it is signed. @@ -316,7 +289,7 @@ * @since 1.3 */ public JarFile(File file, boolean verify, int mode) throws IOException { - this(file, verify, mode, Release.BASE); + this(file, verify, mode, BASE_VERSION); this.notVersioned = true; } @@ -324,8 +297,13 @@ * Creates a new {@code JarFile} to read from the specified * {@code File} object in the specified mode. The mode argument * must be either {@code OPEN_READ} or {@code OPEN_READ | OPEN_DELETE}. - * The version argument configures the {@code JarFile} for processing + * The version argument, after being converted to a canonical form, is + * used to configure the {@code JarFile} for processing * multi-release jar files. + *

    + * The canonical form derived from the version parameter is + * {@code Runtime.Version.parse(Integer.toString(n))} where {@code n} is + * {@code Math.max(version.major(), JarFile.baseVersion().major())}. * * @param file the jar file to be opened for reading * @param verify whether or not to verify the jar file if @@ -340,47 +318,31 @@ * @throws NullPointerException if {@code version} is {@code null} * @since 9 */ - public JarFile(File file, boolean verify, int mode, Release version) throws IOException { + public JarFile(File file, boolean verify, int mode, Runtime.Version version) throws IOException { super(file, mode); - Objects.requireNonNull(version); this.verify = verify; - // version applies to multi-release jar files, ignored for regular jar files - if (MULTI_RELEASE_FORCED) { + Objects.requireNonNull(version); + if (MULTI_RELEASE_FORCED || version.major() == RUNTIME_VERSION.major()) { + // This deals with the common case where the value from JarFile.runtimeVersion() is passed this.version = RUNTIME_VERSION; - version = Release.RUNTIME; + } else if (version.major() <= BASE_VERSION_MAJOR) { + // This also deals with the common case where the value from JarFile.baseVersion() is passed + this.version = BASE_VERSION; } else { - this.version = version.value(); + // Canonicalize + this.version = Runtime.Version.parse(Integer.toString(version.major())); } - this.runtimeVersioned = version == Release.RUNTIME; - - assert runtimeVersionExists(); - } - - private boolean runtimeVersionExists() { - int version = Runtime.version().major(); - try { - Release.valueOf(version); - return true; - } catch (IllegalArgumentException x) { - System.err.println("No JarFile.Release object for release " + version); - return false; - } + this.versionMajor = this.version.major(); } /** * Returns the maximum version used when searching for versioned entries. * - * @return the maximum version, or {@code Release.BASE} if this jar file is - * processed as if it is an unversioned jar file or is not a - * multi-release jar file + * @return the maximum version * @since 9 */ - public final Release getVersion() { - if (isMultiRelease()) { - return runtimeVersioned ? Release.RUNTIME : Release.valueOf(version); - } else { - return Release.BASE; - } + public final Runtime.Version getVersion() { + return isMultiRelease() ? this.version : BASE_VERSION; } /** @@ -393,7 +355,7 @@ if (isMultiRelease) { return true; } - if (MULTI_RELEASE_ENABLED && version != BASE_VERSION) { + if (MULTI_RELEASE_ENABLED && versionMajor != BASE_VERSION_MAJOR) { try { checkForSpecialAttributes(); } catch (IOException io) { @@ -639,7 +601,7 @@ ZipEntry vze = null; String sname = "/" + name; int i = version; - while (i > BASE_VERSION) { + while (i > BASE_VERSION_MAJOR) { vze = super.getEntry(META_INF_VERSIONS + i + sname); if (vze != null) break; i--; @@ -649,10 +611,10 @@ private ZipEntry getVersionedEntry(ZipEntry ze) { ZipEntry vze = null; - if (version > BASE_VERSION && !ze.isDirectory()) { + if (BASE_VERSION_MAJOR < versionMajor && !ze.isDirectory()) { String name = ze.getName(); if (!name.startsWith(META_INF)) { - vze = searchForVersionedEntry(version, name); + vze = searchForVersionedEntry(versionMajor, name); } } return vze == null ? ze : vze; @@ -1038,7 +1000,7 @@ hasClassPathAttribute = match(CLASSPATH_CHARS, b, CLASSPATH_LASTOCC) != -1; // is this a multi-release jar file - if (MULTI_RELEASE_ENABLED && version != BASE_VERSION) { + if (MULTI_RELEASE_ENABLED && versionMajor != BASE_VERSION_MAJOR) { int i = match(MULTIRELEASE_CHARS, b, MULTIRELEASE_LASTOCC); if (i != -1) { i += MULTIRELEASE_CHARS.length; diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/java.base/share/classes/java/util/zip/InflaterInputStream.java --- a/jdk/src/java.base/share/classes/java/util/zip/InflaterInputStream.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/java.base/share/classes/java/util/zip/InflaterInputStream.java Wed Jul 05 21:58:29 2017 +0200 @@ -179,6 +179,10 @@ ensureOpen(); if (reachEOF) { return 0; + } else if (inf.finished()) { + // the end of the compressed data stream has been reached + reachEOF = true; + return 0; } else { return 1; } diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/java.base/share/classes/jdk/internal/loader/URLClassPath.java --- a/jdk/src/java.base/share/classes/jdk/internal/loader/URLClassPath.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/java.base/share/classes/jdk/internal/loader/URLClassPath.java Wed Jul 05 21:58:29 2017 +0200 @@ -695,7 +695,7 @@ throw new FileNotFoundException(p.getPath()); } return checkJar(new JarFile(new File(p.getPath()), true, ZipFile.OPEN_READ, - JarFile.Release.RUNTIME)); + JarFile.runtimeVersion())); } URLConnection uc = (new URL(getBaseURL(), "#runtime")).openConnection(); uc.setRequestProperty(USER_AGENT_JAVA_VERSION, JAVA_VERSION); diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/java.base/share/classes/sun/net/www/protocol/jar/URLJarFile.java --- a/jdk/src/java.base/share/classes/sun/net/www/protocol/jar/URLJarFile.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/java.base/share/classes/sun/net/www/protocol/jar/URLJarFile.java Wed Jul 05 21:58:29 2017 +0200 @@ -66,7 +66,9 @@ static JarFile getJarFile(URL url, URLJarFileCloseController closeController) throws IOException { if (isFileURL(url)) { - Release version = "runtime".equals(url.getRef()) ? Release.RUNTIME : Release.BASE; + Runtime.Version version = "runtime".equals(url.getRef()) + ? JarFile.runtimeVersion() + : JarFile.baseVersion(); return new URLJarFile(url, closeController, version); } else { return retrieve(url, closeController); @@ -90,12 +92,14 @@ this.closeController = closeController; } - private URLJarFile(File file, URLJarFileCloseController closeController, Release version) throws IOException { + private URLJarFile(File file, URLJarFileCloseController closeController, Runtime.Version version) + throws IOException { super(file, true, ZipFile.OPEN_READ | ZipFile.OPEN_DELETE, version); this.closeController = closeController; } - private URLJarFile(URL url, URLJarFileCloseController closeController, Release version) throws IOException { + private URLJarFile(URL url, URLJarFileCloseController closeController, Runtime.Version version) + throws IOException { super(new File(ParseUtil.decode(url.getFile())), true, ZipFile.OPEN_READ, version); this.closeController = closeController; } @@ -200,7 +204,9 @@ { JarFile result = null; - Release version = "runtime".equals(url.getRef()) ? Release.RUNTIME : Release.BASE; + Runtime.Version version = "runtime".equals(url.getRef()) + ? JarFile.runtimeVersion() + : JarFile.baseVersion(); /* get the stream before asserting privileges */ try (final InputStream in = url.openConnection().getInputStream()) { diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/java.base/share/classes/sun/security/tools/KeyStoreUtil.java --- a/jdk/src/java.base/share/classes/sun/security/tools/KeyStoreUtil.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/java.base/share/classes/sun/security/tools/KeyStoreUtil.java Wed Jul 05 21:58:29 2017 +0200 @@ -38,6 +38,8 @@ import java.security.KeyStore; +import java.security.Provider; +import java.security.Security; import java.security.cert.X509Certificate; import java.text.Collator; @@ -46,6 +48,7 @@ import java.util.List; import java.util.Locale; import java.util.Properties; +import java.util.ServiceLoader; import sun.security.util.PropertyExpander; @@ -209,6 +212,7 @@ /** * Prepends matched options from a pre-configured options file. + * * @param tool the name of the tool, can be "keytool" or "jarsigner" * @param file the pre-configured options file * @param c1 the name of the command, with the "-" prefix, @@ -259,4 +263,68 @@ return result.toArray(new String[result.size()]); } } + + /** + * Loads a security provider as a service. + * + * @param provName the name + * @param arg optional arg + * @throws IllegalArgumentException if no provider matches the name + */ + public static void loadProviderByName(String provName, String arg) { + Provider loaded = Security.getProvider(provName); + if (loaded != null) { + if (arg != null) { + loaded = loaded.configure(arg); + Security.addProvider(loaded); + } + return; + } + for (Provider p : ServiceLoader.load(Provider.class, + ClassLoader.getSystemClassLoader())) { + if (p.getName().equals(provName)) { + if (arg != null) { + p = p.configure(arg); + } + Security.addProvider(p); + return; + } + } + throw new IllegalArgumentException("No provider found"); + } + + /** + * Loads a security provider by a fully-qualified class name. + * + * @param provClass the class name + * @param arg optional arg + * @param cl optional class loader + * @throws IllegalArgumentException if no provider matches the class name + * @throws ClassCastException if the class has not extended Provider + */ + public static void loadProviderByClass( + String provClass, String arg, ClassLoader cl) { + + // For compatibility, SunPKCS11 and OracleUcrypto can still be + // loadable with -providerClass. + if (provClass.equals("sun.security.pkcs11.SunPKCS11")) { + loadProviderByName("SunPKCS11", arg); + return; + } else if (provClass.equals("com.oracle.security.crypto.UcryptoProvider")) { + loadProviderByName("OracleUcrypto", arg); + return; + } + + Provider prov; + try { + Class clazz = Class.forName(provClass, false, cl); + prov = (Provider) clazz.getConstructor().newInstance(); + } catch (ReflectiveOperationException e) { + throw new IllegalArgumentException(e); + } + if (arg != null) { + prov = prov.configure(arg); + } + Security.addProvider(prov); + } } diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java --- a/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java Wed Jul 05 21:58:29 2017 +0200 @@ -33,13 +33,11 @@ import java.security.Key; import java.security.PublicKey; import java.security.PrivateKey; -import java.security.Security; import java.security.Signature; import java.security.Timestamp; import java.security.UnrecoverableEntryException; import java.security.UnrecoverableKeyException; import java.security.Principal; -import java.security.Provider; import java.security.cert.Certificate; import java.security.cert.CertificateFactory; import java.security.cert.CertStoreException; @@ -128,6 +126,7 @@ // them through the command line. private Set> providers = null; + private Set> providerClasses = null; private String storetype = null; private boolean hasStoretypeOption = false; private String srcProviderName = null; @@ -166,57 +165,57 @@ enum Command { CERTREQ("Generates.a.certificate.request", ALIAS, SIGALG, FILEOUT, KEYPASS, KEYSTORE, DNAME, - STOREPASS, STORETYPE, PROVIDERNAME, PROVIDERCLASS, - PROVIDERARG, PROVIDERPATH, V, PROTECTED), + STOREPASS, STORETYPE, PROVIDERNAME, ADDPROVIDER, + PROVIDERCLASS, PROVIDERPATH, V, PROTECTED), CHANGEALIAS("Changes.an.entry.s.alias", ALIAS, DESTALIAS, KEYPASS, KEYSTORE, STOREPASS, - STORETYPE, PROVIDERNAME, PROVIDERCLASS, PROVIDERARG, + STORETYPE, PROVIDERNAME, ADDPROVIDER, PROVIDERCLASS, PROVIDERPATH, V, PROTECTED), DELETE("Deletes.an.entry", ALIAS, KEYSTORE, STOREPASS, STORETYPE, - PROVIDERNAME, PROVIDERCLASS, PROVIDERARG, + PROVIDERNAME, ADDPROVIDER, PROVIDERCLASS, PROVIDERPATH, V, PROTECTED), EXPORTCERT("Exports.certificate", RFC, ALIAS, FILEOUT, KEYSTORE, STOREPASS, - STORETYPE, PROVIDERNAME, PROVIDERCLASS, PROVIDERARG, + STORETYPE, PROVIDERNAME, ADDPROVIDER, PROVIDERCLASS, PROVIDERPATH, V, PROTECTED), GENKEYPAIR("Generates.a.key.pair", ALIAS, KEYALG, KEYSIZE, SIGALG, DESTALIAS, DNAME, STARTDATE, EXT, VALIDITY, KEYPASS, KEYSTORE, - STOREPASS, STORETYPE, PROVIDERNAME, PROVIDERCLASS, - PROVIDERARG, PROVIDERPATH, V, PROTECTED), + STOREPASS, STORETYPE, PROVIDERNAME, ADDPROVIDER, + PROVIDERCLASS, PROVIDERPATH, V, PROTECTED), GENSECKEY("Generates.a.secret.key", ALIAS, KEYPASS, KEYALG, KEYSIZE, KEYSTORE, - STOREPASS, STORETYPE, PROVIDERNAME, PROVIDERCLASS, - PROVIDERARG, PROVIDERPATH, V, PROTECTED), + STOREPASS, STORETYPE, PROVIDERNAME, ADDPROVIDER, + PROVIDERCLASS, PROVIDERPATH, V, PROTECTED), GENCERT("Generates.certificate.from.a.certificate.request", RFC, INFILE, OUTFILE, ALIAS, SIGALG, DNAME, STARTDATE, EXT, VALIDITY, KEYPASS, KEYSTORE, - STOREPASS, STORETYPE, PROVIDERNAME, PROVIDERCLASS, - PROVIDERARG, PROVIDERPATH, V, PROTECTED), + STOREPASS, STORETYPE, PROVIDERNAME, ADDPROVIDER, + PROVIDERCLASS, PROVIDERPATH, V, PROTECTED), IMPORTCERT("Imports.a.certificate.or.a.certificate.chain", NOPROMPT, TRUSTCACERTS, PROTECTED, ALIAS, FILEIN, KEYPASS, KEYSTORE, STOREPASS, STORETYPE, - PROVIDERNAME, PROVIDERCLASS, PROVIDERARG, + PROVIDERNAME, ADDPROVIDER, PROVIDERCLASS, PROVIDERPATH, V), IMPORTPASS("Imports.a.password", ALIAS, KEYPASS, KEYALG, KEYSIZE, KEYSTORE, - STOREPASS, STORETYPE, PROVIDERNAME, PROVIDERCLASS, - PROVIDERARG, PROVIDERPATH, V, PROTECTED), + STOREPASS, STORETYPE, PROVIDERNAME, ADDPROVIDER, + PROVIDERCLASS, PROVIDERPATH, V, PROTECTED), IMPORTKEYSTORE("Imports.one.or.all.entries.from.another.keystore", SRCKEYSTORE, DESTKEYSTORE, SRCSTORETYPE, DESTSTORETYPE, SRCSTOREPASS, DESTSTOREPASS, SRCPROTECTED, DESTPROTECTED, SRCPROVIDERNAME, DESTPROVIDERNAME, SRCALIAS, DESTALIAS, SRCKEYPASS, DESTKEYPASS, - NOPROMPT, PROVIDERCLASS, PROVIDERARG, PROVIDERPATH, + NOPROMPT, ADDPROVIDER, PROVIDERCLASS, PROVIDERPATH, V), KEYPASSWD("Changes.the.key.password.of.an.entry", ALIAS, KEYPASS, NEW, KEYSTORE, STOREPASS, - STORETYPE, PROVIDERNAME, PROVIDERCLASS, PROVIDERARG, + STORETYPE, PROVIDERNAME, ADDPROVIDER, PROVIDERCLASS, PROVIDERPATH, V), LIST("Lists.entries.in.a.keystore", RFC, ALIAS, KEYSTORE, STOREPASS, STORETYPE, - PROVIDERNAME, PROVIDERCLASS, PROVIDERARG, + PROVIDERNAME, ADDPROVIDER, PROVIDERCLASS, PROVIDERPATH, V, PROTECTED), PRINTCERT("Prints.the.content.of.a.certificate", RFC, FILEIN, SSLSERVER, JARFILE, V), @@ -226,26 +225,26 @@ FILEIN, V), STOREPASSWD("Changes.the.store.password.of.a.keystore", NEW, KEYSTORE, STOREPASS, STORETYPE, PROVIDERNAME, - PROVIDERCLASS, PROVIDERARG, PROVIDERPATH, V), + ADDPROVIDER, PROVIDERCLASS, PROVIDERPATH, V), // Undocumented start here, KEYCLONE is used a marker in -help; KEYCLONE("Clones.a.key.entry", ALIAS, DESTALIAS, KEYPASS, NEW, STORETYPE, - KEYSTORE, STOREPASS, PROVIDERNAME, PROVIDERCLASS, - PROVIDERARG, PROVIDERPATH, V), + KEYSTORE, STOREPASS, PROVIDERNAME, ADDPROVIDER, + PROVIDERCLASS, PROVIDERPATH, V), SELFCERT("Generates.a.self.signed.certificate", ALIAS, SIGALG, DNAME, STARTDATE, VALIDITY, KEYPASS, STORETYPE, KEYSTORE, STOREPASS, PROVIDERNAME, - PROVIDERCLASS, PROVIDERARG, PROVIDERPATH, V), + ADDPROVIDER, PROVIDERCLASS, PROVIDERPATH, V), GENCRL("Generates.CRL", RFC, FILEOUT, ID, ALIAS, SIGALG, EXT, KEYPASS, KEYSTORE, - STOREPASS, STORETYPE, PROVIDERNAME, PROVIDERCLASS, - PROVIDERARG, PROVIDERPATH, V, PROTECTED), + STOREPASS, STORETYPE, PROVIDERNAME, ADDPROVIDER, + PROVIDERCLASS, PROVIDERPATH, V, PROTECTED), IDENTITYDB("Imports.entries.from.a.JDK.1.1.x.style.identity.database", FILEIN, STORETYPE, KEYSTORE, STOREPASS, PROVIDERNAME, - PROVIDERCLASS, PROVIDERARG, PROVIDERPATH, V); + ADDPROVIDER, PROVIDERCLASS, PROVIDERPATH, V); final String description; final Option[] options; @@ -289,48 +288,48 @@ enum Option { ALIAS("alias", "", "alias.name.of.the.entry.to.process"), - DESTALIAS("destalias", "", "destination.alias"), + DESTALIAS("destalias", "", "destination.alias"), DESTKEYPASS("destkeypass", "", "destination.key.password"), - DESTKEYSTORE("destkeystore", "", "destination.keystore.name"), + DESTKEYSTORE("destkeystore", "", "destination.keystore.name"), DESTPROTECTED("destprotected", null, "destination.keystore.password.protected"), - DESTPROVIDERNAME("destprovidername", "", "destination.keystore.provider.name"), + DESTPROVIDERNAME("destprovidername", "", "destination.keystore.provider.name"), DESTSTOREPASS("deststorepass", "", "destination.keystore.password"), - DESTSTORETYPE("deststoretype", "", "destination.keystore.type"), - DNAME("dname", "", "distinguished.name"), + DESTSTORETYPE("deststoretype", "", "destination.keystore.type"), + DNAME("dname", "", "distinguished.name"), EXT("ext", "", "X.509.extension"), - FILEOUT("file", "", "output.file.name"), - FILEIN("file", "", "input.file.name"), + FILEOUT("file", "", "output.file.name"), + FILEIN("file", "", "input.file.name"), ID("id", "", "Serial.ID.of.cert.to.revoke"), - INFILE("infile", "", "input.file.name"), - KEYALG("keyalg", "", "key.algorithm.name"), + INFILE("infile", "", "input.file.name"), + KEYALG("keyalg", "", "key.algorithm.name"), KEYPASS("keypass", "", "key.password"), - KEYSIZE("keysize", "", "key.bit.size"), + KEYSIZE("keysize", "", "key.bit.size"), KEYSTORE("keystore", "", "keystore.name"), NEW("new", "", "new.password"), NOPROMPT("noprompt", null, "do.not.prompt"), - OUTFILE("outfile", "", "output.file.name"), + OUTFILE("outfile", "", "output.file.name"), PROTECTED("protected", null, "password.through.protected.mechanism"), - PROVIDERARG("providerarg", "", "provider.argument"), - PROVIDERCLASS("providerclass", "", "provider.class.name"), - PROVIDERNAME("providername", "", "provider.name"), - PROVIDERPATH("providerpath", "", "provider.classpath"), + PROVIDERCLASS("providerclass", "\n[-providerarg ]", "provider.class.option"), + ADDPROVIDER("addprovider", "\n[-providerarg ]", "addprovider.option"), + PROVIDERNAME("providername", "", "provider.name"), + PROVIDERPATH("providerpath", "", "provider.classpath"), RFC("rfc", null, "output.in.RFC.style"), - SIGALG("sigalg", "", "signature.algorithm.name"), - SRCALIAS("srcalias", "", "source.alias"), + SIGALG("sigalg", "", "signature.algorithm.name"), + SRCALIAS("srcalias", "", "source.alias"), SRCKEYPASS("srckeypass", "", "source.key.password"), - SRCKEYSTORE("srckeystore", "", "source.keystore.name"), + SRCKEYSTORE("srckeystore", "", "source.keystore.name"), SRCPROTECTED("srcprotected", null, "source.keystore.password.protected"), - SRCPROVIDERNAME("srcprovidername", "", "source.keystore.provider.name"), + SRCPROVIDERNAME("srcprovidername", "", "source.keystore.provider.name"), SRCSTOREPASS("srcstorepass", "", "source.keystore.password"), - SRCSTORETYPE("srcstoretype", "", "source.keystore.type"), + SRCSTORETYPE("srcstoretype", "", "source.keystore.type"), SSLSERVER("sslserver", "", "SSL.server.host.and.port"), - JARFILE("jarfile", "", "signed.jar.file"), - STARTDATE("startdate", "", "certificate.validity.start.date.time"), + JARFILE("jarfile", "", "signed.jar.file"), + STARTDATE("startdate", "", "certificate.validity.start.date.time"), STOREPASS("storepass", "", "keystore.password"), - STORETYPE("storetype", "", "keystore.type"), + STORETYPE("storetype", "", "keystore.type"), TRUSTCACERTS("trustcacerts", null, "trust.certificates.from.cacerts"), V("v", null, "verbose.output"), - VALIDITY("validity", "", "validity.number.of.days"); + VALIDITY("validity", "", "validity.number.of.days"); final String name, arg, description; Option(String name, String arg, String description) { @@ -344,8 +343,6 @@ } }; - private static final Class[] PARAM_STRING = { String.class }; - private static final String NONE = "NONE"; private static final String P11KEYSTORE = "PKCS11"; private static final String P12KEYSTORE = "PKCS12"; @@ -549,10 +546,10 @@ jarfile = args[++i]; } else if (collator.compare(flags, "-srckeystore") == 0) { srcksfname = args[++i]; - } else if ((collator.compare(flags, "-provider") == 0) || - (collator.compare(flags, "-providerclass") == 0)) { - if (providers == null) { - providers = new HashSet> (3); + } else if (collator.compare(flags, "-provider") == 0 || + collator.compare(flags, "-providerclass") == 0) { + if (providerClasses == null) { + providerClasses = new HashSet> (3); } String providerClass = args[++i]; String providerArg = null; @@ -565,8 +562,25 @@ i += 2; } } + providerClasses.add( + Pair.of(providerClass, providerArg)); + } else if (collator.compare(flags, "-addprovider") == 0) { + if (providers == null) { + providers = new HashSet> (3); + } + String provider = args[++i]; + String providerArg = null; + + if (args.length > (i+1)) { + flags = args[i+1]; + if (collator.compare(flags, "-providerarg") == 0) { + if (args.length == (i+2)) errorNeedArgument(flags); + providerArg = args[i+2]; + i += 2; + } + } providers.add( - Pair.of(providerClass, providerArg)); + Pair.of(provider, providerArg)); } /* @@ -617,7 +631,6 @@ return cmd != PRINTCERT && cmd != PRINTCERTREQ; } - /** * Execute the commands. */ @@ -703,6 +716,20 @@ // Try to load and install specified provider if (providers != null) { + for (Pair provider : providers) { + try { + KeyStoreUtil.loadProviderByName( + provider.fst, provider.snd); + if (debug) { + System.out.println("loadProviderByName: " + provider.fst); + } + } catch (IllegalArgumentException e) { + throw new Exception(String.format(rb.getString( + "provider.name.not.found"), provider.fst)); + } + } + } + if (providerClasses != null) { ClassLoader cl = null; if (pathlist != null) { String path = null; @@ -717,30 +744,20 @@ } else { cl = ClassLoader.getSystemClassLoader(); } - - for (Pair provider: providers) { - String provName = provider.fst; - Class provClass; - if (cl != null) { - provClass = cl.loadClass(provName); - } else { - provClass = Class.forName(provName); + for (Pair provider : providerClasses) { + try { + KeyStoreUtil.loadProviderByClass( + provider.fst, provider.snd, cl); + if (debug) { + System.out.println("loadProviderByClass: " + provider.fst); + } + } catch (ClassCastException cce) { + throw new Exception(String.format(rb.getString( + "provclass.not.a.provider"), provider.fst)); + } catch (IllegalArgumentException e) { + throw new Exception(String.format(rb.getString( + "provider.class.not.found"), provider.fst), e.getCause()); } - - @SuppressWarnings("deprecation") - Object obj = provClass.newInstance(); - if (!(obj instanceof Provider)) { - MessageFormat form = new MessageFormat - (rb.getString("provName.not.a.provider")); - Object[] source = {provName}; - throw new Exception(form.format(source)); - } - Provider p = (Provider) obj; - String provArg = provider.snd; - if (provArg != null) { - p = p.configure(provArg); - } - Security.addProvider(p); } } @@ -4132,27 +4149,40 @@ System.err.println(rb.getString("Options.")); System.err.println(); - // Left and right sides of the options list + // Left and right sides of the options list. Both might + // contain "\n" and span multiple lines String[] left = new String[command.options.length]; String[] right = new String[command.options.length]; - // Check if there's an unknown option - boolean found = false; - // Length of left side of options list int lenLeft = 0; - for (int j=0; j lenLeft) { - lenLeft = left[j].length(); + if (opt.arg != null) { + left[j] += " " + opt.arg; + } + String[] lefts = left[j].split("\n"); + for (String s : lefts) { + if (s.length() > lenLeft) { + lenLeft = s.length(); + } } right[j] = rb.getString(opt.description); } - for (int j=0; j>", "read"; }; grant codeBase "jrt:/java.sql" { diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/java.base/share/native/libjli/args.c --- a/jdk/src/java.base/share/native/libjli/args.c Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/java.base/share/native/libjli/args.c Wed Jul 05 21:58:29 2017 +0200 @@ -130,7 +130,7 @@ expectingNoDashArg = JNI_FALSE; } // only update on java mode and not yet found main class - if (firstAppArgIndex == -1 && idx != 0) { + if (firstAppArgIndex == NOT_FOUND && idx != 0) { firstAppArgIndex = (int) idx; } } diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/java.base/windows/native/libjli/java_md.c --- a/jdk/src/java.base/windows/native/libjli/java_md.c Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/java.base/windows/native/libjli/java_md.c Wed Jul 05 21:58:29 2017 +0200 @@ -943,26 +943,6 @@ return JNI_FALSE; } -int -filterArgs(StdArg *stdargs, const int nargc, StdArg **pargv) { - StdArg* argv = NULL; - int nargs = 0; - int i; - - /* Copy the non-vm args */ - for (i = 0; i < nargc ; i++) { - const char *arg = stdargs[i].arg; - if (arg[0] == '-' && arg[1] == 'J') - continue; - argv = (StdArg*) JLI_MemRealloc(argv, (nargs+1) * sizeof(StdArg)); - argv[nargs].arg = JLI_StringDup(arg); - argv[nargs].has_wildcard = stdargs[i].has_wildcard; - nargs++; - } - *pargv = argv; - return nargs; -} - /* * At this point we have the arguments to the application, and we need to * check with original stdargs in order to compare which of these truly @@ -975,12 +955,13 @@ int i, j, idx; size_t tlen; jobjectArray outArray, inArray; - char *ostart, *astart, **nargv; + char *arg, **nargv; jboolean needs_expansion = JNI_FALSE; jmethodID mid; - int filteredargc, stdargc; + int stdargc; StdArg *stdargs; - StdArg *filteredargs; + int *appArgIdx; + int isTool; jclass cls = GetLauncherHelperClass(env); NULL_CHECK0(cls); @@ -991,8 +972,6 @@ stdargs = JLI_GetStdArgs(); stdargc = JLI_GetStdArgc(); - filteredargc = filterArgs(stdargs, stdargc, &filteredargs); - // sanity check, this should never happen if (argc > stdargc) { JLI_TraceLauncher("Warning: app args is larger than the original, %d %d\n", argc, stdargc); @@ -1001,22 +980,35 @@ } // sanity check, match the args we have, to the holy grail - idx = filteredargc - argc; - ostart = filteredargs[idx].arg; - astart = strv[0]; - // sanity check, ensure that the first argument of the arrays are the same - if (JLI_StrCmp(ostart, astart) != 0) { - // some thing is amiss the args don't match - JLI_TraceLauncher("Warning: app args parsing error\n"); - JLI_TraceLauncher("passing arguments as-is\n"); + idx = JLI_GetAppArgIndex(); + isTool = (idx == 0); + if (isTool) { idx++; } // skip tool name + JLI_TraceLauncher("AppArgIndex: %d points to %s\n", idx, stdargs[idx].arg); + + appArgIdx = calloc(argc, sizeof(int)); + for (i = idx, j = 0; i < stdargc; i++) { + if (isTool) { // filter -J used by tools to pass JVM options + arg = stdargs[i].arg; + if (arg[0] == '-' && arg[1] == 'J') { + continue; + } + } + appArgIdx[j++] = i; + } + // sanity check, ensure same number of arguments for application + if (j != argc) { + JLI_TraceLauncher("Warning: app args count doesn't match, %d %d\n", j, argc); + JLI_TraceLauncher("passing arguments as-is.\n"); + JLI_MemFree(appArgIdx); return NewPlatformStringArray(env, strv, argc); } // make a copy of the args which will be expanded in java if required. nargv = (char **)JLI_MemAlloc(argc * sizeof(char*)); - for (i = 0, j = idx; i < argc; i++, j++) { - jboolean arg_expand = (JLI_StrCmp(filteredargs[j].arg, strv[i]) == 0) - ? filteredargs[j].has_wildcard + for (i = 0; i < argc; i++) { + j = appArgIdx[i]; + jboolean arg_expand = (JLI_StrCmp(stdargs[j].arg, strv[i]) == 0) + ? stdargs[j].has_wildcard : JNI_FALSE; if (needs_expansion == JNI_FALSE) needs_expansion = arg_expand; @@ -1039,6 +1031,7 @@ JLI_MemFree(nargv[i]); } JLI_MemFree(nargv); + JLI_MemFree(appArgIdx); return NewPlatformStringArray(env, strv, argc); } NULL_CHECK0(mid = (*env)->GetStaticMethodID(env, cls, @@ -1053,6 +1046,6 @@ JLI_MemFree(nargv[i]); } JLI_MemFree(nargv); - JLI_MemFree(filteredargs); + JLI_MemFree(appArgIdx); return outArray; } diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/java.logging/share/classes/java/util/logging/LogManager.java --- a/jdk/src/java.logging/share/classes/java/util/logging/LogManager.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/java.logging/share/classes/java/util/logging/LogManager.java Wed Jul 05 21:58:29 2017 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -387,11 +387,15 @@ assert rootLogger == null; assert initializedCalled && !initializationDone; + // create root logger before reading primordial + // configuration - to ensure that it will be added + // before the global logger, and not after. + owner.rootLogger = owner.new RootLogger(); + // Read configuration. owner.readPrimordialConfiguration(); // Create and retain Logger for the root of the namespace. - owner.rootLogger = owner.new RootLogger(); owner.addLogger(owner.rootLogger); if (!owner.rootLogger.isLevelInitialized()) { owner.rootLogger.setLevel(defaultLevel); @@ -516,7 +520,7 @@ if (result == null) { // only allocate the new logger once Logger newLogger = new Logger(name, resourceBundleName, - module == null ? null : module, this, false); + module, this, false); do { if (addLogger(newLogger)) { // We successfully added the new Logger that we @@ -569,15 +573,13 @@ } while (logger == null); // LogManager will set the sysLogger's handlers via LogManager.addLogger method. - if (logger != sysLogger && sysLogger.accessCheckedHandlers().length == 0) { - // if logger already exists but handlers not set + if (logger != sysLogger) { + // if logger already exists we merge the two logger configurations. final Logger l = logger; AccessController.doPrivileged(new PrivilegedAction() { @Override public Void run() { - for (Handler hdl : l.accessCheckedHandlers()) { - sysLogger.addHandler(hdl); - } + l.mergeWithSystemLogger(sysLogger); return null; } }); diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/java.logging/share/classes/java/util/logging/Logger.java --- a/jdk/src/java.logging/share/classes/java/util/logging/Logger.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/java.logging/share/classes/java/util/logging/Logger.java Wed Jul 05 21:58:29 2017 +0200 @@ -259,13 +259,185 @@ private static final RuntimePermission GET_CLASS_LOADER_PERMISSION = new RuntimePermission("getClassLoader"); + // A value class that holds the logger configuration data. + // This configuration can be shared between an application logger + // and a system logger of the same name. + private static final class ConfigurationData { + + // The delegate field is used to avoid races while + // merging configuration. This will ensure that any pending + // configuration action on an application logger will either + // be finished before the merge happens, or will be forwarded + // to the system logger configuration after the merge is completed. + // By default delegate=this. + private volatile ConfigurationData delegate; + + volatile boolean useParentHandlers; + volatile Filter filter; + volatile Level levelObject; + volatile int levelValue; // current effective level value + final CopyOnWriteArrayList handlers = + new CopyOnWriteArrayList<>(); + + ConfigurationData() { + delegate = this; + useParentHandlers = true; + levelValue = Level.INFO.intValue(); + } + + void setUseParentHandlers(boolean flag) { + useParentHandlers = flag; + if (delegate != this) { + // merge in progress - propagate value to system peer. + final ConfigurationData system = delegate; + synchronized (system) { + system.useParentHandlers = useParentHandlers; + } + } + } + + void setFilter(Filter f) { + filter = f; + if (delegate != this) { + // merge in progress - propagate value to system peer. + final ConfigurationData system = delegate; + synchronized (system) { + system.filter = filter; + } + } + } + + void setLevelObject(Level l) { + levelObject = l; + if (delegate != this) { + // merge in progress - propagate value to system peer. + final ConfigurationData system = delegate; + synchronized (system) { + system.levelObject = levelObject; + } + } + } + + void setLevelValue(int v) { + levelValue = v; + if (delegate != this) { + // merge in progress - propagate value to system peer. + final ConfigurationData system = delegate; + synchronized (system) { + system.levelValue = levelValue; + } + } + } + + void addHandler(Handler h) { + if (handlers.add(h)) { + if (delegate != this) { + // merge in progress - propagate value to system peer. + final ConfigurationData system = delegate; + synchronized (system) { + system.handlers.addIfAbsent(h); + } + } + } + } + + void removeHandler(Handler h) { + if (handlers.remove(h)) { + if (delegate != this) { + // merge in progress - propagate value to system peer. + final ConfigurationData system = delegate; + synchronized (system) { + system.handlers.remove(h); + } + } + } + } + + ConfigurationData merge(Logger systemPeer) { + if (!systemPeer.isSystemLogger) { + // should never come here + throw new InternalError("not a system logger"); + } + + ConfigurationData system = systemPeer.config; + + if (system == this) { + // nothing to do + return system; + } + + synchronized (system) { + // synchronize before checking on delegate to counter + // race conditions where two threads might attempt to + // merge concurrently + if (delegate == system) { + // merge already performed; + return system; + } + + // publish system as the temporary delegate configuration. + // This should take care of potential race conditions where + // an other thread might attempt to call e.g. setlevel on + // the application logger while merge is in progress. + // (see implementation of ConfigurationData::setLevel) + delegate = system; + + // merge this config object data into the system config + system.useParentHandlers = useParentHandlers; + system.filter = filter; + system.levelObject = levelObject; + system.levelValue = levelValue; + + // Prevent race condition in case two threads attempt to merge + // configuration and add handlers at the same time. We don't want + // to add the same handlers twice. + // + // Handlers are created and loaded by LogManager.addLogger. If we + // reach here, then it means that the application logger has + // been created first and added with LogManager.addLogger, and the + // system logger was created after - and no handler has been added + // to it by LogManager.addLogger. Therefore, system.handlers + // should be empty. + // + // A non empty cfg.handlers list indicates a race condition + // where two threads might attempt to merge the configuration + // or add handlers concurrently. Though of no consequence for + // the other data (level etc...) this would be an issue if we + // added the same handlers twice. + // + for (Handler h : handlers) { + if (!system.handlers.contains(h)) { + systemPeer.addHandler(h); + } + } + system.handlers.retainAll(handlers); + system.handlers.addAllAbsent(handlers); + } + + // sanity: update effective level after merging + synchronized(treeLock) { + systemPeer.updateEffectiveLevel(); + } + + return system; + } + + } + + // The logger configuration data. Ideally, this should be final + // for system loggers, and replace-once for application loggers. + // When an application requests a logger by name, we do not know a-priori + // whether that corresponds to a system logger name or not. + // So if no system logger by that name already exists, we simply return an + // application logger. + // If a system class later requests a system logger of the same name, then + // the application logger and system logger configurations will be merged + // in a single instance of ConfigurationData that both loggers will share. + private volatile ConfigurationData config; + private volatile LogManager manager; private String name; - private final CopyOnWriteArrayList handlers = - new CopyOnWriteArrayList<>(); private volatile LoggerBundle loggerBundle = NO_RESOURCE_BUNDLE; - private volatile boolean useParentHandlers = true; - private volatile Filter filter; private boolean anonymous; // Cache to speed up behavior of findResourceBundle: @@ -280,8 +452,6 @@ // references from children to parents. private volatile Logger parent; // our nearest parent. private ArrayList kids; // WeakReferences to loggers that have us as parent - private volatile Level levelObject; - private volatile int levelValue; // current effective level value private WeakReference callerModuleRef; private final boolean isSystemLogger; @@ -384,9 +554,29 @@ LogManager manager, boolean isSystemLogger) { this.manager = manager; this.isSystemLogger = isSystemLogger; - setupResourceInfo(resourceBundleName, caller); + this.config = new ConfigurationData(); this.name = name; - levelValue = Level.INFO.intValue(); + setupResourceInfo(resourceBundleName, caller); + } + + // Called by LogManager when a system logger is created + // after a user logger of the same name. + // Ensure that both loggers will share the same + // configuration. + final void mergeWithSystemLogger(Logger system) { + // sanity checks + if (!system.isSystemLogger + || anonymous + || name == null + || !name.equals(system.name)) { + // should never come here + throw new InternalError("invalid logger merge"); + } + checkPermission(); + final ConfigurationData cfg = config; + if (cfg != system.config) { + config = cfg.merge(system); + } } private void setCallerModuleRef(Module callerModule) { @@ -408,7 +598,7 @@ // The manager field is not initialized here. this.name = name; this.isSystemLogger = true; - levelValue = Level.INFO.intValue(); + config = new ConfigurationData(); } // It is called from LoggerContext.addLocalLogger() when the logger @@ -451,7 +641,7 @@ private static Logger demandLogger(String name, String resourceBundleName, Class caller) { LogManager manager = LogManager.getLogManager(); if (!SystemLoggerHelper.disableCallerCheck) { - if (caller.getClassLoader() == null) { + if (isSystem(caller.getModule())) { return manager.demandSystemLogger(name, resourceBundleName, caller); } } @@ -740,7 +930,7 @@ */ public void setFilter(Filter newFilter) throws SecurityException { checkPermission(); - filter = newFilter; + config.setFilter(newFilter); } /** @@ -749,7 +939,7 @@ * @return a filter object (may be null) */ public Filter getFilter() { - return filter; + return config.filter; } /** @@ -765,7 +955,7 @@ if (!isLoggable(record.getLevel())) { return; } - Filter theFilter = filter; + Filter theFilter = config.filter; if (theFilter != null && !theFilter.isLoggable(record)) { return; } @@ -784,7 +974,7 @@ } final boolean useParentHdls = isSystemLogger - ? logger.useParentHandlers + ? logger.config.useParentHandlers : logger.getUseParentHandlers(); if (!useParentHdls) { @@ -1804,13 +1994,13 @@ public void setLevel(Level newLevel) throws SecurityException { checkPermission(); synchronized (treeLock) { - levelObject = newLevel; + config.setLevelObject(newLevel); updateEffectiveLevel(); } } final boolean isLevelInitialized() { - return levelObject != null; + return config.levelObject != null; } /** @@ -1821,7 +2011,7 @@ * @return this Logger's level */ public Level getLevel() { - return levelObject; + return config.levelObject; } /** @@ -1833,6 +2023,7 @@ * @return true if the given message level is currently being logged. */ public boolean isLoggable(Level level) { + int levelValue = config.levelValue; if (level.intValue() < levelValue || levelValue == offValue) { return false; } @@ -1862,7 +2053,7 @@ public void addHandler(Handler handler) throws SecurityException { Objects.requireNonNull(handler); checkPermission(); - handlers.add(handler); + config.addHandler(handler); } /** @@ -1880,7 +2071,7 @@ if (handler == null) { return; } - handlers.remove(handler); + config.removeHandler(handler); } /** @@ -1895,7 +2086,7 @@ // This method should ideally be marked final - but unfortunately // it needs to be overridden by LogManager.RootLogger Handler[] accessCheckedHandlers() { - return handlers.toArray(emptyHandlers); + return config.handlers.toArray(emptyHandlers); } /** @@ -1912,7 +2103,7 @@ */ public void setUseParentHandlers(boolean useParentHandlers) { checkPermission(); - this.useParentHandlers = useParentHandlers; + config.setUseParentHandlers(useParentHandlers); } /** @@ -1922,7 +2113,7 @@ * @return true if output is to be sent to the logger's parent */ public boolean getUseParentHandlers() { - return useParentHandlers; + return config.useParentHandlers; } /** @@ -2256,11 +2447,13 @@ // Figure out our current effective level. int newLevelValue; + final ConfigurationData cfg = config; + final Level levelObject = cfg.levelObject; if (levelObject != null) { newLevelValue = levelObject.intValue(); } else { if (parent != null) { - newLevelValue = parent.levelValue; + newLevelValue = parent.config.levelValue; } else { // This may happen during initialization. newLevelValue = Level.INFO.intValue(); @@ -2268,11 +2461,11 @@ } // If our effective value hasn't changed, we're done. - if (levelValue == newLevelValue) { + if (cfg.levelValue == newLevelValue) { return; } - levelValue = newLevelValue; + cfg.setLevelValue(newLevelValue); // System.err.println("effective level: \"" + getName() + "\" := " + level); diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/java.naming/share/classes/com/sun/jndi/ldap/AbstractLdapNamingEnumeration.java --- a/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/AbstractLdapNamingEnumeration.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/AbstractLdapNamingEnumeration.java Wed Jul 05 21:58:29 2017 +0200 @@ -300,7 +300,7 @@ errEx = e; } - protected abstract AbstractLdapNamingEnumeration getReferredResults( + protected abstract AbstractLdapNamingEnumeration getReferredResults( LdapReferralContext refCtx) throws NamingException; /* @@ -360,7 +360,7 @@ * Merge the entries and/or referrals from the supplied enumeration * with those of the current enumeration. */ - protected void update(AbstractLdapNamingEnumeration ne) { + protected void update(AbstractLdapNamingEnumeration ne) { // Cleanup previous context first homeCtx.decEnumCount(); diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/java.naming/share/classes/com/sun/jndi/ldap/LdapBindingEnumeration.java --- a/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/LdapBindingEnumeration.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/LdapBindingEnumeration.java Wed Jul 05 21:58:29 2017 +0200 @@ -104,9 +104,9 @@ } @Override - protected LdapBindingEnumeration getReferredResults( + protected AbstractLdapNamingEnumeration getReferredResults( LdapReferralContext refCtx) throws NamingException{ // repeat the original operation at the new context - return (LdapBindingEnumeration)refCtx.listBindings(listArg); + return (AbstractLdapNamingEnumeration)refCtx.listBindings(listArg); } } diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/java.naming/share/classes/com/sun/jndi/ldap/LdapNamingEnumeration.java --- a/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/LdapNamingEnumeration.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/LdapNamingEnumeration.java Wed Jul 05 21:58:29 2017 +0200 @@ -72,9 +72,9 @@ } @Override - protected LdapNamingEnumeration getReferredResults( + protected AbstractLdapNamingEnumeration getReferredResults( LdapReferralContext refCtx) throws NamingException { // repeat the original operation at the new context - return (LdapNamingEnumeration)refCtx.list(listArg); + return (AbstractLdapNamingEnumeration)refCtx.list(listArg); } } diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/java.naming/share/classes/com/sun/jndi/ldap/LdapSearchEnumeration.java --- a/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/LdapSearchEnumeration.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/LdapSearchEnumeration.java Wed Jul 05 21:58:29 2017 +0200 @@ -199,15 +199,15 @@ } @Override - protected LdapSearchEnumeration getReferredResults( + protected AbstractLdapNamingEnumeration getReferredResults( LdapReferralContext refCtx) throws NamingException { // repeat the original operation at the new context - return (LdapSearchEnumeration)refCtx.search( + return (AbstractLdapNamingEnumeration)refCtx.search( searchArgs.name, searchArgs.filter, searchArgs.cons); } @Override - protected void update(AbstractLdapNamingEnumeration ne) { + protected void update(AbstractLdapNamingEnumeration ne) { super.update(ne); // Update search-specific variables diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/UcryptoProvider.java --- a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/UcryptoProvider.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/UcryptoProvider.java Wed Jul 05 21:58:29 2017 +0200 @@ -235,13 +235,14 @@ @Override public Provider configure(String configArg) throws InvalidParameterException { - // default policy entry only grants read access to default config - if (!defConfigName.equals(configArg)) { - throw new InvalidParameterException("Ucrypto provider can only be " + - "configured with default configuration file"); + try { + init(configArg); + } catch (UcryptoException ue) { + InvalidParameterException ipe = + new InvalidParameterException("Error using " + configArg); + ipe.initCause(ue.getCause()); + throw ipe; } - // re-read the config - init(defConfigName); return this; } diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/jdk.httpserver/share/classes/com/sun/net/httpserver/package-info.java --- a/jdk/src/jdk.httpserver/share/classes/com/sun/net/httpserver/package-info.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/jdk.httpserver/share/classes/com/sun/net/httpserver/package-info.java Wed Jul 05 21:58:29 2017 +0200 @@ -54,7 +54,7 @@ } ... - HttpServer server = HttpServer.create(new InetSocketAddress(8000)); + HttpServer server = HttpServer.create(new InetSocketAddress(8000), 0); server.createContext("/applications/myapp", new MyHandler()); server.setExecutor(null); // creates a default executor server.start(); diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java --- a/jdk/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java Wed Jul 05 21:58:29 2017 +0200 @@ -118,7 +118,8 @@ boolean protectedPath; // protected authentication path String storetype; // keystore type String providerName; // provider name - Vector providers = null; // list of providers + List providers = null; // list of provider names + List providerClasses = null; // list of provider classes // arguments for provider constructors HashMap providerArgs = new HashMap<>(); char[] keypass; // private key password @@ -174,30 +175,36 @@ // Try to load and install the specified providers if (providers != null) { - ClassLoader cl = ClassLoader.getSystemClassLoader(); - Enumeration e = providers.elements(); - while (e.hasMoreElements()) { - String provName = e.nextElement(); - Class provClass; - if (cl != null) { - provClass = cl.loadClass(provName); - } else { - provClass = Class.forName(provName); + for (String provName: providers) { + try { + KeyStoreUtil.loadProviderByName(provName, + providerArgs.get(provName)); + if (debug) { + System.out.println("loadProviderByName: " + provName); + } + } catch (IllegalArgumentException e) { + throw new Exception(String.format(rb.getString( + "provider.name.not.found"), provName)); } + } + } - Object obj = provClass.newInstance(); - if (!(obj instanceof Provider)) { - MessageFormat form = new MessageFormat(rb.getString - ("provName.not.a.provider")); - Object[] source = {provName}; - throw new Exception(form.format(source)); + if (providerClasses != null) { + ClassLoader cl = ClassLoader.getSystemClassLoader(); + for (String provClass: providerClasses) { + try { + KeyStoreUtil.loadProviderByClass(provClass, + providerArgs.get(provClass), cl); + if (debug) { + System.out.println("loadProviderByClass: " + provClass); + } + } catch (ClassCastException cce) { + throw new Exception(String.format(rb.getString( + "provclass.not.a.provider"), provClass)); + } catch (IllegalArgumentException e) { + throw new Exception(String.format(rb.getString( + "provider.class.not.found"), provClass), e.getCause()); } - Provider p = (Provider) obj; - String provArg = providerArgs.get(provName); - if (provArg != null) { - p = p.configure(provArg); - } - Security.addProvider(p); } } @@ -335,11 +342,26 @@ } else if (collator.compare(flags, "-providerName") ==0) { if (++n == args.length) usageNoArg(); providerName = args[n]; - } else if ((collator.compare(flags, "-provider") == 0) || - (collator.compare(flags, "-providerClass") == 0)) { + } else if (collator.compare(flags, "-provider") == 0 || + collator.compare(flags, "-providerClass") == 0) { + if (++n == args.length) usageNoArg(); + if (providerClasses == null) { + providerClasses = new ArrayList<>(3); + } + providerClasses.add(args[n]); + + if (args.length > (n+1)) { + flags = args[n+1]; + if (collator.compare(flags, "-providerArg") == 0) { + if (args.length == (n+2)) usageNoArg(); + providerArgs.put(args[n], args[n+2]); + n += 2; + } + } + } else if (collator.compare(flags, "-addprovider") == 0) { if (++n == args.length) usageNoArg(); if (providers == null) { - providers = new Vector(3); + providers = new ArrayList<>(3); } providers.add(args[n]); @@ -584,9 +606,14 @@ (".providerName.name.provider.name")); System.out.println(); System.out.println(rb.getString - (".providerClass.class.name.of.cryptographic.service.provider.s")); + (".add.provider.option")); System.out.println(rb.getString - (".providerArg.arg.master.class.file.and.constructor.argument")); + (".providerArg.option.1")); + System.out.println(); + System.out.println(rb.getString + (".providerClass.option")); + System.out.println(rb.getString + (".providerArg.option.2")); System.out.println(); System.out.println(rb.getString (".strict.treat.warnings.as.errors")); diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Resources.java --- a/jdk/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Resources.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Resources.java Wed Jul 05 21:58:29 2017 +0200 @@ -40,8 +40,9 @@ {"6SPACE", " "}, {"COMMA", ", "}, - {"provName.not.a.provider", "{0} not a provider"}, - {"signerClass.is.not.a.signing.mechanism", "{0} is not a signing mechanism"}, + {"provclass.not.a.provider", "%s not a provider"}, + {"provider.name.not.found", "Provider named \"%s\" not found"}, + {"provider.class.not.found", "Provider \"%s\" not found"}, {"jarsigner.error.", "jarsigner error: "}, {"Illegal.option.", "Illegal option: "}, {"This.option.is.deprecated", "This option is deprecated: "}, @@ -105,10 +106,14 @@ "[-protected] keystore has protected authentication path"}, {".providerName.name.provider.name", "[-providerName ] provider name"}, - {".providerClass.class.name.of.cryptographic.service.provider.s", - "[-providerClass name of cryptographic service provider's"}, - {".providerArg.arg.master.class.file.and.constructor.argument", - " [-providerArg ]] ... master class file and constructor argument"}, + {".add.provider.option", + "[-addprovider add security provider by name (e.g. SunPKCS11)"}, + {".providerArg.option.1", + " [-providerArg ]] ... configure argument for -addprovider"}, + {".providerClass.option", + "[-providerClass add security provider by fully-qualified class name"}, + {".providerArg.option.2", + " [-providerArg ]] ... configure argument for -providerClass"}, {".strict.treat.warnings.as.errors", "[-strict] treat warnings as errors"}, {".conf.url.specify.a.pre.configured.options.file", diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginStack.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginStack.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginStack.java Wed Jul 05 21:58:29 2017 +0200 @@ -400,6 +400,14 @@ } @Override + public Optional findEntryInContext(String path, ModuleEntry context) { + Objects.requireNonNull(path); + Objects.requireNonNull(context); + Optional res = pool.findEntryInContext(path, context); + return res.map(this::getUncompressed); + } + + @Override public boolean contains(ModuleEntry res) { return pool.contains(res); } diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModuleEntryFactory.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModuleEntryFactory.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModuleEntryFactory.java Wed Jul 05 21:58:29 2017 +0200 @@ -51,16 +51,32 @@ original.getPath(), original.getType(), file); } - private static String moduleFrom(String path) { + static String moduleFrom(String path) { Objects.requireNonNull(path); if (path.isEmpty() || path.charAt(0) != '/') { throw new IllegalArgumentException(path + " must start with /"); } - String noRoot = path.substring(1); - int idx = noRoot.indexOf('/'); + int idx = path.indexOf('/', 1); if (idx == -1) { throw new IllegalArgumentException("/ missing after module: " + path); } - return noRoot.substring(0, idx); + return path.substring(1, idx); + } + + static String packageFrom(String path) { + Objects.requireNonNull(path); + int idx = path.lastIndexOf('/'); + if (idx == -1) { + throw new IllegalArgumentException("/ missing from path: " + path); + } + if (path.startsWith("/")) { + int jdx = path.indexOf('/', 1); + if (jdx == -1) { + throw new IllegalArgumentException("/ missing after module: " + path); + } + return path.substring(jdx + 1, idx); + } else { + return path.substring(0, idx); + } } } diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModulePoolImpl.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModulePoolImpl.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModulePoolImpl.java Wed Jul 05 21:58:29 2017 +0200 @@ -265,6 +265,25 @@ } /** + * Get the ModuleEntry for the passed path restricted to supplied context. + * + * @param path A data path + * @param context A context of the search + * @return A ModuleEntry instance or null if the data is not found + */ + @Override + public Optional findEntryInContext(String path, ModuleEntry context) { + Objects.requireNonNull(path); + Objects.requireNonNull(context); + LinkModule module = modules.get(context.getModule()); + Objects.requireNonNull(module); + Optional entry = module.findEntry(path); + // Navigating other modules via requires and exports is problematic + // since we cannot construct the runtime model of loaders and layers. + return entry; + } + + /** * Check if the ModulePool contains the given ModuleEntry. * * @param data The module data to check existence for. diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ClassForNamePlugin.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ClassForNamePlugin.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ClassForNamePlugin.java Wed Jul 05 21:58:29 2017 +0200 @@ -28,7 +28,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.stream.Collectors; +import java.util.Optional; import jdk.tools.jlink.plugin.ModulePool; import jdk.tools.jlink.plugin.Plugin.Category; import jdk.internal.org.objectweb.asm.ClassReader; @@ -67,7 +67,7 @@ return index == -1 ? "" : binaryName.substring(0, index); } - private ModuleEntry transform(ModuleEntry resource, Map classes) { + private ModuleEntry transform(ModuleEntry resource, ModulePool pool) { byte[] inBytes = resource.getBytes(); ClassReader cr = new ClassReader(inBytes); ClassNode cn = new ClassNode(); @@ -96,10 +96,11 @@ min.desc.equals("(Ljava/lang/String;)Ljava/lang/Class;")) { String ldcClassName = ldc.cst.toString(); String thatClassName = ldcClassName.replaceAll("\\.", "/"); - ModuleEntry thatClass = classes.get(thatClassName); + Optional thatClass = + pool.findEntryInContext(thatClassName + ".class", resource); - if (thatClass != null) { - int thatAccess = getAccess(thatClass); + if (thatClass.isPresent()) { + int thatAccess = getAccess(thatClass.get()); String thatPackage = getPackage(thatClassName); if ((thatAccess & Opcodes.ACC_PRIVATE) != Opcodes.ACC_PRIVATE && @@ -142,19 +143,13 @@ public void visit(ModulePool in, ModulePool out) { Objects.requireNonNull(in); Objects.requireNonNull(out); - Map classes = in.entries() - .filter(resource -> resource != null && - resource.getPath().endsWith(".class") && - !resource.getPath().endsWith("/module-info.class")) - .collect(Collectors.toMap(resource -> binaryClassName(resource.getPath()), - resource -> resource)); + in.entries() - .filter(resource -> resource != null) .forEach(resource -> { String path = resource.getPath(); if (path.endsWith(".class") && !path.endsWith("/module-info.class")) { - out.add(transform(resource, classes)); + out.add(transform(resource, in)); } else { out.add(resource); } diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/ModulePool.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/ModulePool.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/ModulePool.java Wed Jul 05 21:58:29 2017 +0200 @@ -89,7 +89,16 @@ * @param path A data path * @return A ModuleEntry instance or null if the data is not found */ - public Optional findEntry(String path); + public Optional findEntry(String path); + + /** + * Get the ModuleEntry for the passed path restricted to supplied context. + * + * @param path A data path + * @param context A context of the search + * @return A ModuleEntry instance or null if the data is not found + */ + public Optional findEntryInContext(String path, ModuleEntry context); /** * Check if the ModulePool contains the given ModuleEntry. diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_ar.java --- a/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_ar.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_ar.java Wed Jul 05 21:58:29 2017 +0200 @@ -371,6 +371,8 @@ sharedShortEras }, { "roc.short.Eras", sharedShortEras }, + { "timezone.gmtFormat", + "\u062c\u0631\u064a\u0646\u062a\u0634{0}" }, }; } } diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_be.java --- a/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_be.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_be.java Wed Jul 05 21:58:29 2017 +0200 @@ -308,6 +308,8 @@ sharedAbbreviatedAmPmMarkers }, { "roc.narrow.AmPmMarkers", sharedNarrowAmPmMarkers }, + { "timezone.hourFormat", + "+HH.mm;-HH.mm" }, }; } } diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_bg.java --- a/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_bg.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_bg.java Wed Jul 05 21:58:29 2017 +0200 @@ -309,6 +309,8 @@ sharedAmPmMarkers }, { "roc.narrow.AmPmMarkers", sharedAmPmMarkers }, + { "timezone.gmtFormat", + "\u0413\u0440\u0438\u043d\u0443\u0438\u0447{0}" }, }; } } diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_cs.java --- a/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_cs.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_cs.java Wed Jul 05 21:58:29 2017 +0200 @@ -298,6 +298,8 @@ sharedEras }, { "roc.short.Eras", sharedEras }, + { "timezone.hourFormat", + "+H:mm;-H:mm" }, }; } } diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_da.java --- a/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_da.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_da.java Wed Jul 05 21:58:29 2017 +0200 @@ -308,6 +308,8 @@ sharedEras }, { "roc.short.Eras", sharedEras }, + { "timezone.hourFormat", + "+HH.mm;-HH.mm" }, }; } } diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_et.java --- a/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_et.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_et.java Wed Jul 05 21:58:29 2017 +0200 @@ -280,6 +280,8 @@ sharedTimePatterns }, { "roc.narrow.AmPmMarkers", sharedNarrowAmPmMarkers }, + { "timezone.hourFormat", + "+HH:mm;\u2212HH:mm" }, }; } } diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_fi.java --- a/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_fi.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_fi.java Wed Jul 05 21:58:29 2017 +0200 @@ -324,6 +324,10 @@ sharedEras }, { "roc.short.Eras", sharedEras }, + { "timezone.gmtFormat", + "UTC{0}" }, + { "timezone.hourFormat", + "+H.mm;-H.mm" }, }; } } diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_fr.java --- a/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_fr.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_fr.java Wed Jul 05 21:58:29 2017 +0200 @@ -329,6 +329,10 @@ sharedEras }, { "roc.short.Eras", sharedEras }, + { "timezone.gmtFormat", + "UTC{0}" }, + { "timezone.hourFormat", + "+HH:mm;\u2212HH:mm" }, }; } } diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_ga.java --- a/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_ga.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_ga.java Wed Jul 05 21:58:29 2017 +0200 @@ -284,6 +284,8 @@ sharedAmPmMarkers }, { "roc.narrow.AmPmMarkers", sharedNarrowAmPmMarkers }, + { "timezone.gmtFormat", + "MAG{0}" }, }; } } diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_hr.java --- a/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_hr.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_hr.java Wed Jul 05 21:58:29 2017 +0200 @@ -335,6 +335,8 @@ sharedEras }, { "roc.short.Eras", sharedEras }, + { "timezone.hourFormat", + "+HH:mm; -HH:mm" }, }; } } diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_in.java --- a/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_in.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_in.java Wed Jul 05 21:58:29 2017 +0200 @@ -347,6 +347,8 @@ sharedEras }, { "roc.short.Eras", sharedEras }, + { "timezone.hourFormat", + "+HH.mm;-HH.mm" }, }; } } diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_iw.java --- a/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_iw.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_iw.java Wed Jul 05 21:58:29 2017 +0200 @@ -324,6 +324,10 @@ sharedAmPmMarkers }, { "roc.narrow.AmPmMarkers", sharedAmPmMarkers }, + { "timezone.gmtFormat", + "GMT{0}\u200e" }, + { "timezone.hourFormat", + "\u200e+HH:mm;-HH:mm\u200e" }, }; } } diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_lt.java --- a/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_lt.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_lt.java Wed Jul 05 21:58:29 2017 +0200 @@ -325,6 +325,8 @@ sharedEras }, { "roc.short.Eras", sharedEras }, + { "timezone.hourFormat", + "+HH:mm;\u2212HH:mm" }, }; } } diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_no.java --- a/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_no.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_no.java Wed Jul 05 21:58:29 2017 +0200 @@ -389,6 +389,8 @@ sharedEras }, { "roc.short.Eras", sharedEras }, + { "timezone.hourFormat", + "+HH.mm;-HH.mm" }, }; } } diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_sl.java --- a/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_sl.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_sl.java Wed Jul 05 21:58:29 2017 +0200 @@ -286,6 +286,8 @@ sharedAmPmMarkers }, { "roc.narrow.AmPmMarkers", sharedNarrowAmPmMarkers }, + { "timezone.hourFormat", + "+HH.mm;-HH.mm" }, }; } } diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_sq.java --- a/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_sq.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_sq.java Wed Jul 05 21:58:29 2017 +0200 @@ -294,6 +294,8 @@ sharedAmPmMarkers }, { "roc.narrow.AmPmMarkers", sharedAmPmMarkers }, + { "timezone.gmtFormat", + "Ora e Grenui\u00e7it: {0}" }, }; } } diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_sr.java --- a/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_sr.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_sr.java Wed Jul 05 21:58:29 2017 +0200 @@ -386,6 +386,8 @@ sharedShortEras }, { "roc.short.Eras", sharedShortEras }, + { "timezone.hourFormat", + "+HHmm;-HHmm" }, }; } } diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_sv.java --- a/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_sv.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_sv.java Wed Jul 05 21:58:29 2017 +0200 @@ -345,6 +345,8 @@ sharedEras }, { "roc.short.Eras", sharedEras }, + { "timezone.hourFormat", + "+HH:mm;\u2212HH:mm" }, }; } } diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/src/jdk.policytool/share/classes/sun/security/tools/policytool/PolicyTool.java --- a/jdk/src/jdk.policytool/share/classes/sun/security/tools/policytool/PolicyTool.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/src/jdk.policytool/share/classes/sun/security/tools/policytool/PolicyTool.java Wed Jul 05 21:58:29 2017 +0200 @@ -1376,10 +1376,6 @@ ToolDialog ed = new ToolDialog (PolicyTool.getMessage("Error"), tool, this, true); - // find where the PolicyTool gui is - Point location = ((w == null) ? - getLocationOnScreen() : w.getLocationOnScreen()); - //ed.setBounds(location.x + 50, location.y + 50, 600, 100); ed.setLayout(new GridBagLayout()); JLabel label = new JLabel(error); diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/test/ProblemList.txt --- a/jdk/test/ProblemList.txt Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/test/ProblemList.txt Wed Jul 05 21:58:29 2017 +0200 @@ -213,9 +213,9 @@ # jdk_security -sun/security/pkcs11/ec/TestKeyFactory.java 7157786 generic-all +sun/security/pkcs11/ec/TestKeyFactory.java 8026976 generic-all -sun/security/krb5/auto/Unreachable.java 7164518 macosx-all no PortUnreachableException on Mac +sun/security/krb5/auto/Unreachable.java 7164518 macosx-all sun/security/tools/keytool/ListKeychainStore.sh 8156889 macosx-all @@ -284,6 +284,7 @@ sun/security/krb5/auto/HttpNegotiateServer.java 8038079 generic-all sun/security/tools/keytool/autotest.sh 8130302 generic-all +sun/security/ssl/SSLSocketImpl/AsyncSSLSocketClose.java 8161232 macosx-all ############################################################################ diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/test/java/lang/Runtime/Version/VersionProps.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/java/lang/Runtime/Version/VersionProps.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2016 SAP SE. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 8160564 + * @summary check the implementation of VersionProps.versionNumbers() + * @run main VersionProps + * @author Volker Simonis + */ + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.List; + +public class VersionProps { + + final static String[] validVersions = { + "1", "1.2", "1.2.3", "1.2.3.4", "1.0.0.1", + "1.10000.1", "1.0.2.0.0.3.0.0.0.4.5.0.0.6", + "1000001", "1.2.3.4.5.6.7.8.9.0.9.8.7.6.5.4.3.2.1" }; + + @SuppressWarnings("rawtypes") + final static List[] validLists = { + Arrays.asList(1), + Arrays.asList(1, 2), + Arrays.asList(1, 2, 3), + Arrays.asList(1, 2, 3, 4), + Arrays.asList(1, 0, 0, 1), + Arrays.asList(1, 10000, 1), + Arrays.asList(1, 0, 2, 0, 0, 3, 0, 0, 0, 4, 5, 0, 0, 6), + Arrays.asList(1000001), + Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1) }; + + final static String[] invalidVersions = { + "01", "0.1.2", "1.02.3", "1.2.03.4", "1.0.0.1.0", + "1.0.1.0.0", "1.00.1", "1.0.1.00", "1.10000." }; + + public static void main(String[] args) throws Exception { + Class versionProps = Class.forName("java.lang.VersionProps"); + Method parseVersionNumbers = + versionProps.getDeclaredMethod("parseVersionNumbers", String.class); + parseVersionNumbers.setAccessible(true); + + for (int i = 0; i < validVersions.length; i++) { + @SuppressWarnings("unchecked") + List li = + (List)parseVersionNumbers.invoke(null, validVersions[i]); + System.out.println(li); + if (!validLists[i].equals(li)) + throw new Exception(li + " != " + validLists[i]); + li = Runtime.Version.parse(validVersions[i]).version(); + if (!validLists[i].equals(li)) + throw new Exception(li + " != " + validLists[i]); + } + + for (int i = 0; i < invalidVersions.length; i++) { + try { + List li = + (List)parseVersionNumbers.invoke(null, invalidVersions[i]); + throw new Exception(invalidVersions[i] + + " not recognized as invalid by VersionProps.parseVersionNumbers()"); + } catch (InvocationTargetException ex) { + if (ex.getCause() instanceof IllegalArgumentException) { + System.out.println("OK - caught bad version string " + + invalidVersions[i]); + } else { + throw ex; + } + } + + try { + List li = Runtime.Version.parse(invalidVersions[i]).version(); + throw new Exception(invalidVersions[i] + + " not recognized as invalid by Runtime.Version.parse()"); + } catch (IllegalArgumentException ex) { + continue; + } + } + } +} diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/test/java/lang/System/Logger/default/DefaultLoggerTest.java --- a/jdk/test/java/lang/System/Logger/default/DefaultLoggerTest.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/test/java/lang/System/Logger/default/DefaultLoggerTest.java Wed Jul 05 21:58:29 2017 +0200 @@ -539,6 +539,7 @@ throw new RuntimeException("identical loggers"); } + final java.util.logging.Logger sink; final java.util.logging.Logger appSink; final java.util.logging.Logger sysSink; final java.util.logging.Handler appHandler; @@ -548,10 +549,9 @@ try { appSink = java.util.logging.Logger.getLogger("foo"); sysSink = accessSystemLogger.demandSystemLogger("foo"); - appSink.addHandler(appHandler = new MyHandler()); - sysSink.addHandler(sysHandler = new MyHandler()); - appSink.setUseParentHandlers(false); - sysSink.setUseParentHandlers(false); + sink = java.util.logging.Logger.getLogger("foo"); + sink.addHandler(appHandler = sysHandler = new MyHandler()); + sink.setUseParentHandlers(false); provider = LoggerFinder.getLoggerFinder(); } finally { allowAll.get().set(false); diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/test/java/lang/System/LoggerFinder/DefaultLoggerFinderTest/DefaultLoggerFinderTest.java --- a/jdk/test/java/lang/System/LoggerFinder/DefaultLoggerFinderTest/DefaultLoggerFinderTest.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/test/java/lang/System/LoggerFinder/DefaultLoggerFinderTest/DefaultLoggerFinderTest.java Wed Jul 05 21:58:29 2017 +0200 @@ -299,10 +299,9 @@ final java.util.logging.Logger appSink = java.util.logging.Logger.getLogger("foo"); final java.util.logging.Logger sysSink = accessSystemLogger.demandSystemLogger("foo"); - appSink.addHandler(new MyHandler()); - sysSink.addHandler(new MyHandler()); - appSink.setUseParentHandlers(VERBOSE); - sysSink.setUseParentHandlers(VERBOSE); + final java.util.logging.Logger sink = java.util.logging.Logger.getLogger("foo"); + sink.addHandler(new MyHandler()); + sink.setUseParentHandlers(VERBOSE); Stream.of(args).map(TestCases::valueOf).forEach((testCase) -> { LoggerFinder provider; diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/test/java/lang/System/LoggerFinder/jdk/DefaultLoggerBridgeTest/DefaultLoggerBridgeTest.java --- a/jdk/test/java/lang/System/LoggerFinder/jdk/DefaultLoggerBridgeTest/DefaultLoggerBridgeTest.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/test/java/lang/System/LoggerFinder/jdk/DefaultLoggerBridgeTest/DefaultLoggerBridgeTest.java Wed Jul 05 21:58:29 2017 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -390,6 +390,7 @@ throw new RuntimeException("identical loggers"); } + final java.util.logging.Logger sink; final java.util.logging.Logger appSink; final java.util.logging.Logger sysSink; final MyHandler appHandler; @@ -404,10 +405,13 @@ if (appSink == sysSink) { throw new RuntimeException("identical backend loggers"); } - appSink.addHandler(appHandler = new MyHandler()); - sysSink.addHandler(sysHandler = new MyHandler()); - appSink.setUseParentHandlers(VERBOSE); - sysSink.setUseParentHandlers(VERBOSE); + sink = java.util.logging.Logger.getLogger("foo"); + if (appSink != sink) { + throw new RuntimeException("expected same application logger"); + } + + sink.addHandler(appHandler = sysHandler = new MyHandler()); + sink.setUseParentHandlers(VERBOSE); } finally { allowAll.get().set(old); } diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/test/java/lang/System/LoggerFinder/jdk/DefaultPlatformLoggerTest/DefaultPlatformLoggerTest.java --- a/jdk/test/java/lang/System/LoggerFinder/jdk/DefaultPlatformLoggerTest/DefaultPlatformLoggerTest.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/test/java/lang/System/LoggerFinder/jdk/DefaultPlatformLoggerTest/DefaultPlatformLoggerTest.java Wed Jul 05 21:58:29 2017 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * 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,9 +42,9 @@ import java.util.logging.LogManager; import java.util.logging.LogRecord; import java.lang.System.LoggerFinder; +import java.util.logging.Logger; import sun.util.logging.PlatformLogger; import sun.util.logging.internal.LoggingProviderImpl; -import java.lang.reflect.Module; /** * @test @@ -248,10 +248,9 @@ DefaultPlatformLoggerTest.class.getModule()); java.util.logging.Logger sysSink = LoggingProviderImpl.getLogManagerAccess() .demandLoggerFor(LogManager.getLogManager(),"foo", Thread.class.getModule()); - appSink.addHandler(new MyHandler()); - sysSink.addHandler(new MyHandler()); - appSink.setUseParentHandlers(VERBOSE); - sysSink.setUseParentHandlers(VERBOSE); + java.util.logging.Logger sink = Logger.getLogger("foo"); + sink.addHandler(new MyHandler()); + sink.setUseParentHandlers(VERBOSE); System.out.println("\n*** Without Security Manager\n"); test(provider, true, appSink, sysSink); @@ -274,7 +273,7 @@ public static void test(LoggerFinder provider, boolean hasRequiredPermissions, java.util.logging.Logger appSink, java.util.logging.Logger sysSink) throws Exception { - // No way to giva a resource bundle to a platform logger. + // No way to give a resource bundle to a platform logger. // ResourceBundle loggerBundle = ResourceBundle.getBundle(MyLoggerBundle.class.getName()); final Map loggerDescMap = new HashMap<>(); diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/test/java/lang/ThreadGroup/Stop.java --- a/jdk/test/java/lang/ThreadGroup/Stop.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/test/java/lang/ThreadGroup/Stop.java Wed Jul 05 21:58:29 2017 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. * 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,60 +28,41 @@ * unpredictable results. */ -public class Stop implements Runnable { - private static boolean groupStopped = false ; - private static final Object lock = new Object(); +import java.util.concurrent.CountDownLatch; - private static final ThreadGroup group = new ThreadGroup(""); - private static final Thread first = new Thread(group, new Stop()); - private static final Thread second = new Thread(group, new Stop()); +public class Stop { - public void run() { - while (true) { - // Give the other thread a chance to start - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - } + public static void main(String[] args) throws Exception { + final CountDownLatch ready = new CountDownLatch(1); + final ThreadGroup group = new ThreadGroup(""); - // When the first thread runs, it will stop the group. - if (Thread.currentThread() == first) { - synchronized (lock) { - try { - group.stop(); - } finally { - // Signal the main thread it is time to check - // that the stopped thread group was successful - groupStopped = true; - lock.notifyAll(); - } + final Thread second = new Thread(group, () -> { + ready.countDown(); + while (true) { + try { + Thread.sleep(60000); + } catch (InterruptedException shouldNotHappen) { } } - } - } + }); - public static void main(String[] args) throws Exception { + final Thread first = new Thread(group, () -> { + // Wait until "second" is started + try { + ready.await(); + } catch (InterruptedException shouldNotHappen) { + } + // Now stop the group + group.stop(); + }); + // Launch two threads as part of the same thread group first.start(); second.start(); - // Wait for the thread group stop to be issued - synchronized(lock){ - while (!groupStopped) { - lock.wait(); - // Give the other thread a chance to stop - Thread.sleep(1000); - } - } - // Check that the second thread is terminated when the // first thread terminates the thread group. - boolean failed = second.isAlive(); - - // Clean up any threads that may have not been terminated - first.stop(); - second.stop(); - if (failed) - throw new RuntimeException("Failure."); + second.join(); + // Test passed - if never get here the test times out and fails. } } diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/test/java/nio/channels/FileChannel/Transfers.java --- a/jdk/test/java/nio/channels/FileChannel/Transfers.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/test/java/nio/channels/FileChannel/Transfers.java Wed Jul 05 21:58:29 2017 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -489,69 +489,72 @@ debug = verbose = true; } - sourceFile = File.createTempFile("xfer.src.", ""); + File testDir = new File(System.getProperty("test.dir", ".")); + + sourceFile = File.createTempFile("xfer.src.", "", testDir); sourceFile.deleteOnExit(); - targetFile = File.createTempFile("xfer.tgt.", ""); + targetFile = File.createTempFile("xfer.tgt.", "", testDir); targetFile.deleteOnExit(); - File fn = File.createTempFile("xfer.fch.", ""); + File fn = File.createTempFile("xfer.fch.", "", testDir); fn.deleteOnExit(); - FileChannel fc = new RandomAccessFile(fn, "rw").getChannel(); Random rnd = new Random(); int failures = 0; - for (boolean to = false;; to = true) { - for (boolean user = false;; user = true) { - if (!verbose) - out.print((to ? "To " : "From ") + - (user ? "user channel" : "file channel") - + ":"); - IntGenerator offGen = new IntGenerator(MAX_XFER_SIZE + 2); - while (offGen.hasNext()) { - int off = offGen.next(); - if (!verbose) out.print(" " + off); - IntGenerator lenGen = new IntGenerator(MAX_XFER_SIZE + 2); - while (lenGen.hasNext()) { - int len = lenGen.next(); - long s = rnd.nextLong(); - String chName = null; - try { - if (to) { - Target tgt; - if (user) - tgt = new UserTarget(len, s); - else - tgt = new FileTarget(len, s); - chName = tgt.name(); - testTo(s, fc, off, len, tgt); + try (FileChannel fc = new RandomAccessFile(fn, "rw").getChannel()) { + for (boolean to = false;; to = true) { + for (boolean user = false;; user = true) { + if (!verbose) + out.print((to ? "To " : "From ") + + (user ? "user channel" : "file channel") + + ":"); + IntGenerator offGen = new IntGenerator(MAX_XFER_SIZE + 2); + while (offGen.hasNext()) { + int off = offGen.next(); + if (!verbose) out.print(" " + off); + IntGenerator lenGen = new IntGenerator(MAX_XFER_SIZE + 2); + while (lenGen.hasNext()) { + int len = lenGen.next(); + long s = rnd.nextLong(); + String chName = null; + try { + if (to) { + Target tgt; + if (user) + tgt = new UserTarget(len, s); + else + tgt = new FileTarget(len, s); + chName = tgt.name(); + testTo(s, fc, off, len, tgt); + } + else { + Source src; + if (user) + src = new UserSource(len, s); + else + src = new FileSource(len, s); + chName = src.name(); + testFrom(s, src, fc, off, len); + } + } catch (Failure x) { + out.println(); + out.println("FAILURE: " + chName + + ", offset " + off + + ", length " + len); + x.printStackTrace(out); + failures++; } - else { - Source src; - if (user) - src = new UserSource(len, s); - else - src = new FileSource(len, s); - chName = src.name(); - testFrom(s, src, fc, off, len); - } - } catch (Failure x) { - out.println(); - out.println("FAILURE: " + chName - + ", offset " + off - + ", length " + len); - x.printStackTrace(out); - failures++; } } + if (!verbose) + out.println(); + if (user) + break; } - if (!verbose) - out.println(); - if (user) + if (to) break; } - if (to) - break; } sourceFile.delete(); @@ -563,6 +566,6 @@ throw new RuntimeException("Some tests failed"); } + out.println("Test succeeded."); } - } diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/test/java/rmi/activation/Activatable/restartService/RestartService.java --- a/jdk/test/java/rmi/activation/Activatable/restartService/RestartService.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/test/java/rmi/activation/Activatable/restartService/RestartService.java Wed Jul 05 21:58:29 2017 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ /* @test * @bug 4095165 4321151 + * @key intermittent * @summary synopsis: activator should restart daemon services * @author Ann Wollrath * diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/test/java/rmi/activation/ActivationGroup/downloadActivationGroup/DownloadActivationGroup.java --- a/jdk/test/java/rmi/activation/ActivationGroup/downloadActivationGroup/DownloadActivationGroup.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/test/java/rmi/activation/ActivationGroup/downloadActivationGroup/DownloadActivationGroup.java Wed Jul 05 21:58:29 2017 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ /* * @test * @bug 4510355 + * @key intermittent * @summary ActivationGroup implementations cannot be downloaded by default; * Creates a custom activation group without setting a security manager * in activation group's descriptor. The custom activation group diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/UseCustomSocketFactory.java --- a/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/UseCustomSocketFactory.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/UseCustomSocketFactory.java Wed Jul 05 21:58:29 2017 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. * 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 4115696 - + * @key intermittent * @summary synopsis: cannot use socket factories with Activatable objects * @author Ann Wollrath * diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/test/java/util/Locale/Bug8154797.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/java/util/Locale/Bug8154797.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 8154797 + * @modules java.base/sun.util.locale.provider + * java.base/sun.util.resources + * jdk.localedata + * @summary Test for checking HourFormat and GmtFormat resources are retrieved from + * COMPAT and CLDR Providers. +*/ + +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; +import sun.util.locale.provider.LocaleProviderAdapter.Type; +import sun.util.locale.provider.LocaleProviderAdapter; + +public class Bug8154797 { + static Map expectedResourcesMap = new HashMap<>(); + static final String GMT_RESOURCE_KEY = "timezone.gmtFormat"; + static final String HMT_RESOURCE_KEY = "timezone.hourFormat"; + static final String GMT = "Gmt"; + static final String HMT = "Hmt"; + + static void generateExpectedValues() { + expectedResourcesMap.put("FR" + GMT, "UTC{0}"); + expectedResourcesMap.put("FR" + HMT, "+HH:mm;\u2212HH:mm"); + expectedResourcesMap.put("FI" + HMT, "+H.mm;-H.mm"); + expectedResourcesMap.put("FI" + GMT, "UTC{0}"); + /* For root locale, en_US, de_DE, hi_IN, ja_JP,Root locale resources + * should be returned. + */ + expectedResourcesMap.put(GMT, "GMT{0}"); //Root locale resource + expectedResourcesMap.put(HMT, "+HH:mm;-HH:mm"); //Root locale resource + } + + static void compareResources(Locale loc) { + String mapKeyHourFormat = HMT, mapKeyGmtFormat = GMT; + ResourceBundle compatBundle, cldrBundle; + compatBundle = LocaleProviderAdapter.forJRE().getLocaleResources(loc) + .getJavaTimeFormatData(); + cldrBundle = LocaleProviderAdapter.forType(Type.CLDR) + .getLocaleResources(loc).getJavaTimeFormatData(); + if (loc.getCountry() == "FR" || loc.getCountry() == "FI") { + mapKeyHourFormat = loc.getCountry() + HMT; + mapKeyGmtFormat = loc.getCountry() + GMT; + } + + if (!(expectedResourcesMap.get(mapKeyGmtFormat) + .equals(compatBundle.getString(GMT_RESOURCE_KEY)) + && expectedResourcesMap.get(mapKeyHourFormat) + .equals(compatBundle.getString(HMT_RESOURCE_KEY)) + && expectedResourcesMap.get(mapKeyGmtFormat) + .equals(cldrBundle.getString(GMT_RESOURCE_KEY)) + && expectedResourcesMap.get(mapKeyHourFormat) + .equals(cldrBundle.getString(HMT_RESOURCE_KEY)))) { + + throw new RuntimeException("Retrieved resource does not match with " + + " expected string for Locale " + compatBundle.getLocale()); + + } + + } + + public static void main(String args[]) { + Bug8154797.generateExpectedValues(); + Locale[] locArr = {new Locale("hi", "IN"), Locale.UK, new Locale("fi", "FI"), + Locale.ROOT, Locale.GERMAN, Locale.JAPANESE, + Locale.ENGLISH, Locale.FRANCE}; + for (Locale loc : locArr) { + Bug8154797.compareResources(loc); + } + } + +} + diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarAPI.java --- a/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarAPI.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarAPI.java Wed Jul 05 21:58:29 2017 +0200 @@ -40,25 +40,19 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipFile; -import static java.util.jar.JarFile.Release; - import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; +import org.testng.annotations.DataProvider; import org.testng.annotations.Test; - public class MultiReleaseJarAPI { - static final int MAJOR_VERSION = Runtime.version().major(); - String userdir = System.getProperty("user.dir","."); CreateMultiReleaseTestJars creator = new CreateMultiReleaseTestJars(); File unversioned = new File(userdir, "unversioned.jar"); File multirelease = new File(userdir, "multi-release.jar"); File signedmultirelease = new File(userdir, "signed-multi-release.jar"); - Release[] values = JarFile.Release.values(); - @BeforeClass public void initialize() throws Exception { @@ -81,7 +75,7 @@ Assert.assertFalse(jf.isMultiRelease()); } - try (JarFile jf = new JarFile(unversioned, true, ZipFile.OPEN_READ, Release.RUNTIME)) { + try (JarFile jf = new JarFile(unversioned, true, ZipFile.OPEN_READ, Runtime.version())) { Assert.assertFalse(jf.isMultiRelease()); } @@ -89,7 +83,7 @@ Assert.assertFalse(jf.isMultiRelease()); } - try (JarFile jf = new JarFile(multirelease, true, ZipFile.OPEN_READ, Release.RUNTIME)) { + try (JarFile jf = new JarFile(multirelease, true, ZipFile.OPEN_READ, Runtime.version())) { Assert.assertTrue(jf.isMultiRelease()); } @@ -110,68 +104,68 @@ private void testCustomMultiReleaseValue(String value, boolean expected) throws Exception { creator.buildCustomMultiReleaseJar("custom-mr.jar", value); File custom = new File(userdir, "custom-mr.jar"); - try (JarFile jf = new JarFile(custom, true, ZipFile.OPEN_READ, Release.RUNTIME)) { + try (JarFile jf = new JarFile(custom, true, ZipFile.OPEN_READ, Runtime.version())) { Assert.assertEquals(jf.isMultiRelease(), expected); } Files.delete(custom.toPath()); } - @Test - public void testVersioning() throws Exception { - // multi-release jar - JarFile jar = new JarFile(multirelease); - Assert.assertEquals(Release.BASE, jar.getVersion()); - jar.close(); + @DataProvider(name = "versions") + public Object[][] createVersionData() throws Exception { + return new Object[][]{ + {JarFile.baseVersion(), 8}, + {JarFile.runtimeVersion(), Runtime.version().major()}, + {Runtime.version(), Runtime.version().major()}, + {Runtime.Version.parse("7.1"), JarFile.baseVersion().major()}, + {Runtime.Version.parse("9"), 9}, + {Runtime.Version.parse("9.1.5-ea+200"), 9} + }; + } - for (Release value : values) { - System.err.println("test versioning for Release " + value); - try (JarFile jf = new JarFile(multirelease, true, ZipFile.OPEN_READ, value)) { - Assert.assertEquals(value, jf.getVersion()); - } + @Test(dataProvider="versions") + public void testVersioning(Runtime.Version value, int xpected) throws Exception { + Runtime.Version expected = Runtime.Version.parse(String.valueOf(xpected)); + Runtime.Version base = JarFile.baseVersion(); + + // multi-release jar, opened as unversioned + try (JarFile jar = new JarFile(multirelease)) { + Assert.assertEquals(jar.getVersion(), base); + } + + System.err.println("test versioning for Release " + value); + try (JarFile jf = new JarFile(multirelease, true, ZipFile.OPEN_READ, value)) { + Assert.assertEquals(jf.getVersion(), expected); } // regular, unversioned, jar - for (Release value : values) { - try (JarFile jf = new JarFile(unversioned, true, ZipFile.OPEN_READ, value)) { - Assert.assertEquals(Release.BASE, jf.getVersion()); - } - } - - // assure that we have a Release object corresponding to the actual runtime version - String version = "VERSION_" + MAJOR_VERSION; - boolean runtimeVersionExists = false; - for (Release value : values) { - if (version.equals(value.name())) runtimeVersionExists = true; - } - Assert.assertTrue(runtimeVersionExists); - } - - @Test - public void testAliasing() throws Exception { - for (Release value : values) { - System.err.println("test aliasing for Release " + value); - String name = value.name(); - String prefix; - if (name.equals("BASE")) { - prefix = ""; - } else if (name.equals("RUNTIME")) { - prefix = "META-INF/versions/" + MAJOR_VERSION + "/"; - } else { - prefix = "META-INF/versions/" + name.substring(8) + "/"; - } - // test both multi-release jars - readAndCompare(multirelease, value, "README", prefix + "README"); - readAndCompare(multirelease, value, "version/Version.class", prefix + "version/Version.class"); - // and signed multi-release jars - readAndCompare(signedmultirelease, value, "README", prefix + "README"); - readAndCompare(signedmultirelease, value, "version/Version.class", prefix + "version/Version.class"); + try (JarFile jf = new JarFile(unversioned, true, ZipFile.OPEN_READ, value)) { + Assert.assertEquals(jf.getVersion(), base); } } - private void readAndCompare(File jar, Release version, String name, String realName) throws Exception { + @Test(dataProvider="versions") + public void testAliasing(Runtime.Version version, int xpected) throws Exception { + int n = Math.max(version.major(), JarFile.baseVersion().major()); + Runtime.Version value = Runtime.Version.parse(String.valueOf(n)); + System.err.println("test aliasing for Release " + version); + String prefix; + if (JarFile.baseVersion().equals(value)) { + prefix = ""; + } else { + prefix = "META-INF/versions/" + value.major() + "/"; + } + // test both multi-release jars + readAndCompare(multirelease, value, "README", prefix + "README"); + readAndCompare(multirelease, value, "version/Version.class", prefix + "version/Version.class"); + // and signed multi-release jars + readAndCompare(signedmultirelease, value, "README", prefix + "README"); + readAndCompare(signedmultirelease, value, "version/Version.class", prefix + "version/Version.class"); + } + + private void readAndCompare(File jar, Runtime.Version version, String name, String realName) throws Exception { byte[] baseBytes; byte[] versionedBytes; - try (JarFile jf = new JarFile(jar, true, ZipFile.OPEN_READ, Release.BASE)) { + try (JarFile jf = new JarFile(jar, true, ZipFile.OPEN_READ, JarFile.baseVersion())) { ZipEntry ze = jf.getEntry(realName); try (InputStream is = jf.getInputStream(ze)) { baseBytes = is.readAllBytes(); @@ -200,7 +194,7 @@ ze1 = jf.getEntry(vname); } Assert.assertEquals(ze1.getName(), vname); - try (JarFile jf = new JarFile(multirelease, true, ZipFile.OPEN_READ, Release.VERSION_9)) { + try (JarFile jf = new JarFile(multirelease, true, ZipFile.OPEN_READ, Runtime.Version.parse("9"))) { ze2 = jf.getEntry(rname); } Assert.assertEquals(ze2.getName(), rname); diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarHttpProperties.java --- a/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarHttpProperties.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarHttpProperties.java Wed Jul 05 21:58:29 2017 +0200 @@ -47,14 +47,8 @@ */ import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.InetSocketAddress; import java.net.URL; import java.net.URLClassLoader; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; import org.testng.Assert; import org.testng.annotations.AfterClass; diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarIterators.java --- a/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarIterators.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarIterators.java Wed Jul 05 21:58:29 2017 +0200 @@ -43,8 +43,6 @@ import java.util.stream.Collectors; import java.util.zip.ZipFile; -import static java.util.jar.JarFile.Release; - import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; @@ -111,17 +109,17 @@ testStream(jf, mrEntries); } - try (JarFile jf = new JarFile(multirelease, true, ZipFile.OPEN_READ, Release.BASE)) { + try (JarFile jf = new JarFile(multirelease, true, ZipFile.OPEN_READ, JarFile.baseVersion())) { testEnumeration(jf, baseEntries); testStream(jf, baseEntries); } - try (JarFile jf = new JarFile(multirelease, true, ZipFile.OPEN_READ, Release.VERSION_9)) { + try (JarFile jf = new JarFile(multirelease, true, ZipFile.OPEN_READ, Runtime.Version.parse("9"))) { testEnumeration(jf, v9Entries); testStream(jf, v9Entries); } - try (JarFile jf = new JarFile(multirelease, true, ZipFile.OPEN_READ, Release.RUNTIME)) { + try (JarFile jf = new JarFile(multirelease, true, ZipFile.OPEN_READ, Runtime.version())) { Map expectedEntries; switch (MAJOR_VERSION) { case 9: @@ -147,17 +145,17 @@ testStream(jf, uvEntries); } - try (JarFile jf = new JarFile(unversioned, true, ZipFile.OPEN_READ, Release.BASE)) { + try (JarFile jf = new JarFile(unversioned, true, ZipFile.OPEN_READ, JarFile.baseVersion())) { testEnumeration(jf, uvEntries); testStream(jf, uvEntries); } - try (JarFile jf = new JarFile(unversioned, true, ZipFile.OPEN_READ, Release.VERSION_9)) { + try (JarFile jf = new JarFile(unversioned, true, ZipFile.OPEN_READ, Runtime.Version.parse("9"))) { testEnumeration(jf, uvEntries); testStream(jf, uvEntries); } - try (JarFile jf = new JarFile(unversioned, true, ZipFile.OPEN_READ, Release.RUNTIME)) { + try (JarFile jf = new JarFile(unversioned, true, ZipFile.OPEN_READ, Runtime.version())) { testEnumeration(jf, uvEntries); testStream(jf, uvEntries); } diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarProperties.java --- a/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarProperties.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarProperties.java Wed Jul 05 21:58:29 2017 +0200 @@ -60,11 +60,10 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -public class MultiReleaseJarProperties { - static final int MAJOR_VERSION = Runtime.version().major(); +public class MultiReleaseJarProperties { + final static int BASE_VERSION = JarFile.baseVersion().major(); - final static int ROOTVERSION = 8; // magic number from knowledge of internals final static String userdir = System.getProperty("user.dir", "."); final static File multirelease = new File(userdir, "multi-release.jar"); protected int rtVersion; @@ -77,15 +76,15 @@ CreateMultiReleaseTestJars creator = new CreateMultiReleaseTestJars(); creator.compileEntries(); creator.buildMultiReleaseJar(); - - rtVersion = Integer.getInteger("jdk.util.jar.version", MAJOR_VERSION); + int RUNTIME_VERSION = Runtime.version().major(); + rtVersion = Integer.getInteger("jdk.util.jar.version", RUNTIME_VERSION); String mrprop = System.getProperty("jdk.util.jar.enableMultiRelease", ""); if (mrprop.equals("false")) { - rtVersion = ROOTVERSION; - } else if (rtVersion < ROOTVERSION) { - rtVersion = ROOTVERSION; - } else if (rtVersion > MAJOR_VERSION) { - rtVersion = MAJOR_VERSION; + rtVersion = BASE_VERSION; + } else if (rtVersion < BASE_VERSION) { + rtVersion = BASE_VERSION; + } else if (rtVersion > RUNTIME_VERSION) { + rtVersion = RUNTIME_VERSION; } force = mrprop.equals("force"); @@ -135,7 +134,7 @@ if (force) throw x; } } - invokeMethod(vcls, force ? rtVersion : ROOTVERSION); + invokeMethod(vcls, force ? rtVersion : BASE_VERSION); } } diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarSecurity.java --- a/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarSecurity.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarSecurity.java Wed Jul 05 21:58:29 2017 +0200 @@ -70,7 +70,7 @@ @Test public void testCertsAndSigners() throws IOException { - try (JarFile jf = new JarFile(signedmultirelease, true, ZipFile.OPEN_READ, JarFile.Release.RUNTIME)) { + try (JarFile jf = new JarFile(signedmultirelease, true, ZipFile.OPEN_READ, Runtime.version())) { CertsAndSigners vcas = new CertsAndSigners(jf, jf.getJarEntry("version/Version.class")); CertsAndSigners rcas = new CertsAndSigners(jf, jf.getJarEntry("META-INF/versions/" + MAJOR_VERSION + "/version/Version.class")); Assert.assertTrue(Arrays.equals(rcas.getCertificates(), vcas.getCertificates())); diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/test/java/util/logging/SystemLoggerConfigTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/java/util/logging/SystemLoggerConfigTest.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,423 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.UncheckedIOException; +import java.lang.ref.Reference; +import java.security.Permission; +import java.security.Policy; +import java.security.ProtectionDomain; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.Properties; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.atomic.AtomicLong; +import java.util.logging.Handler; +import java.util.logging.Level; +import java.util.logging.LogManager; +import java.util.logging.LogRecord; +import java.util.logging.Logger; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import sun.util.logging.PlatformLogger; + + +/** + * @test + * @bug 8159245 + * @summary Tests configuration of loggers. + * @modules java.logging/sun.util.logging.internal java.base/sun.util.logging + * @run main/othervm SystemLoggerConfigTest NOSECURITY + * @run main/othervm SystemLoggerConfigTest WITHSECURITY + * + * @author danielfuchs + */ +public class SystemLoggerConfigTest { + + static Logger createSystemLogger(String name) { + return sun.util.logging.internal.LoggingProviderImpl.getLogManagerAccess() + .demandLoggerFor(LogManager.getLogManager(), name, + Thread.class.getModule()); + } + + static PlatformLogger createPlatformLogger(String name) { + return PlatformLogger.getLogger(name); + } + + private static void assertFalse(boolean value, String msg) { + assertEquals(false, value, msg); + } + private static void assertEquals(boolean expected, boolean actual, String msg) { + if (expected != actual) { + throw new AssertionError(msg+": expected: " + expected + " actual: " + actual); + } + } + private static void assertEquals(int expected, int actual, String msg) { + if (expected != actual) { + throw new AssertionError(msg+": expected: " + expected + " actual: " + actual); + } + } + private static void assertEquals(long expected, long actual, String msg) { + if (expected != actual) { + throw new AssertionError(msg+": expected: " + expected + " actual: " + actual); + } + } + private static void assertEquals(Object expected, Object actual, String msg) { + if (!Objects.equals(expected, actual)) { + throw new AssertionError(msg+": expected: " + expected + " actual: " + actual); + } + } + + static class TestHandler extends Handler { + private final List records = new CopyOnWriteArrayList<>(); + public TestHandler() { + super(); + setLevel(Level.ALL); + } + + @Override + public void publish(LogRecord lr) { + records.add(lr); + } + + public List drain() { + List list = new ArrayList<>(records); + records.clear(); + return list; + } + + public void close() { + records.clear(); + } + + public void flush() { + } + + } + + public static class TestHandler1 extends TestHandler { + final static AtomicLong COUNT = new AtomicLong(); + public TestHandler1() { + COUNT.incrementAndGet(); + } + } + + public static class TestHandler2 extends TestHandler { + final static AtomicLong COUNT = new AtomicLong(); + public TestHandler2() { + COUNT.incrementAndGet(); + } + } + + static enum TestCase { WITHSECURITY, NOSECURITY } + + public static void main(String[] args) { + if (args == null || args.length == 0) { + args = Stream.of(TestCase.values()) + .map(String::valueOf) + .collect(Collectors.toList()) + .toArray(new String[0]); + } + Stream.of(args) + .map(TestCase::valueOf) + .forEach(SystemLoggerConfigTest::launch); + } + + public static void launch(TestCase test) { + switch(test) { + case WITHSECURITY: + Policy.setPolicy(new Policy() { + @Override + public boolean implies(ProtectionDomain domain, Permission permission) { + return true; + } + }); + System.setSecurityManager(new SecurityManager()); + break; + case NOSECURITY: + break; + default: + throw new InternalError("Unexpected enum: " + test); + } + try { + test(test.name(), ".1", ".child"); + test(test.name(), ".2", ""); + testUpdateConfiguration(test.name(), ".3"); + testSetPlatformLevel(test.name(), ".4"); + } catch (IOException io) { + throw new UncheckedIOException(io); + } + } + + public static void test(String name, String step, String ext) + throws IOException { + + System.out.println("\n*** Testing " + name + step + ext); + + final String systemName1a = "system.logger.one.a." + name + step + ext; + final String systemName1b = "system.logger.one.b." + name + step + ext; + final String appName1a = "system.logger.one.a." + name + step; + final String appName1b = "system.logger.one.b." + name + step; + final String msg1a = "logger name: " + systemName1a; + final String msg1b = "logger name: " + systemName1b; + final String systemName2 = "system.logger.two." + name + step + ext; + final String appName2 = "system.logger.two." + name + step; + final String msg2 = "logger name: " + systemName2; + final String systemName3 = "system.logger.three." + name + step + ext; + final String appName3 = "system.logger.three." + name + step; + final String msg3 = "logger name: " + systemName3; + List records; + + System.out.println("\n[Case #1] Creating platform logger: " + systemName1a); + PlatformLogger system1a = createPlatformLogger(systemName1a); + System.out.println(" Creating platform logger: " + systemName1b); + PlatformLogger system1b = createPlatformLogger(systemName1b); + System.out.println(" Adding handler on root logger..."); + TestHandler test1 = new TestHandler(); + Logger.getLogger("").addHandler(test1); + + System.out.println(" Creating and configuring app logger: " + appName1a + + ", " + appName1b); + Logger app1a = Logger.getLogger(appName1a); + app1a.setLevel(Level.INFO); + Logger app1b = Logger.getLogger(appName1b); + app1b.setLevel(Level.INFO); + assertFalse(system1a.isLoggable(PlatformLogger.Level.FINEST), + "Unexpected level for " + system1a); + System.out.println(" Configuring root logger..."); + Logger.getLogger("").setLevel(Level.FINEST); + System.out.println(" Logging through system logger: " + systemName1a); + system1a.finest(msg1a); + Reference.reachabilityFence(app1a); + records = test1.drain(); + assertEquals(0, records.size(), "Unexpected size for " + records.toString()); + System.out.println(" Logging through system logger: " + systemName1b); + system1b.finest(msg1b); + Reference.reachabilityFence(app1b); + records = test1.drain(); + assertEquals(0, records.size(), "Unexpected size for " + records.toString()); + Logger.getLogger("system.logger.one.a").finest("system.logger.one.a"); + records = test1.drain(); + assertEquals("system.logger.one.a", records.get(0).getMessage(), "Unexpected message: "); + Logger.getLogger("").setLevel(Level.INFO); + Logger.getLogger("system.logger.one.a").finest("system.logger.one.a"); + records = test1.drain(); + assertEquals(0, records.size(), "Unexpected size for " + records.toString()); + + Reference.reachabilityFence(system1a); + Reference.reachabilityFence(system1b); + + System.out.println("\n[Case #2] Creating system logger: " + systemName2); + Logger system2 = createSystemLogger(systemName2); + System.out.println(" Creating app logger: " + appName2); + Logger app2 = Logger.getLogger(appName2); + System.out.println(" Configuring app logger..."); + TestHandler test2 = new TestHandler(); + app2.setLevel(Level.ALL); + app2.setUseParentHandlers(false); + app2.addHandler(test2); + System.out.println(" Logging through system logger: " + systemName2); + system2.finest(msg2); + records = test2.drain(); + assertEquals(1, records.size(), "Unexpected size for " + records.toString()); + assertEquals(msg2, records.get(0).getMessage(), "Unexpected message: "); + records = test1.drain(); + assertEquals(0, records.size(), "Unexpected size for " + records.toString()); + + Reference.reachabilityFence(app2); + Reference.reachabilityFence(system2); + + System.out.println("\n[Case #3] Creating app logger: " + appName3); + Logger app3 = Logger.getLogger(appName3); + System.out.println(" Configuring app logger..."); + TestHandler test3 = new TestHandler(); + app3.setLevel(Level.ALL); + app3.setUseParentHandlers(false); + app3.addHandler(test3); + System.out.println(" Creating system logger: " + systemName3); + Logger system3 = createSystemLogger(systemName3); + System.out.println(" Logging through system logger: " + systemName3); + system3.finest(msg3); + records = test3.drain(); + assertEquals(1, records.size(), "Unexpected size for " + records.toString()); + assertEquals(msg3, records.get(0).getMessage(), "Unexpected message: "); + records = test1.drain(); + assertEquals(0, records.size(), "Unexpected size for " + records.toString()); + + Reference.reachabilityFence(app3); + Reference.reachabilityFence(system3); + System.gc(); + + } + + @SuppressWarnings("deprecated") + static void setPlatformLevel(PlatformLogger logger, PlatformLogger.Level level) { + logger.setLevel(level); + } + + public static void testSetPlatformLevel(String name, String step) { + System.out.println("\n*** Testing PlatformLogger.setLevel " + name + step); + + System.out.println("\n[Case #5] Creating app logger: " + name + step); + // this should return named logger in the global context + Logger foo = Logger.getLogger(name + step); + foo.setLevel(Level.FINE); + + System.out.println(" Creating platform logger: " + name + step); + PlatformLogger foo1 = PlatformLogger.getLogger(name + step); + System.out.println(" Configuring platform logger..."); + setPlatformLevel(foo1, PlatformLogger.Level.INFO); + + System.out.println(" Checking levels..."); + assertEquals(foo.getName(), foo1.getName(), "Bad logger names"); + // both logger share the same config + assertEquals(foo.getLevel(), Level.INFO, "Bad level for user logger"); + assertEquals(foo1.level(), PlatformLogger.Level.INFO, + "Bad level for platform logger"); + + } + + static void updateConfiguration(Properties props) throws IOException { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + props.store(baos, ""); + ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); + LogManager.getLogManager().updateConfiguration(bais, (k) -> (o,n) -> n != null ? n : o); + } + + static void readConfiguration(Properties props) throws IOException { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + props.store(baos, ""); + ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); + LogManager.getLogManager().readConfiguration(bais); + } + + // Tests that though two loggers exist, only one handler is created for the + // pair when reading configuration. + // + public static void testUpdateConfiguration(String name, String step) throws IOException { + + System.out.println("\n*** Testing LogManager.updateConfiguration " + name + step); + + final String name1a = "system.logger.one.a." + name + step; + final String name1b = "system.logger.one.b." + name + step; + final String msg1a = "logger name: " + name1a; + final String msg1b = "logger name: " + name1b; + List records; + + TestHandler1.COUNT.set(0); + TestHandler2.COUNT.set(0); + Properties props = new Properties(); + props.setProperty(name1a+".handlers", TestHandler1.class.getName()); + updateConfiguration(props); + assertEquals(0, TestHandler1.COUNT.get(), "Bad instance count for " + + TestHandler1.class.getName()); + assertEquals(0, TestHandler2.COUNT.get(), "Bad instance count for " + + TestHandler2.class.getName()); + + System.out.println("\n[Case #4] Creating app logger: " + name1a); + Logger app1a = Logger.getLogger(name1a); + System.out.println(" Configuring app logger..."); + TestHandler test1 = new TestHandler(); + app1a.setLevel(Level.ALL); + app1a.setUseParentHandlers(false); + app1a.addHandler(test1); + assertEquals(1, TestHandler1.COUNT.get(), "Bad instance count for " + + TestHandler1.class.getName()); + assertEquals(0, TestHandler2.COUNT.get(), "Bad instance count for " + + TestHandler2.class.getName()); + + System.out.println(" Creating system logger: " + name1a); + Logger system1a = createSystemLogger(name1a); + assertEquals(Level.ALL, system1a.getLevel(), "Bad level for system logger " + name1a); + System.out.println(" Logging through system logger: " + name1a); + system1a.finest(msg1a); + records = test1.drain(); + assertEquals(1, records.size(), "Unexpected size for " + records.toString()); + assertEquals(msg1a, records.get(0).getMessage(), "Unexpected message: "); + records = test1.drain(); + assertEquals(0, records.size(), "Unexpected size for " + records.toString()); + + assertEquals(1, TestHandler1.COUNT.get(), "Bad instance count for " + + TestHandler1.class.getName()); + assertEquals(0, TestHandler2.COUNT.get(), "Bad instance count for " + + TestHandler2.class.getName()); + + props.setProperty(name1a+".handlers", TestHandler2.class.getName()); + updateConfiguration(props); + + assertEquals(1, TestHandler1.COUNT.get(), "Bad instance count for " + + TestHandler1.class.getName()); + assertEquals(1, TestHandler2.COUNT.get(), "Bad instance count for " + + TestHandler2.class.getName()); + + updateConfiguration(props); + + assertEquals(1, TestHandler1.COUNT.get(), "Bad instance count for " + + TestHandler1.class.getName()); + assertEquals(1, TestHandler2.COUNT.get(), "Bad instance count for " + + TestHandler2.class.getName()); + + readConfiguration(props); + + assertEquals(1, TestHandler1.COUNT.get(), "Bad instance count for " + + TestHandler1.class.getName()); + // readConfiguration reset handlers but does not recreate them + assertEquals(1, TestHandler2.COUNT.get(), "Bad instance count for " + + TestHandler2.class.getName()); + + updateConfiguration(props); + + assertEquals(1, TestHandler1.COUNT.get(), "Bad instance count for " + + TestHandler1.class.getName()); + assertEquals(1, TestHandler2.COUNT.get(), "Bad instance count for " + + TestHandler2.class.getName()); + + LogManager.getLogManager().reset(); + updateConfiguration(props); + + assertEquals(1, TestHandler1.COUNT.get(), "Bad instance count for " + + TestHandler1.class.getName()); + assertEquals(2, TestHandler2.COUNT.get(), "Bad instance count for " + + TestHandler2.class.getName()); + + props.setProperty(name1a+".handlers", + TestHandler2.class.getName() + "," + TestHandler1.class.getName()); + updateConfiguration(props); + + assertEquals(2, TestHandler1.COUNT.get(), "Bad instance count for " + + TestHandler1.class.getName()); + assertEquals(3, TestHandler2.COUNT.get(), "Bad instance count for " + + TestHandler2.class.getName()); + + Reference.reachabilityFence(app1a); + Reference.reachabilityFence(system1a); + + LogManager.getLogManager().readConfiguration(); + System.gc(); + } + + + +} diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/test/java/util/zip/InflaterInputStream/TestAvailable.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/java/util/zip/InflaterInputStream/TestAvailable.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 + * @library /lib/testlibrary/ + * @build jdk.testlibrary.* + * @run main TestAvailable + * @bug 7031075 8161426 + * @summary Make sure that available() method behaves as expected. + * @key randomness + */ + +import java.io.*; +import java.util.Random; +import java.util.zip.*; +import jdk.testlibrary.RandomFactory; + +public class TestAvailable { + + public static void main(String args[]) throws Throwable { + Random r = RandomFactory.getRandom(); + for (int n = 0; n < 10; n++) { + byte[] src = new byte[r.nextInt(100) + 1]; + r.nextBytes(src); + // test InflaterInputStream + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + try (DeflaterOutputStream dos = new DeflaterOutputStream(baos)) { + dos.write(src); + } + try (InflaterInputStream iis = new InflaterInputStream( + new ByteArrayInputStream(baos.toByteArray()))) { + test(iis, src); + } + + // test GZIPInputStream + baos = new ByteArrayOutputStream(); + try (GZIPOutputStream dos = new GZIPOutputStream(baos)) { + dos.write(src); + } + try (GZIPInputStream gis = new GZIPInputStream( + new ByteArrayInputStream(baos.toByteArray()))) { + test(gis, src); + } + } + } + + private static void test(InputStream is, byte[] expected) throws IOException { + int cnt = 0; + do { + int available = is.available(); + if (available > 0) { + int b = is.read(); + if (b == -1) { + throw new RuntimeException("available() > 0, read() == -1 : failed!"); + } + if (expected[cnt++] != (byte)b) { + throw new RuntimeException("read() : failed!"); + } + } else if (available == 0) { + if (is.read() != -1) { + throw new RuntimeException("available() == 0, read() != -1 : failed!"); + } + break; + } else { + throw new RuntimeException("available() < 0 : failed!"); + } + } while (true); + if (cnt != expected.length) { + throw new RuntimeException("read : failed!"); + } + } + +} diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/test/sun/net/www/protocol/http/NULLTargetInfoTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/sun/net/www/protocol/http/NULLTargetInfoTest.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 8151788 + * @summary NullPointerException from ntlm.Client.type3 + * @modules java.base/com.sun.security.ntlm + * @run main NULLTargetInfoTest + */ +import com.sun.security.ntlm.Client; + +public class NULLTargetInfoTest { + + public static void main(String[] args) throws Exception { + Client c = new Client(null, "host", "user", "domain", "pass".toCharArray()); + c.type1(); + // this input does have the 0x800000 bit(NTLMSSP_NEGOTIATE_TARGET_INFO) set + // but after offset 40 all eight bytes are all zero which means there is no + // security buffer for target info. + byte[] type2 = hex( + "4E 54 4C 4D 53 53 50 00 02 00 00 00 00 00 00 00" + + "00 00 00 00 05 82 89 00 0B 87 81 B6 2D 6E 8B C1" + + "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"); + byte[] nonce = new byte[10]; + c.type3(type2, nonce); + } + + private static byte[] hex(String str) { + str = str.replaceAll("\\s", ""); + byte[] response = new byte[str.length() / 2]; + int index = 0; + for (int i = 0; i < str.length(); i += 2) { + response[index++] = Integer.valueOf(str.substring(i, i + 2), 16).byteValue(); + } + return response; + } +} diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/test/sun/net/www/protocol/jar/MultiReleaseJarURLConnection.java --- a/jdk/test/sun/net/www/protocol/jar/MultiReleaseJarURLConnection.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/test/sun/net/www/protocol/jar/MultiReleaseJarURLConnection.java Wed Jul 05 21:58:29 2017 +0200 @@ -132,12 +132,12 @@ URL rootUrl = new URL(urlFile); JarURLConnection juc = (JarURLConnection)rootUrl.openConnection(); JarFile rootJar = juc.getJarFile(); - JarFile.Release root = rootJar.getVersion(); + Runtime.Version root = rootJar.getVersion(); URL runtimeUrl = new URL(urlFile + "#runtime"); juc = (JarURLConnection)runtimeUrl.openConnection(); JarFile runtimeJar = juc.getJarFile(); - JarFile.Release runtime = runtimeJar.getVersion(); + Runtime.Version runtime = runtimeJar.getVersion(); if (style.equals("unversioned")) { Assert.assertEquals(root, runtime); } else { diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/test/sun/security/pkcs11/fips/ImportKeyStore.java --- a/jdk/test/sun/security/pkcs11/fips/ImportKeyStore.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/test/sun/security/pkcs11/fips/ImportKeyStore.java Wed Jul 05 21:58:29 2017 +0200 @@ -37,7 +37,7 @@ modutil -create -dbdir . modutil -changepw "NSS Internal PKCS #11 Module" -dbdir . -$JHOME/bin/keytool -list -storetype PKCS11 -providerclass sun.security.pkcs11.SunPKCS11 -providerarg "--name=NSS\nnssSecmodDirectory=." -v -storepass test12 +$JHOME/bin/keytool -list -storetype PKCS11 -addprovider SunPKCS11 -providerarg "--name=NSS\nnssSecmodDirectory=." -v -storepass test12 modutil -fips true -dbdir . diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/test/sun/security/tools/jarsigner/AltProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/sun/security/tools/jarsigner/AltProvider.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,161 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 4906940 8130302 + * @summary -providerPath, -providerClass, -addprovider, and -providerArg + * @library /lib/testlibrary /test/lib/share/classes + * @modules java.base/jdk.internal.misc + */ + +import jdk.test.lib.JDKToolLauncher; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; +import jdk.testlibrary.JarUtils; + +import java.nio.file.*; + +public class AltProvider { + + private static final String TEST_SRC = + Paths.get(System.getProperty("test.src")).toString(); + + private static final Path MOD_SRC_DIR = Paths.get(TEST_SRC, "alt"); + private static final Path MOD_DEST_DIR = Paths.get("mods"); + + private static final String ktCommand = "-keystore x.jks " + + "-storepass changeit -storetype dummyks -list -debug"; + + private static final String jsCommand = "-keystore x.jks " + + "-storepass changeit -storetype dummyks -debug x.jar x"; + + public static void main(String[] args) throws Throwable { + + // Compile the provider + CompilerUtils.compile( + MOD_SRC_DIR, MOD_DEST_DIR, + "-modulesourcepath", + MOD_SRC_DIR.toString()); + + // Create a keystore + tool("keytool", "-keystore x.jks -storetype jks -genkeypair" + + " -storepass changeit -keypass changeit -alias x -dname CN=X") + .shouldHaveExitValue(0); + + // Create a jar file + JarUtils.createJar("x.jar", "x.jks"); + + // Test starts here + + // Without new provider + testBoth("", 1, "DUMMYKS not found"); + + // legacy use (-providerPath only supported by keytool) + testKeytool("-providerPath mods/test.dummy " + + "-providerClass org.test.dummy.DummyProvider -providerArg full", + 0, "loadProviderByClass: org.test.dummy.DummyProvider"); + + // legacy, on classpath + testBoth("-J-cp -Jmods/test.dummy " + + "-providerClass org.test.dummy.DummyProvider -providerArg full", + 0, "loadProviderByClass: org.test.dummy.DummyProvider"); + + // Wrong name + testBoth("-J-cp -Jmods/test.dummy " + + "-providerClass org.test.dummy.Dummy -providerArg full", + 1, "Provider \"org.test.dummy.Dummy\" not found"); + + // Not a provider name + testBoth("-J-cp -Jmods/test.dummy " + + "-providerClass java.lang.Object -providerArg full", + 1, "java.lang.Object not a provider"); + + // without arg + testBoth("-J-cp -Jmods/test.dummy " + + "-providerClass org.test.dummy.DummyProvider", + 1, "DUMMYKS not found"); + + // old -provider still works + testBoth("-J-cp -Jmods/test.dummy " + + "-provider org.test.dummy.DummyProvider -providerArg full", + 0, "loadProviderByClass: org.test.dummy.DummyProvider"); + + // name in a module + testBoth("-J-mp -Jmods " + + "-addprovider Dummy -providerArg full", + 0, "loadProviderByName: Dummy"); + + // -providerClass does not work + testBoth("-J-mp -Jmods " + + "-providerClass org.test.dummy.DummyProvider -providerArg full", + 1, "Provider \"org.test.dummy.DummyProvider\" not found"); + + // -addprovider with class does not work + testBoth("-J-mp -Jmods " + + "-addprovider org.test.dummy.DummyProvider -providerArg full", + 1, "Provider named \"org.test.dummy.DummyProvider\" not found"); + + // -addprovider without arg does not work + testBoth("-J-mp -Jmods " + + "-addprovider Dummy", + 1, "DUMMYKS not found"); + } + + // Test both tools with the same extra options + private static void testBoth(String args, int exitValue, String contains) + throws Throwable { + testKeytool(args, exitValue, contains); + testJarsigner(args, exitValue, contains); + } + + // Test keytool with extra options and check exitValue and output + private static void testKeytool(String args, int exitValue, String contains) + throws Throwable { + tool("keytool", ktCommand + " " + args) + .shouldHaveExitValue(exitValue) + .shouldContain(contains); + } + + // Test jarsigner with extra options and check exitValue and output + private static void testJarsigner(String args, int exitValue, String contains) + throws Throwable { + tool("jarsigner", jsCommand + " " + args) + .shouldHaveExitValue(exitValue) + .shouldContain(contains); + } + + // Launch a tool with args (space separated string) + private static OutputAnalyzer tool(String tool, String args) + throws Throwable { + JDKToolLauncher l = JDKToolLauncher.createUsingTestJDK(tool); + for (String a: args.split("\\s+")) { + if (a.startsWith("-J")) { + l.addVMArg(a.substring(2)); + } else { + l.addToolArg(a); + } + } + return ProcessTools.executeCommand(l.getCommand()); + } +} diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/test/sun/security/tools/jarsigner/alt/test.dummy/module-info.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/sun/security/tools/jarsigner/alt/test.dummy/module-info.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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. + */ + +module test.dummy { + provides java.security.Provider with org.test.dummy.DummyProvider; +} diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/test/sun/security/tools/jarsigner/alt/test.dummy/org/test/dummy/DummyProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/sun/security/tools/jarsigner/alt/test.dummy/org/test/dummy/DummyProvider.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2004, 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 org.test.dummy; + +import java.security.*; + +public class DummyProvider extends Provider { + public DummyProvider() { + super("Dummy", 0.1, "Dummy Provider with nothing"); + } + + @Override + public Provider configure(String configArg) { + return new DummyProvider(configArg); + } + + private DummyProvider(String arg) { + super("Dummy", 0.2, "Dummy Provider with " + arg); + // + // KeyStore + // + put("KeyStore.DummyKS", "sun.security.provider.JavaKeyStore$JKS"); + + // + // Signature engines + // + put("Signature.SHA1withDSA", + "sun.security.provider.DSA$SHA1withDSA"); + put("Alg.Alias.Signature.DSA", "SHA1withDSA"); + + // + // Key Pair Generator engines + // + put("KeyPairGenerator.DSA", + "sun.security.provider.DSAKeyPairGenerator"); + + // + // Digest engines + // + put("MessageDigest.SHA", "sun.security.provider.SHA"); + put("Alg.Alias.MessageDigest.SHA1", "SHA"); + + // + // Algorithm Parameter Generator engines + // + put("AlgorithmParameterGenerator.DSA", + "sun.security.provider.DSAParameterGenerator"); + + // + // Algorithm Parameter engines + // + put("AlgorithmParameters.DSA", + "sun.security.provider.DSAParameters"); + + // + // Key factories + // + put("KeyFactory.DSA", "sun.security.provider.DSAKeyFactory"); + + // + // Certificate factories + // + put("CertificateFactory.X.509", + "sun.security.provider.X509Factory"); + put("Alg.Alias.CertificateFactory.X509", "X.509"); + } +} diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/test/sun/security/tools/keytool/AltProviderPath.sh --- a/jdk/test/sun/security/tools/keytool/AltProviderPath.sh Wed Jul 05 21:57:12 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,122 +0,0 @@ -# -# Copyright (c) 2004, 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 4906940 -# @summary Add -providerPath option for keytool allowing one to specify -# an additional classpath to search for providers. -# @author Andrew Fan -# -# @run build DummyProvider -# @run shell AltProviderPath.sh -# set a few environment variables so that the shell-script can run stand-alone -# in the source directory -if [ "${TESTSRC}" = "" ] ; then - TESTSRC="." -fi -if [ "${TESTCLASSES}" = "" ] ; then - TESTCLASSES="." -fi -if [ "${TESTJAVA}" = "" ] ; then - echo "TESTJAVA not set. Test cannot execute." - echo "FAILED!!!" - exit 1 -fi - -# set platform-dependent variables -OS=`uname -s` -case "$OS" in - SunOS | Linux | Darwin | AIX ) - NULL=/dev/null - PS=":" - FS="/" - ;; - CYGWIN* ) - NULL=/dev/null - PS=";" - FS="/" - ;; - Windows_* ) - NULL=NUL - PS=";" - FS="\\" - ;; - * ) - echo "Unrecognized operating system!" - exit 1; - ;; -esac - -# the test code -#genkey -${TESTJAVA}${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -genkey -v -alias dummyTestCA \ - -keyalg "RSA" -keysize 1024 -sigalg "ShA1WithRSA" \ - -dname "cn=Dummy Test CA, ou=JSN, o=JavaSoft, c=US" -validity 3650 \ - -keypass storepass -keystore keystoreCA.dks -storepass storepass \ - -storetype "dummyks" -provider "org.test.dummy.DummyProvider" \ - -providerPath ${TESTCLASSES} - -if [ $? -ne 0 ]; then - exit 1 -fi - -#Change keystore password -${TESTJAVA}${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storepasswd -new storepass2 \ - -keystore keystoreCA.dks -storetype "dummyks" -storepass storepass \ - -provider "org.test.dummy.DummyProvider" -providerPath ${TESTCLASSES} - -if [ $? -ne 0 ]; then - exit 1 -fi - - -#Change keystore key password -${TESTJAVA}${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -keypasswd -alias "dummyTestCA" \ - -keypass storepass -new keypass -keystore keystoreCA.dks \ - -storetype "dummyks" -storepass storepass2 \ - -provider "org.test.dummy.DummyProvider" -providerPath ${TESTCLASSES} - -if [ $? -ne 0 ]; then - exit 1 -fi - -#Export certificate -${TESTJAVA}${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -v -export -rfc -alias "dummyTestCA" \ - -file "dummyTestCA.der" -keystore keystoreCA.dks -storetype "dummyks" \ - -storepass storepass2 -provider "org.test.dummy.DummyProvider" \ - -providerPath ${TESTCLASSES} - -if [ $? -ne 0 ]; then - exit 1 -fi - -#list keystore -${TESTJAVA}${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -v -list -keystore keystoreCA.dks \ - -storetype "dummyks" -storepass storepass2 \ - -provider "org.test.dummy.DummyProvider" -providerPath ${TESTCLASSES} - -if [ $? -ne 0 ]; then - exit 1 -fi - -exit 0 diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/test/sun/security/tools/keytool/DummyProvider.java --- a/jdk/test/sun/security/tools/keytool/DummyProvider.java Wed Jul 05 21:57:12 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2004, 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. - */ - -/* - * - * - * @bug 4906490 - * @summary Dummy security service provider. - * It is cited by the AltProviderPath.sh script. - */ -package org.test.dummy; - -import java.util.*; -import java.security.*; - -public class DummyProvider extends Provider { - public DummyProvider() { - super("Dummy", 0.1, "Dummy Provider"); - - // - // KeyStore - // - put("KeyStore.DummyKS", "sun.security.provider.JavaKeyStore$JKS"); - - // - // Signature engines - // - put("Signature.SHA1withDSA", - "sun.security.provider.DSA$SHA1withDSA"); - put("Alg.Alias.Signature.DSA", "SHA1withDSA"); - - // - // Key Pair Generator engines - // - put("KeyPairGenerator.DSA", - "sun.security.provider.DSAKeyPairGenerator"); - - // - // Digest engines - // - put("MessageDigest.SHA", "sun.security.provider.SHA"); - put("Alg.Alias.MessageDigest.SHA1", "SHA"); - - // - // Algorithm Parameter Generator engines - // - put("AlgorithmParameterGenerator.DSA", - "sun.security.provider.DSAParameterGenerator"); - - // - // Algorithm Parameter engines - // - put("AlgorithmParameters.DSA", - "sun.security.provider.DSAParameters"); - - // - // Key factories - // - put("KeyFactory.DSA", "sun.security.provider.DSAKeyFactory"); - - // - // Certificate factories - // - put("CertificateFactory.X.509", - "sun.security.provider.X509Factory"); - put("Alg.Alias.CertificateFactory.X509", "X.509"); - } -} diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/test/sun/security/tools/keytool/KeyToolTest.java --- a/jdk/test/sun/security/tools/keytool/KeyToolTest.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/test/sun/security/tools/keytool/KeyToolTest.java Wed Jul 05 21:58:29 2017 +0200 @@ -82,8 +82,9 @@ static final String NSS_P11_ARG = "-keystore NONE -storetype PKCS11 -providerName SunPKCS11-nss " + - "-providerClass sun.security.pkcs11.SunPKCS11 " + + "-addprovider SunPKCS11 " + "-providerArg p11-nss.txt "; + // Use -providerClass here, to confirm it still works for SunPKCS11. static final String NSS_SRC_P11_ARG = "-srckeystore NONE -srcstoretype PKCS11 " + "-srcproviderName SunPKCS11-nss " + @@ -91,12 +92,12 @@ "-providerArg p11-nss.txt "; static final String NZZ_P11_ARG = "-keystore NONE -storetype PKCS11 -providerName SunPKCS11-nzz " + - "-providerClass sun.security.pkcs11.SunPKCS11 " + + "-addprovider SunPKCS11 " + "-providerArg p11-nzz.txt "; static final String NZZ_SRC_P11_ARG = "-srckeystore NONE -srcstoretype PKCS11 " + "-srcproviderName SunPKCS11-nzz " + - "-providerClass sun.security.pkcs11.SunPKCS11 " + + "-addprovider SunPKCS11 " + "-providerArg p11-nzz.txt "; static final String SUN_P11_ARG = "-keystore NONE -storetype PKCS11 "; static final String SUN_SRC_P11_ARG = @@ -1715,9 +1716,9 @@ // 14. keytool -printcert -file cert testOK("", "-printcert -file cert -keystore x.jks -storetype JKS"); remove("cert"); - // 15. keytool -list -storepass password -provider sun.security.provider.Sun + // 15. keytool -list -storepass password -addprovider SUN testOK("", "-list -storepass password" + - " -provider sun.security.provider.Sun" + + " -addprovider SUN" + " -keystore x.jks -storetype JKS"); //Error tests diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/test/sun/security/tools/keytool/i18n.html --- a/jdk/test/sun/security/tools/keytool/i18n.html Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/test/sun/security/tools/keytool/i18n.html Wed Jul 05 21:58:29 2017 +0200 @@ -50,7 +50,7 @@

  • keytool -import -v -file /tmp/cert -storepass password Check error (Certificate reply and cert are the same)
  • keytool -printcert -file /tmp/cert -
  • keytool -list -storepass password -provider sun.security.provider.Sun +
  • keytool -list -storepass password -addprovider SUN Error tests @@ -93,19 +93,19 @@
    1. sccs edit cert8.db key3.db -
    2. keytool -keystore NONE -storepass test12 -storetype PKCS11 -providerName SunPKCS11-nss -providerClass sun.security.pkcs11.SunPKCS11 -providerArg p11-nss.txt -genkey -alias genkey -dname cn=genkey -keysize 512 -keyalg rsa -
    3. keytool -keystore NONE -storepass test12 -storetype PKCS11 -providerName SunPKCS11-nss -providerClass sun.security.pkcs11.SunPKCS11 -providerArg p11-nss.txt -list -
    4. keytool -keystore NONE -storepass test12 -storetype PKCS11 -providerName SunPKCS11-nss -providerClass sun.security.pkcs11.SunPKCS11 -providerArg p11-nss.txt -list -alias genkey -
    5. keytool -keystore NONE -storepass test12 -storetype PKCS11 -providerName SunPKCS11-nss -providerClass sun.security.pkcs11.SunPKCS11 -providerArg p11-nss.txt -certreq -alias genkey -file genkey.certreq -
    6. keytool -keystore NONE -storepass test12 -storetype PKCS11 -providerName SunPKCS11-nss -providerClass sun.security.pkcs11.SunPKCS11 -providerArg p11-nss.txt -export -alias genkey -file genkey.cert +
    7. keytool -keystore NONE -storepass test12 -storetype PKCS11 -providerName SunPKCS11-nss -addprovider SunPKCS11 -providerArg p11-nss.txt -genkey -alias genkey -dname cn=genkey -keysize 512 -keyalg rsa +
    8. keytool -keystore NONE -storepass test12 -storetype PKCS11 -providerName SunPKCS11-nss -addprovider SunPKCS11 -providerArg p11-nss.txt -list +
    9. keytool -keystore NONE -storepass test12 -storetype PKCS11 -providerName SunPKCS11-nss -addprovider SunPKCS11 -providerArg p11-nss.txt -list -alias genkey +
    10. keytool -keystore NONE -storepass test12 -storetype PKCS11 -providerName SunPKCS11-nss -addprovider SunPKCS11 -providerArg p11-nss.txt -certreq -alias genkey -file genkey.certreq +
    11. keytool -keystore NONE -storepass test12 -storetype PKCS11 -providerName SunPKCS11-nss -addprovider SunPKCS11 -providerArg p11-nss.txt -export -alias genkey -file genkey.cert
    12. keytool -printcert -file genkey.cert -
    13. keytool -keystore NONE -storepass test12 -storetype PKCS11 -providerName SunPKCS11-nss -providerClass sun.security.pkcs11.SunPKCS11 -providerArg p11-nss.txt -selfcert -alias genkey -dname cn=selfCert +
    14. keytool -keystore NONE -storepass test12 -storetype PKCS11 -providerName SunPKCS11-nss -addprovider SunPKCS11 -providerArg p11-nss.txt -selfcert -alias genkey -dname cn=selfCert -
    15. keytool -keystore NONE -storepass test12 -storetype PKCS11 -providerName SunPKCS11-nss -providerClass sun.security.pkcs11.SunPKCS11 -providerArg p11-nss.txt -list -alias genkey -v +
    16. keytool -keystore NONE -storepass test12 -storetype PKCS11 -providerName SunPKCS11-nss -addprovider SunPKCS11 -providerArg p11-nss.txt -list -alias genkey -v (check that cert subject DN is [cn=selfCert]) -
    17. keytool -keystore NONE -storepass test12 -storetype PKCS11 -providerName SunPKCS11-nss -providerClass sun.security.pkcs11.SunPKCS11 -providerArg p11-nss.txt -delete -alias genkey -
    18. keytool -keystore NONE -storepass test12 -storetype PKCS11 -providerName SunPKCS11-nss -providerClass sun.security.pkcs11.SunPKCS11 -providerArg p11-nss.txt -list +
    19. keytool -keystore NONE -storepass test12 -storetype PKCS11 -providerName SunPKCS11-nss -addprovider SunPKCS11 -providerArg p11-nss.txt -delete -alias genkey +
    20. keytool -keystore NONE -storepass test12 -storetype PKCS11 -providerName SunPKCS11-nss -addprovider SunPKCS11 -providerArg p11-nss.txt -list (check for empty database listing)
    21. sccs unedit cert8.db key3.db diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/test/sun/text/resources/JavaTimeSupplementaryTest.java --- a/jdk/test/sun/text/resources/JavaTimeSupplementaryTest.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/test/sun/text/resources/JavaTimeSupplementaryTest.java Wed Jul 05 21:58:29 2017 +0200 @@ -23,7 +23,7 @@ /* * @test - * @bug 8159943 + * @bug 8159943 8154797 * @modules java.base/sun.util.locale.provider * java.base/sun.util.resources * jdk.localedata @@ -65,6 +65,7 @@ "field.", "islamic.", "roc.", + "timezone." }; // All available locales for the COMPAT FormatData resource bundles diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/test/tools/jar/multiRelease/Basic.java --- a/jdk/test/tools/jar/multiRelease/Basic.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/test/tools/jar/multiRelease/Basic.java Wed Jul 05 21:58:29 2017 +0200 @@ -220,7 +220,7 @@ private void checkMultiRelease(String jarFile, boolean expected) throws IOException { try (JarFile jf = new JarFile(new File(jarFile), true, ZipFile.OPEN_READ, - JarFile.Release.RUNTIME)) { + JarFile.runtimeVersion())) { assertEquals(jf.isMultiRelease(), expected); } } diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/test/tools/jlink/JLinkPluginsTest.java --- a/jdk/test/tools/jlink/JLinkPluginsTest.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/test/tools/jlink/JLinkPluginsTest.java Wed Jul 05 21:58:29 2017 +0200 @@ -75,5 +75,13 @@ Path imageDir = helper.generateDefaultImage(userOptions, moduleName).assertSuccess(); helper.checkImage(imageDir, moduleName, res, null); } + { + // Optimize Class.forName + String[] userOptions = {"--class-for-name"}; + String moduleName = "classforname"; + helper.generateDefaultJModule(moduleName, "composite2"); + Path imageDir = helper.generateDefaultImage(userOptions, moduleName).assertSuccess(); + helper.checkImage(imageDir, moduleName, null, null); + } } } diff -r 5a66e43d8cbd -r 5bf88dce615f jdk/test/tools/launcher/Arrrghs.java --- a/jdk/test/tools/launcher/Arrrghs.java Wed Jul 05 21:57:12 2017 +0200 +++ b/jdk/test/tools/launcher/Arrrghs.java Wed Jul 05 21:58:29 2017 +0200 @@ -24,7 +24,7 @@ /** * @test * @bug 5030233 6214916 6356475 6571029 6684582 6742159 4459600 6758881 6753938 - * 6894719 6968053 7151434 7146424 8007333 8077822 8143640 + * 6894719 6968053 7151434 7146424 8007333 8077822 8143640 8132379 * @summary Argument parsing validation. * @compile -XDignore.symbol.file Arrrghs.java * @run main/othervm Arrrghs @@ -383,6 +383,12 @@ checkArgumentWildcard("empty\\*?", "empty\\*?"); checkArgumentWildcard("empty\\?*", "empty\\?*"); + // 8132379: java should not filter out -J options for application + String[] args = { "-J-one", "-Jtwo", "lib\\???.java", "-J-Dsomething", + "a", "-J-Dlast.arg" }; + String[] expected = { "-J-one", "-Jtwo", "lib\\Fbo.java", + "lib\\Foo.java", "-J-Dsomething", "a", "-J-Dlast.arg" }; + checkArgumentWildcard(args, expected); } void doArgumentCheck(String inArgs, String... expArgs) { diff -r 5a66e43d8cbd -r 5bf88dce615f langtools/.hgtags --- a/langtools/.hgtags Wed Jul 05 21:57:12 2017 +0200 +++ b/langtools/.hgtags Wed Jul 05 21:58:29 2017 +0200 @@ -369,3 +369,4 @@ 26aa3caa778eab1c931910149c414783ee83bce7 jdk-9+124 2d65e127e93d5ff0df61bf78e57d7f46a2f1edeb jdk-9+125 ea4eea2997b9e2f26cd7965839921710ff4065c8 jdk-9+126 +a42768b48cb0c5af9063e12093975baeeca3b5fa jdk-9+127 diff -r 5a66e43d8cbd -r 5bf88dce615f langtools/make/src/classes/build/tools/listjdkinternals/ListJDKInternals.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/make/src/classes/build/tools/listjdkinternals/ListJDKInternals.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,195 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 build.tools.listjdkinternals; + +import java.io.IOException; +import java.io.OutputStream; +import java.io.PrintStream; +import java.io.UncheckedIOException; +import java.lang.module.ModuleDescriptor; +import java.lang.module.ModuleFinder; +import java.lang.module.ModuleReference; +import java.net.URI; +import java.nio.file.FileSystem; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.attribute.BasicFileAttributes; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import java.util.stream.Collectors; + +/** + * Run this tool to generate the JDK internal APIs in the previous releases + * including platform-specific internal APIs. + */ +public class ListJDKInternals { + // Filter non-interesting JAR files + private final static List excludes = Arrays.asList( + "deploy.jar", + "javaws.jar", + "plugin.jar", + "cldrdata.jar", + "localedata.jar" + ); + private static void usage() { + System.out.println("ListJDKInternals [-o ] []*"); + } + + private static final Set EXPORTED_PACKAGES = new HashSet<>(); + + public static void main(String... args) throws IOException { + List paths = new ArrayList<>(); + Path outFile = null; + int i=0; + while (i < args.length) { + String arg = args[i++]; + if (arg.equals("-o")) { + outFile = Paths.get(args[i++]); + } else { + Path p = Paths.get(arg); + if (Files.notExists(p)) + throw new IllegalArgumentException(p + " not exist"); + paths.add(p); + } + } + if (paths.isEmpty()) { + usage(); + System.exit(1); + } + + // Get the exported APIs from the current JDK releases + Path javaHome = Paths.get(System.getProperty("java.home")); + ModuleFinder.ofSystem().findAll() + .stream() + .map(ModuleReference::descriptor) + .filter(md -> !md.name().equals("jdk.unsupported")) + .map(ModuleDescriptor::exports) + .flatMap(Set::stream) + .filter(exp -> !exp.isQualified()) + .map(ModuleDescriptor.Exports::source) + .forEach(EXPORTED_PACKAGES::add); + + ListJDKInternals listJDKInternals = new ListJDKInternals(paths); + if (outFile != null) { + try (OutputStream out = Files.newOutputStream(outFile); + PrintStream pw = new PrintStream(out)) { + listJDKInternals.write(pw); + } + } else { + listJDKInternals.write(System.out); + } + } + + private final Set packages = new HashSet<>(); + ListJDKInternals(List dirs) throws IOException { + for (Path p : dirs) { + packages.addAll(list(p)); + } + } + + private void write(PrintStream pw) { + pw.println("# This file is auto-generated by ListJDKInternals tool on " + + LocalDateTime.now().toString()); + packages.stream().sorted() + .forEach(pw::println); + } + + private Set list(Path javaHome) throws IOException { + Path jrt = javaHome.resolve("lib").resolve("modules"); + Path jre = javaHome.resolve("jre"); + + if (Files.exists(jrt)) { + return listModularRuntime(javaHome); + } else if (Files.exists(jre.resolve("lib").resolve("rt.jar"))) { + return listLegacyRuntime(javaHome); + } + throw new IllegalArgumentException("invalid " + javaHome); + } + + private Set listModularRuntime(Path javaHome) throws IOException { + Map env = new HashMap<>(); + env.put("java.home", javaHome.toString()); + FileSystem fs = FileSystems.newFileSystem(URI.create("jrt:/"), env); + Path root = fs.getPath("packages"); + return Files.walk(root, 1) + .map(Path::getFileName) + .map(Path::toString) + .filter(pn -> !EXPORTED_PACKAGES.contains(pn)) + .collect(Collectors.toSet()); + } + + private Set listLegacyRuntime(Path javaHome) throws IOException { + List dirs = new ArrayList<>(); + Path jre = javaHome.resolve("jre"); + Path lib = javaHome.resolve("lib"); + + dirs.add(jre.resolve("lib")); + dirs.add(jre.resolve("lib").resolve("ext")); + dirs.add(lib.resolve("tools.jar")); + dirs.add(lib.resolve("jconsole.jar")); + Set packages = new HashSet<>(); + for (Path d : dirs) { + Files.find(d, 1, (Path p, BasicFileAttributes attr) + -> p.getFileName().toString().endsWith(".jar") && + !excludes.contains(p.getFileName().toString())) + .map(ListJDKInternals::walkJarFile) + .flatMap(Set::stream) + .filter(pn -> !EXPORTED_PACKAGES.contains(pn)) + .forEach(packages::add); + } + return packages; + } + + static Set walkJarFile(Path jarfile) { + try (JarFile jf = new JarFile(jarfile.toFile())) { + return jf.stream() + .map(JarEntry::getName) + .filter(n -> n.endsWith(".class")) + .map(ListJDKInternals::toPackage) + .collect(Collectors.toSet()); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + + static String toPackage(String name) { + int i = name.lastIndexOf('/'); + if (i < 0) { + System.err.format("Warning: unnamed package %s%n", name); + } + return i >= 0 ? name.substring(0, i).replace("/", ".") : ""; + } +} diff -r 5a66e43d8cbd -r 5bf88dce615f langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java Wed Jul 05 21:57:12 2017 +0200 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java Wed Jul 05 21:58:29 2017 +0200 @@ -1152,10 +1152,6 @@ case TYP: if (sym.isLocal()) { mask = LocalClassFlags; - if (sym.name.isEmpty()) { // Anonymous class - // JLS: Anonymous classes are final. - implicit |= FINAL; - } if ((sym.owner.flags_field & STATIC) == 0 && (flags & ENUM) != 0) log.error(pos, "enums.must.be.static"); diff -r 5a66e43d8cbd -r 5bf88dce615f langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Wed Jul 05 21:57:12 2017 +0200 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Wed Jul 05 21:58:29 2017 +0200 @@ -1040,7 +1040,6 @@ inner.markAbstractIfNeeded(types); char flags = (char) adjustFlags(inner.flags_field); if ((flags & INTERFACE) != 0) flags |= ABSTRACT; // Interfaces are always ABSTRACT - if (inner.name.isEmpty()) flags &= ~FINAL; // Anonymous class: unset FINAL flag flags &= ~STRICTFP; //inner classes should not have the strictfp flag set. if (dumpInnerClassModifiers) { PrintWriter pw = log.getWriter(Log.WriterKind.ERROR); @@ -1679,7 +1678,6 @@ if ((flags & PROTECTED) != 0) flags |= PUBLIC; flags = flags & ClassFlags & ~STRICTFP; if ((flags & INTERFACE) == 0) flags |= ACC_SUPER; - if (c.isInner() && c.name.isEmpty()) flags &= ~FINAL; } if (dumpClassModifiers) { diff -r 5a66e43d8cbd -r 5bf88dce615f langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DCTree.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DCTree.java Wed Jul 05 21:57:12 2017 +0200 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DCTree.java Wed Jul 05 21:58:29 2017 +0200 @@ -578,7 +578,7 @@ public final String signature; // The following are not directly exposed through ReferenceTree - // use DocTrees.getElement(TreePath,ReferenceTree) + // use DocTrees.getElement(DocTreePath) public final JCTree qualifierExpression; public final Name memberName; public final List paramTypes; diff -r 5a66e43d8cbd -r 5bf88dce615f langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java Wed Jul 05 21:57:12 2017 +0200 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java Wed Jul 05 21:58:29 2017 +0200 @@ -458,17 +458,6 @@ } /** - * Add gap between navigation bar elements. - * - * @param liNav the content tree to which the gap will be added - */ - protected void addNavGap(Content liNav) { - liNav.addContent(getSpace()); - liNav.addContent("|"); - liNav.addContent(getSpace()); - } - - /** * {@inheritDoc} */ @Override diff -r 5a66e43d8cbd -r 5bf88dce615f langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java Wed Jul 05 21:57:12 2017 +0200 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java Wed Jul 05 21:58:29 2017 +0200 @@ -764,17 +764,6 @@ } /** - * Add gap between navigation bar elements. - * - * @param liNav the content tree to which the gap will be added - */ - protected void addNavGap(Content liNav) { - liNav.addContent(getSpace()); - liNav.addContent("|"); - liNav.addContent(getSpace()); - } - - /** * Return the TypeElement being documented. * * @return the TypeElement being documented. diff -r 5a66e43d8cbd -r 5bf88dce615f langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java Wed Jul 05 21:57:12 2017 +0200 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java Wed Jul 05 21:58:29 2017 +0200 @@ -908,6 +908,17 @@ } /** + * Add gap between navigation bar elements. + * + * @param liNav the content tree to which the gap will be added + */ + protected void addNavGap(Content liNav) { + liNav.addContent(getSpace()); + liNav.addContent("|"); + liNav.addContent(getSpace()); + } + + /** * Get summary table header. * * @param header the header for the table diff -r 5a66e43d8cbd -r 5bf88dce615f langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java Wed Jul 05 21:57:12 2017 +0200 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java Wed Jul 05 21:58:29 2017 +0200 @@ -26,23 +26,28 @@ package jdk.javadoc.internal.doclets.formats.html; import java.io.*; +import java.util.ArrayList; +import java.util.EnumMap; import java.util.List; -import java.util.Set; +import java.util.Map; import javax.lang.model.element.ModuleElement; +import javax.lang.model.element.ModuleElement.DirectiveKind; import javax.lang.model.element.PackageElement; +import javax.lang.model.element.TypeElement; import com.sun.source.doctree.DocTree; - import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml; +import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; import jdk.javadoc.internal.doclets.toolkit.Content; import jdk.javadoc.internal.doclets.toolkit.ModuleSummaryWriter; import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; +import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; /** * Class to generate file for each module contents in the right-hand @@ -74,17 +79,25 @@ */ protected ModuleElement mdle; + private final Map> directiveMap + = new EnumMap<>(ModuleElement.DirectiveKind.class); + /** * The HTML tree for main tag. */ protected HtmlTree mainTree = HtmlTree.MAIN(); /** + * The HTML tree for section tag. + */ + protected HtmlTree sectionTree = HtmlTree.SECTION(); + + /** * Constructor to construct ModuleWriter object and to generate * "moduleName-summary.html" file. * * @param configuration the configuration of the doclet. - * @param module Module under consideration. + * @param mdle Module under consideration. * @param prevModule Previous module in the sorted array. * @param nextModule Next module in the sorted array. */ @@ -95,10 +108,13 @@ this.prevModule = prevModule; this.nextModule = nextModule; this.mdle = mdle; + generateDirectiveMap(); } /** - * {@inheritDoc} + * Get the module header. + * + * @param heading the heading for the section */ public Content getModuleHeader(String heading) { HtmlTree bodyTree = getBody(true, getWindowTitle(mdle.getQualifiedName().toString())); @@ -127,7 +143,7 @@ } /** - * {@inheritDoc} + * Get the content header. */ public Content getContentHeader() { HtmlTree div = new HtmlTree(HtmlTag.DIV); @@ -136,7 +152,7 @@ } /** - * {@inheritDoc} + * Get the summary section header. */ public Content getSummaryHeader() { HtmlTree li = new HtmlTree(HtmlTag.LI); @@ -145,7 +161,9 @@ } /** - * {@inheritDoc} + * Get the summary tree. + * + * @param summaryContentTree the content tree to be added to the summary tree. */ public Content getSummaryTree(Content summaryContentTree) { HtmlTree ul = HtmlTree.UL(HtmlStyle.blockList, summaryContentTree); @@ -153,18 +171,315 @@ } /** + * Generate the directive map for the directives on the module. + */ + public void generateDirectiveMap() { + for (ModuleElement.Directive d : mdle.getDirectives()) { + if (directiveMap.containsKey(d.getKind())) { + List dir = directiveMap.get(d.getKind()); + dir.add(d); + directiveMap.put(d.getKind(), dir); + } else { + List dir = new ArrayList<>(); + dir.add(d); + directiveMap.put(d.getKind(), dir); + } + } + } + + /** + * Add the summary header. + * + * @param startMarker the marker comment + * @param markerAnchor the marker anchor for the section + * @param heading the heading for the section + * @param htmltree the content tree to which the information is added + */ + public void addSummaryHeader(Content startMarker, SectionName markerAnchor, Content heading, Content htmltree) { + htmltree.addContent(startMarker); + htmltree.addContent(getMarkerAnchor(markerAnchor)); + htmltree.addContent(HtmlTree.HEADING(HtmlTag.H3, heading)); + } + + /** + * Add the summary for the module. + * + * @param text the table caption + * @param tableSummary the summary for the table + * @param htmltree the content tree to which the table will be added + * @param tableStyle the table style + * @param tableHeader the table header + * @param dirs the list of module directives + */ + public void addSummary(String text, String tableSummary, Content htmltree, HtmlStyle tableStyle, + List tableHeader, List dirs) { + Content table = (configuration.isOutputHtml5()) + ? HtmlTree.TABLE(tableStyle, getTableCaption(new RawHtml(text))) + : HtmlTree.TABLE(tableStyle, tableSummary, getTableCaption(new RawHtml(text))); + table.addContent(getSummaryTableHeader(tableHeader, "col")); + Content tbody = new HtmlTree(HtmlTag.TBODY); + addList(dirs, tbody); + table.addContent(tbody); + htmltree.addContent(table); + } + + /** + * Add the list of directives for the module. + * + * @param dirs the list of module directives + * @params tbody the content tree to which the list is added + */ + public void addList(List dirs, Content tbody) { + boolean altColor = true; + for (ModuleElement.Directive direct : dirs) { + DirectiveKind kind = direct.getKind(); + switch (kind) { + case REQUIRES: + addRequiresList((ModuleElement.RequiresDirective) direct, tbody, altColor); + break; + case EXPORTS: + addExportedPackagesList((ModuleElement.ExportsDirective) direct, tbody, altColor); + break; + case USES: + addUsesList((ModuleElement.UsesDirective) direct, tbody, altColor); + break; + case PROVIDES: + addProvidesList((ModuleElement.ProvidesDirective) direct, tbody, altColor); + break; + default: + throw new AssertionError("unknown directive kind: " + kind); + } + altColor = !altColor; + } + } + + /** + * {@inheritDoc} + */ + public void addModulesSummary(Content summaryContentTree) { + List dirs = directiveMap.get(DirectiveKind.REQUIRES); + if (dirs != null && !dirs.isEmpty()) { + HtmlTree li = new HtmlTree(HtmlTag.LI); + li.addStyle(HtmlStyle.blockList); + addSummaryHeader(HtmlConstants.START_OF_MODULES_SUMMARY, SectionName.MODULES, + getResource("doclet.navModules"), li); + String text = configuration.getText("doclet.Requires_Summary"); + String tableSummary = configuration.getText("doclet.Member_Table_Summary", + configuration.getText("doclet.Requires_Summary"), + configuration.getText("doclet.modules")); + addRequiresSummary(text, tableSummary, dirs, li); + HtmlTree ul = HtmlTree.UL(HtmlStyle.blockList, li); + summaryContentTree.addContent(ul); + } + } + + /** + * Add the requires summary for the module. + * + * @param text the table caption + * @param tableSummary the summary for the table + * @param dirs the list of module directives + * @param htmltree the content tree to which the table will be added + */ + public void addRequiresSummary(String text, String tableSummary, List dirs, + Content htmltree) { + addSummary(text, tableSummary, htmltree, HtmlStyle.requiresSummary, requiresTableHeader, dirs); + } + + /** + * Add the requires directive list for the module. + * + * @param direct the requires directive + * @param tbody the content tree to which the directive will be added + * @param altColor true if altColor style should be used or false if rowColor style should be used + */ + public void addRequiresList(ModuleElement.RequiresDirective direct, Content tbody, boolean altColor) { + ModuleElement m = direct.getDependency(); + Content moduleLinkContent = getModuleLink(m, new StringContent(m.getQualifiedName().toString())); + Content tdPackage = HtmlTree.TD(HtmlStyle.colFirst, moduleLinkContent); + HtmlTree tdSummary = new HtmlTree(HtmlTag.TD); + tdSummary.addStyle(HtmlStyle.colLast); + addSummaryComment(m, tdSummary); + HtmlTree tr = HtmlTree.TR(tdPackage); + tr.addContent(tdSummary); + tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor); + tbody.addContent(tr); + } + + /** * {@inheritDoc} */ - public void addPackagesSummary(Set packages, String text, - String tableSummary, Content summaryContentTree) { - Content table = (configuration.isOutputHtml5()) - ? HtmlTree.TABLE(HtmlStyle.overviewSummary, getTableCaption(new RawHtml(text))) - : HtmlTree.TABLE(HtmlStyle.overviewSummary, tableSummary, getTableCaption(new RawHtml(text))); - table.addContent(getSummaryTableHeader(packageTableHeader, "col")); - Content tbody = new HtmlTree(HtmlTag.TBODY); - addPackagesList(packages, tbody); - table.addContent(tbody); - summaryContentTree.addContent(table); + public void addPackagesSummary(Content summaryContentTree) { + List dirs = directiveMap.get(DirectiveKind.EXPORTS); + if (dirs != null && !dirs.isEmpty()) { + HtmlTree li = new HtmlTree(HtmlTag.LI); + li.addStyle(HtmlStyle.blockList); + addSummaryHeader(HtmlConstants.START_OF_PACKAGES_SUMMARY, SectionName.PACKAGES, + getResource("doclet.navPackages"), li); + String text = configuration.getText("doclet.Exported_Packages_Summary"); + String tableSummary = configuration.getText("doclet.Member_Table_Summary", + configuration.getText("doclet.Exported_Packages_Summary"), + configuration.getText("doclet.packages")); + addExportedPackagesSummary(text, tableSummary, dirs, li); + HtmlTree ul = HtmlTree.UL(HtmlStyle.blockList, li); + summaryContentTree.addContent(ul); + } + } + + /** + * Add the exported packages summary for the module. + * + * @param text the table caption + * @param tableSummary the summary for the table + * @param dirs the list of module directives + * @param htmltree the content tree to which the table will be added + */ + public void addExportedPackagesSummary(String text, String tableSummary, List dirs, + Content htmltree) { + addSummary(text, tableSummary, htmltree, HtmlStyle.packagesSummary, exportedPackagesTableHeader, dirs); + } + + /** + * Add the exported packages list for the module. + * + * @param direct the requires directive + * @param tbody the content tree to which the directive will be added + * @param altColor true if altColor style should be used or false if rowColor style should be used + */ + public void addExportedPackagesList(ModuleElement.ExportsDirective direct, Content tbody, boolean altColor) { + PackageElement pkg = direct.getPackage(); + Content pkgLinkContent = getPackageLink(pkg, new StringContent(utils.getPackageName(pkg))); + Content tdPackage = HtmlTree.TD(HtmlStyle.colFirst, pkgLinkContent); + HtmlTree tdModules = new HtmlTree(HtmlTag.TD); + tdModules.addStyle(HtmlStyle.colSecond); + List targetModules = direct.getTargetModules(); + if (targetModules != null) { + List mElements = direct.getTargetModules(); + for (int i = 0; i < mElements.size(); i++) { + if (i > 0) { + tdModules.addContent(new HtmlTree(HtmlTag.BR)); + } + ModuleElement m = mElements.get(i); + tdModules.addContent(new StringContent(m.getQualifiedName().toString())); + } + } else { + tdModules.addContent(configuration.getText("doclet.All_Modules")); + } + HtmlTree tdSummary = new HtmlTree(HtmlTag.TD); + tdSummary.addStyle(HtmlStyle.colLast); + addSummaryComment(pkg, tdSummary); + HtmlTree tr = HtmlTree.TR(tdPackage); + tr.addContent(tdModules); + tr.addContent(tdSummary); + tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor); + tbody.addContent(tr); + } + + /** + * {@inheritDoc} + */ + public void addServicesSummary(Content summaryContentTree) { + List usesDirs = directiveMap.get(DirectiveKind.USES); + List providesDirs = directiveMap.get(DirectiveKind.PROVIDES); + if ((usesDirs != null && !usesDirs.isEmpty()) || (providesDirs != null && !providesDirs.isEmpty())) { + HtmlTree li = new HtmlTree(HtmlTag.LI); + li.addStyle(HtmlStyle.blockList); + addSummaryHeader(HtmlConstants.START_OF_SERVICES_SUMMARY, SectionName.SERVICES, + getResource("doclet.navServices"), li); + String text; + String tableSummary; + if (usesDirs != null && !usesDirs.isEmpty()) { + text = configuration.getText("doclet.Uses_Summary"); + tableSummary = configuration.getText("doclet.Member_Table_Summary", + configuration.getText("doclet.Uses_Summary"), + configuration.getText("doclet.types")); + addUsesSummary(text, tableSummary, usesDirs, li); + } + if (providesDirs != null && !providesDirs.isEmpty()) { + text = configuration.getText("doclet.Provides_Summary"); + tableSummary = configuration.getText("doclet.Member_Table_Summary", + configuration.getText("doclet.Provides_Summary"), + configuration.getText("doclet.types")); + addProvidesSummary(text, tableSummary, providesDirs, li); + } + HtmlTree ul = HtmlTree.UL(HtmlStyle.blockList, li); + summaryContentTree.addContent(ul); + } + } + + /** + * Add the uses summary for the module. + * + * @param text the table caption + * @param tableSummary the summary for the table + * @param dirs the list of module directives + * @param htmltree the content tree to which the table will be added + */ + public void addUsesSummary(String text, String tableSummary, List dirs, + Content htmltree) { + addSummary(text, tableSummary, htmltree, HtmlStyle.usesSummary, usesTableHeader, dirs); + } + + /** + * Add the uses list for the module. + * + * @param direct the requires directive + * @param tbody the content tree to which the directive will be added + * @param altColor true if altColor style should be used or false if rowColor style should be used + */ + public void addUsesList(ModuleElement.UsesDirective direct, Content tbody, boolean altColor) { + TypeElement type = direct.getService(); + Content typeLinkContent = getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.PACKAGE, type)); + Content tdPackage = HtmlTree.TD(HtmlStyle.colFirst, typeLinkContent); + HtmlTree tdSummary = new HtmlTree(HtmlTag.TD); + tdSummary.addStyle(HtmlStyle.colLast); + addSummaryComment(type, tdSummary); + HtmlTree tr = HtmlTree.TR(tdPackage); + tr.addContent(tdSummary); + tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor); + tbody.addContent(tr); + } + + /** + * Add the provides summary for the module. + * + * @param text the table caption + * @param tableSummary the summary for the table + * @param dirs the list of module directives + * @param htmltree the content tree to which the table will be added + */ + public void addProvidesSummary(String text, String tableSummary, List dirs, + Content htmltree) { + addSummary(text, tableSummary, htmltree, HtmlStyle.providesSummary, providesTableHeader, dirs); + } + + /** + * Add the exported packages list for the module. + * + * @param direct the requires directive + * @param tbody the content tree to which the directive will be added + * @param altColor true if altColor style should be used or false if rowColor style should be used + */ + public void addProvidesList(ModuleElement.ProvidesDirective direct, Content tbody, boolean altColor) { + TypeElement impl = direct.getImplementation(); + TypeElement srv = direct.getService(); + Content implLinkContent = getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.PACKAGE, impl)); + Content srvLinkContent = getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.PACKAGE, srv)); + HtmlTree tdType = HtmlTree.TD(HtmlStyle.colFirst, srvLinkContent); + tdType.addContent(new HtmlTree(HtmlTag.BR)); + tdType.addContent("("); + HtmlTree implSpan = HtmlTree.SPAN(HtmlStyle.implementationLabel, getResource("doclet.Implementation")); + tdType.addContent(implSpan); + tdType.addContent(getSpace()); + tdType.addContent(implLinkContent); + tdType.addContent(")"); + HtmlTree tdDesc = new HtmlTree(HtmlTag.TD); + tdDesc.addStyle(HtmlStyle.colLast); + addSummaryComment(srv, tdDesc); + HtmlTree tr = HtmlTree.TR(tdType); + tr.addContent(tdDesc); + tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor); + tbody.addContent(tr); } /** @@ -196,29 +511,56 @@ } /** - * Adds list of packages in the package summary table. Generate link to each package. + * Add summary details to the navigation bar. * - * @param packages Packages to which link is to be generated - * @param tbody the documentation tree to which the list will be added + * @param subDiv the content tree to which the summary detail links will be added + */ + protected void addSummaryDetailLinks(Content subDiv) { + try { + Content div = HtmlTree.DIV(getNavSummaryLinks()); + subDiv.addContent(div); + } catch (Exception e) { + throw new DocletAbortException(e); + } + } + + /** + * Get summary links for navigation bar. + * + * @return the content tree for the navigation summary links */ - protected void addPackagesList(Set packages, Content tbody) { - boolean altColor = true; - for (PackageElement pkg : packages) { - if (pkg != null && !pkg.isUnnamed()) { - 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); - tdSummary.addStyle(HtmlStyle.colLast); - addSummaryComment(pkg, tdSummary); - HtmlTree tr = HtmlTree.TR(tdPackage); - tr.addContent(tdSummary); - tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor); - tbody.addContent(tr); - } - } - altColor = !altColor; - } + protected Content getNavSummaryLinks() throws Exception { + Content li = HtmlTree.LI(moduleSubNavLabel); + li.addContent(getSpace()); + Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li); + Content liNav = new HtmlTree(HtmlTag.LI); + liNav.addContent(!utils.getBody(mdle).isEmpty() && !configuration.nocomment + ? getHyperLink(SectionName.MODULE_DESCRIPTION, getResource("doclet.navModuleDescription")) + : getResource("doclet.navModuleDescription")); + addNavGap(liNav); + liNav.addContent(showDirectives(DirectiveKind.REQUIRES) + ? getHyperLink(SectionName.MODULES, getResource("doclet.navModules")) + : getResource("doclet.navModules")); + addNavGap(liNav); + liNav.addContent(showDirectives(DirectiveKind.EXPORTS) + ? getHyperLink(SectionName.PACKAGES, getResource("doclet.navPackages")) + : getResource("doclet.navPackages")); + addNavGap(liNav); + liNav.addContent((showDirectives(DirectiveKind.USES) || showDirectives(DirectiveKind.PROVIDES)) + ? getHyperLink(SectionName.SERVICES, getResource("doclet.navServices")) + : getResource("doclet.navServices")); + ulNav.addContent(liNav); + return ulNav; + } + + /** + * Return true if the directive should be displayed. + * + * @param dirKind the kind of directive for the module + * @return true if the directive should be displayed + */ + private boolean showDirectives(DirectiveKind dirKind) { + return directiveMap.get(dirKind) != null && !directiveMap.get(dirKind).isEmpty(); } /** diff -r 5a66e43d8cbd -r 5bf88dce615f langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SectionName.java --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SectionName.java Wed Jul 05 21:57:12 2017 +0200 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SectionName.java Wed Jul 05 21:58:29 2017 +0200 @@ -54,6 +54,9 @@ METHODS_INHERITANCE("methods.inherited.from.class."), METHOD_SUMMARY("method.summary"), MODULE_DESCRIPTION("module.description"), + MODULES("modules.summary"), + PACKAGES("packages.summary"), + SERVICES("services.summary"), NAVBAR_BOTTOM("navbar.bottom"), NAVBAR_BOTTOM_FIRSTROW("navbar.bottom.firstrow"), NAVBAR_TOP("navbar.top"), diff -r 5a66e43d8cbd -r 5bf88dce615f langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlConstants.java --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlConstants.java Wed Jul 05 21:57:12 2017 +0200 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlConstants.java Wed Jul 05 21:58:29 2017 +0200 @@ -70,6 +70,24 @@ new Comment("============ MODULE DESCRIPTION ==========="); /** + * Marker to identify start of modules summary. + */ + public static final Content START_OF_MODULES_SUMMARY = + new Comment("============ MODULES SUMMARY ==========="); + + /** + * Marker to identify start of packages summary. + */ + public static final Content START_OF_PACKAGES_SUMMARY = + new Comment("============ PACKAGES SUMMARY ==========="); + + /** + * Marker to identify start of services summary. + */ + public static final Content START_OF_SERVICES_SUMMARY = + new Comment("============ SERVICES SUMMARY ==========="); + + /** * Marker to identify start of class data. */ public static final Content START_OF_CLASS_DATA = diff -r 5a66e43d8cbd -r 5bf88dce615f langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlStyle.java --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlStyle.java Wed Jul 05 21:57:12 2017 +0200 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlStyle.java Wed Jul 05 21:58:29 2017 +0200 @@ -49,6 +49,7 @@ colFirst, colLast, colOne, + colSecond, constantsSummary, constantValuesContainer, contentContainer, @@ -65,6 +66,7 @@ header, horizontal, footer, + implementationLabel, indexContainer, indexNav, inheritance, @@ -87,7 +89,10 @@ overviewSummary, packageHierarchyLabel, packageLabelInClass, + packagesSummary, paramLabel, + providesSummary, + requiresSummary, returnLabel, rightContainer, rightIframe, @@ -111,5 +116,6 @@ typeNameLabel, typeNameLink, typeSummary, - useSummary + useSummary, + usesSummary } diff -r 5a66e43d8cbd -r 5bf88dce615f langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlWriter.java --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlWriter.java Wed Jul 05 21:57:12 2017 +0200 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlWriter.java Wed Jul 05 21:58:29 2017 +0200 @@ -77,6 +77,26 @@ protected final List packageTableHeader; /** + * Header for tables displaying modules and description.. + */ + protected final List requiresTableHeader; + + /** + * Header for tables displaying packages and description.. + */ + protected final List exportedPackagesTableHeader; + + /** + * Header for tables displaying types and description.. + */ + protected final List usesTableHeader; + + /** + * Header for tables displaying types and description.. + */ + protected final List providesTableHeader; + + /** * Summary for use tables displaying class and package use. */ protected final String useTableSummary; @@ -108,6 +128,8 @@ public final Content detailLabel; + public final Content moduleSubNavLabel; + public final Content framesLabel; public final Content noframesLabel; @@ -192,6 +214,19 @@ packageTableHeader = new ArrayList<>(); packageTableHeader.add(configuration.getText("doclet.Package")); packageTableHeader.add(configuration.getText("doclet.Description")); + requiresTableHeader = new ArrayList<>(); + requiresTableHeader.add(configuration.getText("doclet.Module")); + requiresTableHeader.add(configuration.getText("doclet.Description")); + exportedPackagesTableHeader = new ArrayList<>(); + exportedPackagesTableHeader.add(configuration.getText("doclet.Package")); + exportedPackagesTableHeader.add(configuration.getText("doclet.Module")); + exportedPackagesTableHeader.add(configuration.getText("doclet.Description")); + usesTableHeader = new ArrayList<>(); + usesTableHeader.add(configuration.getText("doclet.Type")); + usesTableHeader.add(configuration.getText("doclet.Description")); + providesTableHeader = new ArrayList<>(); + providesTableHeader.add(configuration.getText("doclet.Type")); + providesTableHeader.add(configuration.getText("doclet.Description")); useTableSummary = configuration.getText("doclet.Use_Table_Summary", configuration.getText("doclet.packages")); modifierTypeHeader = configuration.getText("doclet.0_and_1", @@ -208,6 +243,7 @@ nextclassLabel = getNonBreakResource("doclet.Next_Class"); summaryLabel = getResource("doclet.Summary"); detailLabel = getResource("doclet.Detail"); + moduleSubNavLabel = getResource("doclet.Module_Sub_Nav"); framesLabel = getResource("doclet.Frames"); noframesLabel = getNonBreakResource("doclet.No_Frames"); treeLabel = getResource("doclet.Tree"); diff -r 5a66e43d8cbd -r 5bf88dce615f langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties Wed Jul 05 21:57:12 2017 +0200 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties Wed Jul 05 21:58:29 2017 +0200 @@ -31,6 +31,11 @@ doclet.Href_Class_Or_Interface_Title=class or interface in {0} doclet.Summary=Summary: doclet.Detail=Detail: +doclet.Module_Sub_Nav=Module: +doclet.navModuleDescription=Description +doclet.navModules=Modules +doclet.navPackages=Packages +doclet.navServices=Services doclet.navNested=Nested doclet.navAnnotationTypeOptionalMember=Optional doclet.navAnnotationTypeRequiredMember=Required diff -r 5a66e43d8cbd -r 5bf88dce615f langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ModuleSummaryWriter.java --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ModuleSummaryWriter.java Wed Jul 05 21:57:12 2017 +0200 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ModuleSummaryWriter.java Wed Jul 05 21:58:29 2017 +0200 @@ -91,15 +91,25 @@ public abstract void addModuleTags(Content moduleContentTree); /** - * Adds the table of packages to the documentation tree. + * Adds the modules summary to the documentation tree. * - * @param packages the set of packages that should be added. - * @param label the label for this table. - * @param tableSummary the summary string for the table * @param summaryContentTree the content tree to which the summary will be added */ - public abstract void addPackagesSummary(Set packages, String label, - String tableSummary, Content summaryContentTree); + public abstract void addModulesSummary(Content summaryContentTree); + + /** + * Adds the packages summary to the documentation tree. + * + * @param summaryContentTree the content tree to which the summary will be added + */ + public abstract void addPackagesSummary(Content summaryContentTree); + + /** + * Adds the services summary to the documentation tree. + * + * @param summaryContentTree the content tree to which the summary will be added + */ + public abstract void addServicesSummary(Content summaryContentTree); /** * Adds the module content tree to the documentation tree. diff -r 5a66e43d8cbd -r 5bf88dce615f langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ModuleSummaryBuilder.java --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ModuleSummaryBuilder.java Wed Jul 05 21:57:12 2017 +0200 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ModuleSummaryBuilder.java Wed Jul 05 21:58:29 2017 +0200 @@ -167,23 +167,34 @@ } /** - * Build the module package summary. + * Build the modules summary. * * @param node the XML element that specifies which components to document * @param summaryContentTree the content tree to which the summaries will * be added */ - public void buildPackageSummary(XMLNode node, Content summaryContentTree) { - Set packages = configuration.modulePackages.get(mdle); - if (!packages.isEmpty()) { - String packageTableSummary - = configuration.getText("doclet.Member_Table_Summary", - configuration.getText("doclet.Package_Summary"), - configuration.getText("doclet.packages")); - moduleWriter.addPackagesSummary( - packages, configuration.getText("doclet.Package_Summary"), - packageTableSummary, summaryContentTree); + public void buildModulesSummary(XMLNode node, Content summaryContentTree) { + moduleWriter.addModulesSummary(summaryContentTree); + } + + /** + * Build the package summary. + * + * @param node the XML element that specifies which components to document + * @param summaryContentTree the content tree to which the summaries will be added + */ + public void buildPackagesSummary(XMLNode node, Content summaryContentTree) { + moduleWriter.addPackagesSummary(summaryContentTree); } + + /** + * Build the services summary. + * + * @param node the XML element that specifies which components to document + * @param summaryContentTree the content tree to which the summaries will be added + */ + public void buildServicesSummary(XMLNode node, Content summaryContentTree) { + moduleWriter.addServicesSummary(summaryContentTree); } /** diff -r 5a66e43d8cbd -r 5bf88dce615f langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclet.xml --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclet.xml Wed Jul 05 21:57:12 2017 +0200 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclet.xml Wed Jul 05 21:58:29 2017 +0200 @@ -33,7 +33,9 @@ - + + + diff -r 5a66e43d8cbd -r 5bf88dce615f langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets.properties --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets.properties Wed Jul 05 21:57:12 2017 +0200 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets.properties Wed Jul 05 21:58:29 2017 +0200 @@ -69,6 +69,10 @@ doclet.tag_misuse=Tag {0} cannot be used in {1} documentation. It can only be used in the following types of documentation: {2}. doclet.javafx_tag_misuse=Tags @propertyGetter, @propertySetter and @propertyDescription can only be used in JavaFX properties getters and setters. doclet.Package_Summary=Package Summary +doclet.Requires_Summary=Requires +doclet.Exported_Packages_Summary=Exported Packages +doclet.Uses_Summary=Uses +doclet.Provides_Summary=Provides doclet.Module_Summary=Module Summary doclet.Interface_Summary=Interface Summary doclet.Annotation_Types_Summary=Annotation Types Summary @@ -93,6 +97,7 @@ doclet.Packages=Packages doclet.packages=packages doclet.modules=modules +doclet.types=types doclet.All_Classes=All Classes doclet.All_Superinterfaces=All Superinterfaces: doclet.All_Implemented_Interfaces=All Implemented Interfaces: @@ -170,6 +175,7 @@ doclet.subinterfaces=subinterfaces doclet.Modifier=Modifier doclet.Type=Type +doclet.Implementation=Implementation: doclet.Types=Types doclet.Members=Members doclet.SearchTags=SearchTags diff -r 5a66e43d8cbd -r 5bf88dce615f langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css Wed Jul 05 21:57:12 2017 +0200 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css Wed Jul 05 21:58:29 2017 +0200 @@ -412,18 +412,20 @@ /* Table styles */ -.overviewSummary, .memberSummary, .typeSummary, .useSummary, .constantsSummary, .deprecatedSummary { +.overviewSummary, .memberSummary, .typeSummary, .useSummary, .constantsSummary, .deprecatedSummary, +.requiresSummary, .packagesSummary, .providesSummary, .usesSummary { width:100%; border-spacing:0; border-left:1px solid #EEE; border-right:1px solid #EEE; border-bottom:1px solid #EEE; } -.overviewSummary, .memberSummary { +.overviewSummary, .memberSummary, .requiresSummary, .packagesSummary, .providesSummary, .usesSummary { padding:0px; } .overviewSummary caption, .memberSummary caption, .typeSummary caption, -.useSummary caption, .constantsSummary caption, .deprecatedSummary caption { +.useSummary caption, .constantsSummary caption, .deprecatedSummary caption, +.requiresSummary caption, .packagesSummary caption, .providesSummary caption, .usesSummary caption { position:relative; text-align:left; background-repeat:no-repeat; @@ -439,16 +441,26 @@ } .overviewSummary caption a:link, .memberSummary caption a:link, .typeSummary caption a:link, .useSummary caption a:link, .constantsSummary caption a:link, .deprecatedSummary caption a:link, +.requiresSummary caption a:link, .packagesSummary caption a:link, providesSummary caption a:link, +.usesSummary caption a:link, .overviewSummary caption a:hover, .memberSummary caption a:hover, .typeSummary caption a:hover, .useSummary caption a:hover, .constantsSummary caption a:hover, .deprecatedSummary caption a:hover, +.requiresSummary caption a:hover, .packagesSummary caption a:hover, providesSummary caption a:hover, +.usesSummary caption a:hover, .overviewSummary caption a:active, .memberSummary caption a:active, .typeSummary caption a:active, .useSummary caption a:active, .constantsSummary caption a:active, .deprecatedSummary caption a:active, +.requiresSummary caption a:active, .packagesSummary caption a:active, providesSummary caption a:active, +.usesSummary caption a:active, .overviewSummary caption a:visited, .memberSummary caption a:visited, .typeSummary caption a:visited, -.useSummary caption a:visited, .constantsSummary caption a:visited, .deprecatedSummary caption a:visited { +.useSummary caption a:visited, .constantsSummary caption a:visited, .deprecatedSummary caption a:visited +.requiresSummary caption a:visited, .packagesSummary caption a:visited, providesSummary caption a:visited, +.usesSummary caption a:visited { color:#FFFFFF; } .overviewSummary caption span, .memberSummary caption span, .typeSummary caption span, -.useSummary caption span, .constantsSummary caption span, .deprecatedSummary caption span { +.useSummary caption span, .constantsSummary caption span, .deprecatedSummary caption span, +.requiresSummary caption span, .packagesSummary caption span, .providesSummary caption span, +.usesSummary caption span { white-space:nowrap; padding-top:5px; padding-left:12px; @@ -491,7 +503,8 @@ display:inline; } .overviewSummary .tabEnd, .memberSummary .tabEnd, .typeSummary .tabEnd, -.useSummary .tabEnd, .constantsSummary .tabEnd, .deprecatedSummary .tabEnd { +.useSummary .tabEnd, .constantsSummary .tabEnd, .deprecatedSummary .tabEnd, +.requiresSummary .tabEnd, .packagesSummary .tabEnd, .providesSummary .tabEnd, .usesSummary .tabEnd { display:none; width:5px; position:relative; @@ -516,18 +529,19 @@ } .overviewSummary td, .memberSummary td, .typeSummary td, -.useSummary td, .constantsSummary td, .deprecatedSummary td { +.useSummary td, .constantsSummary td, .deprecatedSummary td, +.requiresSummary td, .packagesSummary td, .providesSummary td, .usesSummary td { text-align:left; padding:0px 0px 12px 10px; } -th.colOne, th.colFirst, th.colLast, .useSummary th, .constantsSummary th, -td.colOne, td.colFirst, td.colLast, .useSummary td, .constantsSummary td{ +th.colOne, th.colFirst, th.colSecond, th.colLast, .useSummary th, .constantsSummary th, .packagesSummary th, +td.colOne, td.colFirst, td.colSecond, td.colLast, .useSummary td, .constantsSummary td { vertical-align:top; padding-right:0px; padding-top:8px; padding-bottom:3px; } -th.colFirst, th.colLast, th.colOne, .constantsSummary th { +th.colFirst, th.colSecond, th.colLast, th.colOne, .constantsSummary th, .packagesSummary th { background:#dee3e9; text-align:left; padding:8px 3px 3px 7px; @@ -539,10 +553,19 @@ td.colLast, th.colLast { font-size:13px; } -td.colOne, th.colOne { +td.colOne, th.colOne, .constantsSummary th, .packagesSummary th { + font-size:13px; +} +.providesSummary th.colFirst, .providesSummary th.colLast, .providesSummary td.colFirst, +.providesSummary td.colLast { + white-space:normal; + width:50%; font-size:13px; } .overviewSummary td.colFirst, .overviewSummary th.colFirst, +.requiresSummary td.colFirst, .requiresSummary th.colFirst, +.packagesSummary td.colFirst, .packagesSummary td.colSecond, .packagesSummary th.colFirst, .packagesSummary th, +.usesSummary td.colFirst, .usesSummary th.colFirst, .useSummary td.colFirst, .useSummary th.colFirst, .overviewSummary td.colOne, .overviewSummary th.colOne, .memberSummary td.colFirst, .memberSummary th.colFirst, @@ -551,7 +574,7 @@ width:25%; vertical-align:top; } -td.colOne a:link, td.colOne a:active, td.colOne a:visited, td.colOne a:hover, td.colFirst a:link, td.colFirst a:active, td.colFirst a:visited, td.colFirst a:hover, td.colLast a:link, td.colLast a:active, td.colLast a:visited, td.colLast a:hover, .constantValuesContainer td a:link, .constantValuesContainer td a:active, .constantValuesContainer td a:visited, .constantValuesContainer td a:hover { +td.colOne a:link, td.colOne a:active, td.colOne a:visited, td.colOne a:hover, td.colFirst a:link, td.colFirst a:active, td.colFirst a:visited, td.colFirst a:hover, td.colSecond a:link, td.colSecond a:active, td.colSecond a:visited, td.colSecond a:hover, td.colLast a:link, td.colLast a:active, td.colLast a:visited, td.colLast a:hover, .constantValuesContainer td a:link, .constantValuesContainer td a:active, .constantValuesContainer td a:visited, .constantValuesContainer td a:hover { font-weight:bold; } .tableSubHeadingColor { @@ -611,7 +634,7 @@ margin:3px 10px 2px 0px; color:#474747; } -.deprecatedLabel, .descfrmTypeLabel, .memberNameLabel, .memberNameLink, +.deprecatedLabel, .descfrmTypeLabel, .implementationLabel, .memberNameLabel, .memberNameLink, .moduleLabelInClass, .overrideSpecifyLabel, .packageLabelInClass, .packageHierarchyLabel, .paramLabel, .returnLabel, .seeLabel, .simpleTagLabel, .throwsLabel, .typeNameLabel, .typeNameLink, .searchTagLink { diff -r 5a66e43d8cbd -r 5bf88dce615f langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Analyzer.java --- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Analyzer.java Wed Jul 05 21:57:12 2017 +0200 +++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Analyzer.java Wed Jul 05 21:58:29 2017 +0200 @@ -25,20 +25,19 @@ package com.sun.tools.jdeps; -import static com.sun.tools.jdeps.JdepsConfiguration.*; +import com.sun.tools.classfile.Dependency.Location; -import com.sun.tools.classfile.Dependency.Location; +import java.io.BufferedReader; import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; import java.io.UncheckedIOException; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.Map; -import java.util.MissingResourceException; import java.util.Objects; -import java.util.Optional; -import java.util.ResourceBundle; import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -369,35 +368,29 @@ } } - static final JdkInternals REMOVED_JDK_INTERNALS = new JdkInternals(); + static final Jdk8Internals REMOVED_JDK_INTERNALS = new Jdk8Internals(); - static class JdkInternals extends Module { - private final String BUNDLE = "com.sun.tools.jdeps.resources.jdkinternals"; - - private final Set jdkinternals; - private final Set jdkUnsupportedClasses; - private JdkInternals() { + static class Jdk8Internals extends Module { + private final String JDK8_INTERNALS = "/com/sun/tools/jdeps/resources/jdk8_internals.txt"; + private final Set jdk8Internals; + private Jdk8Internals() { super("JDK removed internal API"); - - try { - ResourceBundle rb = ResourceBundle.getBundle(BUNDLE); - this.jdkinternals = rb.keySet(); - } catch (MissingResourceException e) { - throw new InternalError("Cannot find jdkinternals resource bundle"); + try (InputStream in = JdepsTask.class.getResourceAsStream(JDK8_INTERNALS); + BufferedReader reader = new BufferedReader(new InputStreamReader(in))) { + this.jdk8Internals = reader.lines() + .filter(ln -> !ln.startsWith("#")) + .collect(Collectors.toSet()); + } catch (IOException e) { + throw new UncheckedIOException(e); } - - this.jdkUnsupportedClasses = getUnsupportedClasses(); } public boolean contains(Location location) { - if (jdkUnsupportedClasses.contains(location.getName() + ".class")) { - return false; - } - String cn = location.getClassName(); int i = cn.lastIndexOf('.'); String pn = i > 0 ? cn.substring(0, i) : ""; - return jdkinternals.contains(cn) || jdkinternals.contains(pn); + + return jdk8Internals.contains(pn); } @Override @@ -414,25 +407,5 @@ public boolean isExported(String pn) { return false; } - - private Set getUnsupportedClasses() { - // jdk.unsupported may not be observable - Optional om = Profile.FULL_JRE.findModule(JDK_UNSUPPORTED); - if (om.isPresent()) { - return om.get().reader().entries(); - } - - // find from local run-time image - SystemModuleFinder system = new SystemModuleFinder(); - if (system.find(JDK_UNSUPPORTED).isPresent()) { - try { - return system.getClassReader(JDK_UNSUPPORTED).entries(); - } catch (IOException e) { - throw new UncheckedIOException(e); - } - } - - return Collections.emptySet(); - } } } diff -r 5a66e43d8cbd -r 5bf88dce615f langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdk8_internals.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdk8_internals.txt Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,1029 @@ +# This file is auto-generated by ListJDKInternals tool on 2016-07-12T16:13:20.303865 +apple.applescript +apple.laf +apple.launcher +apple.security +com.apple.concurrent +com.apple.eawt +com.apple.eawt.event +com.apple.eio +com.apple.laf +com.apple.laf.resources +com.oracle.jrockit.jfr +com.oracle.jrockit.jfr.client +com.oracle.jrockit.jfr.management +com.oracle.security.ucrypto +com.oracle.util +com.oracle.webservices.internal.api +com.oracle.webservices.internal.api.databinding +com.oracle.webservices.internal.api.message +com.oracle.webservices.internal.impl.encoding +com.oracle.webservices.internal.impl.internalspi.encoding +com.oracle.xmlns.internal.webservices.jaxws_databinding +com.sun.accessibility.internal.resources +com.sun.activation.registries +com.sun.awt +com.sun.beans +com.sun.beans.decoder +com.sun.beans.editors +com.sun.beans.finder +com.sun.beans.infos +com.sun.beans.util +com.sun.codemodel.internal +com.sun.codemodel.internal.fmt +com.sun.codemodel.internal.util +com.sun.codemodel.internal.writer +com.sun.corba.se.impl.activation +com.sun.corba.se.impl.copyobject +com.sun.corba.se.impl.corba +com.sun.corba.se.impl.dynamicany +com.sun.corba.se.impl.encoding +com.sun.corba.se.impl.interceptors +com.sun.corba.se.impl.io +com.sun.corba.se.impl.ior +com.sun.corba.se.impl.ior.iiop +com.sun.corba.se.impl.javax.rmi +com.sun.corba.se.impl.javax.rmi.CORBA +com.sun.corba.se.impl.legacy.connection +com.sun.corba.se.impl.logging +com.sun.corba.se.impl.monitoring +com.sun.corba.se.impl.naming.cosnaming +com.sun.corba.se.impl.naming.namingutil +com.sun.corba.se.impl.naming.pcosnaming +com.sun.corba.se.impl.oa +com.sun.corba.se.impl.oa.poa +com.sun.corba.se.impl.oa.toa +com.sun.corba.se.impl.orb +com.sun.corba.se.impl.orbutil +com.sun.corba.se.impl.orbutil.closure +com.sun.corba.se.impl.orbutil.concurrent +com.sun.corba.se.impl.orbutil.fsm +com.sun.corba.se.impl.orbutil.graph +com.sun.corba.se.impl.orbutil.threadpool +com.sun.corba.se.impl.presentation.rmi +com.sun.corba.se.impl.protocol +com.sun.corba.se.impl.protocol.giopmsgheaders +com.sun.corba.se.impl.resolver +com.sun.corba.se.impl.transport +com.sun.corba.se.impl.util +com.sun.corba.se.internal.CosNaming +com.sun.corba.se.internal.Interceptors +com.sun.corba.se.internal.POA +com.sun.corba.se.internal.corba +com.sun.corba.se.internal.iiop +com.sun.corba.se.org.omg.CORBA +com.sun.corba.se.pept.broker +com.sun.corba.se.pept.encoding +com.sun.corba.se.pept.protocol +com.sun.corba.se.pept.transport +com.sun.corba.se.spi.activation +com.sun.corba.se.spi.activation.InitialNameServicePackage +com.sun.corba.se.spi.activation.LocatorPackage +com.sun.corba.se.spi.activation.RepositoryPackage +com.sun.corba.se.spi.copyobject +com.sun.corba.se.spi.encoding +com.sun.corba.se.spi.extension +com.sun.corba.se.spi.ior +com.sun.corba.se.spi.ior.iiop +com.sun.corba.se.spi.legacy.connection +com.sun.corba.se.spi.legacy.interceptor +com.sun.corba.se.spi.logging +com.sun.corba.se.spi.monitoring +com.sun.corba.se.spi.oa +com.sun.corba.se.spi.orb +com.sun.corba.se.spi.orbutil.closure +com.sun.corba.se.spi.orbutil.fsm +com.sun.corba.se.spi.orbutil.proxy +com.sun.corba.se.spi.orbutil.threadpool +com.sun.corba.se.spi.presentation.rmi +com.sun.corba.se.spi.protocol +com.sun.corba.se.spi.resolver +com.sun.corba.se.spi.servicecontext +com.sun.corba.se.spi.transport +com.sun.crypto.provider +com.sun.demo.jvmti.hprof +com.sun.deploy.uitoolkit.impl.fx +com.sun.deploy.uitoolkit.impl.fx.ui +com.sun.deploy.uitoolkit.impl.fx.ui.resources +com.sun.glass.events +com.sun.glass.events.mac +com.sun.glass.ui +com.sun.glass.ui.delegate +com.sun.glass.ui.gtk +com.sun.glass.ui.mac +com.sun.glass.ui.win +com.sun.glass.utils +com.sun.image.codec.jpeg +com.sun.imageio.plugins.bmp +com.sun.imageio.plugins.common +com.sun.imageio.plugins.gif +com.sun.imageio.plugins.jpeg +com.sun.imageio.plugins.png +com.sun.imageio.plugins.wbmp +com.sun.imageio.spi +com.sun.imageio.stream +com.sun.istack.internal +com.sun.istack.internal.localization +com.sun.istack.internal.logging +com.sun.istack.internal.tools +com.sun.java.accessibility +com.sun.java.accessibility.util.java.awt +com.sun.java.browser.dom +com.sun.java.browser.net +com.sun.java.swing +com.sun.java.swing.plaf.gtk +com.sun.java.swing.plaf.gtk.resources +com.sun.java.swing.plaf.motif +com.sun.java.swing.plaf.motif.resources +com.sun.java.swing.plaf.nimbus +com.sun.java.swing.plaf.windows +com.sun.java.swing.plaf.windows.resources +com.sun.java.util.jar.pack +com.sun.java_cup.internal.runtime +com.sun.javafx +com.sun.javafx.animation +com.sun.javafx.applet +com.sun.javafx.application +com.sun.javafx.beans +com.sun.javafx.beans.event +com.sun.javafx.binding +com.sun.javafx.charts +com.sun.javafx.collections +com.sun.javafx.css +com.sun.javafx.css.converters +com.sun.javafx.css.parser +com.sun.javafx.cursor +com.sun.javafx.effect +com.sun.javafx.embed +com.sun.javafx.event +com.sun.javafx.font +com.sun.javafx.font.coretext +com.sun.javafx.font.directwrite +com.sun.javafx.font.freetype +com.sun.javafx.font.t2k +com.sun.javafx.fxml +com.sun.javafx.fxml.builder +com.sun.javafx.fxml.expression +com.sun.javafx.geom +com.sun.javafx.geom.transform +com.sun.javafx.geometry +com.sun.javafx.iio +com.sun.javafx.iio.bmp +com.sun.javafx.iio.common +com.sun.javafx.iio.gif +com.sun.javafx.iio.ios +com.sun.javafx.iio.jpeg +com.sun.javafx.iio.png +com.sun.javafx.image +com.sun.javafx.image.impl +com.sun.javafx.jmx +com.sun.javafx.logging +com.sun.javafx.media +com.sun.javafx.menu +com.sun.javafx.perf +com.sun.javafx.print +com.sun.javafx.property +com.sun.javafx.property.adapter +com.sun.javafx.robot +com.sun.javafx.robot.impl +com.sun.javafx.runtime +com.sun.javafx.runtime.async +com.sun.javafx.runtime.eula +com.sun.javafx.scene +com.sun.javafx.scene.control +com.sun.javafx.scene.control.behavior +com.sun.javafx.scene.control.skin +com.sun.javafx.scene.control.skin.resources +com.sun.javafx.scene.input +com.sun.javafx.scene.layout.region +com.sun.javafx.scene.paint +com.sun.javafx.scene.shape +com.sun.javafx.scene.text +com.sun.javafx.scene.transform +com.sun.javafx.scene.traversal +com.sun.javafx.scene.web +com.sun.javafx.scene.web.behavior +com.sun.javafx.scene.web.skin +com.sun.javafx.sg.prism +com.sun.javafx.sg.prism.web +com.sun.javafx.stage +com.sun.javafx.text +com.sun.javafx.tk +com.sun.javafx.tk.quantum +com.sun.javafx.util +com.sun.javafx.webkit +com.sun.javafx.webkit.drt +com.sun.javafx.webkit.prism +com.sun.javafx.webkit.prism.theme +com.sun.javafx.webkit.theme +com.sun.jmx.defaults +com.sun.jmx.interceptor +com.sun.jmx.mbeanserver +com.sun.jmx.remote.internal +com.sun.jmx.remote.protocol.iiop +com.sun.jmx.remote.protocol.rmi +com.sun.jmx.remote.security +com.sun.jmx.remote.util +com.sun.jmx.snmp +com.sun.jmx.snmp.IPAcl +com.sun.jmx.snmp.agent +com.sun.jmx.snmp.daemon +com.sun.jmx.snmp.defaults +com.sun.jmx.snmp.internal +com.sun.jmx.snmp.mpm +com.sun.jmx.snmp.tasks +com.sun.jndi.cosnaming +com.sun.jndi.dns +com.sun.jndi.ldap +com.sun.jndi.ldap.ext +com.sun.jndi.ldap.pool +com.sun.jndi.ldap.sasl +com.sun.jndi.rmi.registry +com.sun.jndi.toolkit.corba +com.sun.jndi.toolkit.ctx +com.sun.jndi.toolkit.dir +com.sun.jndi.toolkit.url +com.sun.jndi.url.corbaname +com.sun.jndi.url.dns +com.sun.jndi.url.iiop +com.sun.jndi.url.iiopname +com.sun.jndi.url.ldap +com.sun.jndi.url.ldaps +com.sun.jndi.url.rmi +com.sun.management.jmx +com.sun.media.jfxmedia +com.sun.media.jfxmedia.control +com.sun.media.jfxmedia.effects +com.sun.media.jfxmedia.events +com.sun.media.jfxmedia.locator +com.sun.media.jfxmedia.logging +com.sun.media.jfxmedia.track +com.sun.media.jfxmediaimpl +com.sun.media.jfxmediaimpl.platform +com.sun.media.jfxmediaimpl.platform.gstreamer +com.sun.media.jfxmediaimpl.platform.ios +com.sun.media.jfxmediaimpl.platform.java +com.sun.media.jfxmediaimpl.platform.osx +com.sun.media.sound +com.sun.naming.internal +com.sun.net.ssl +com.sun.net.ssl.internal.ssl +com.sun.net.ssl.internal.www.protocol.https +com.sun.nio.file +com.sun.nio.zipfs +com.sun.openpisces +com.sun.org.apache.bcel.internal +com.sun.org.apache.bcel.internal.classfile +com.sun.org.apache.bcel.internal.generic +com.sun.org.apache.bcel.internal.util +com.sun.org.apache.regexp.internal +com.sun.org.apache.xalan.internal +com.sun.org.apache.xalan.internal.extensions +com.sun.org.apache.xalan.internal.lib +com.sun.org.apache.xalan.internal.res +com.sun.org.apache.xalan.internal.templates +com.sun.org.apache.xalan.internal.utils +com.sun.org.apache.xalan.internal.xslt +com.sun.org.apache.xalan.internal.xsltc +com.sun.org.apache.xalan.internal.xsltc.cmdline +com.sun.org.apache.xalan.internal.xsltc.cmdline.getopt +com.sun.org.apache.xalan.internal.xsltc.compiler +com.sun.org.apache.xalan.internal.xsltc.compiler.util +com.sun.org.apache.xalan.internal.xsltc.dom +com.sun.org.apache.xalan.internal.xsltc.runtime +com.sun.org.apache.xalan.internal.xsltc.runtime.output +com.sun.org.apache.xalan.internal.xsltc.trax +com.sun.org.apache.xalan.internal.xsltc.util +com.sun.org.apache.xerces.internal.dom +com.sun.org.apache.xerces.internal.dom.events +com.sun.org.apache.xerces.internal.impl +com.sun.org.apache.xerces.internal.impl.dtd +com.sun.org.apache.xerces.internal.impl.dtd.models +com.sun.org.apache.xerces.internal.impl.dv +com.sun.org.apache.xerces.internal.impl.dv.dtd +com.sun.org.apache.xerces.internal.impl.dv.util +com.sun.org.apache.xerces.internal.impl.dv.xs +com.sun.org.apache.xerces.internal.impl.io +com.sun.org.apache.xerces.internal.impl.msg +com.sun.org.apache.xerces.internal.impl.validation +com.sun.org.apache.xerces.internal.impl.xpath +com.sun.org.apache.xerces.internal.impl.xpath.regex +com.sun.org.apache.xerces.internal.impl.xs +com.sun.org.apache.xerces.internal.impl.xs.identity +com.sun.org.apache.xerces.internal.impl.xs.models +com.sun.org.apache.xerces.internal.impl.xs.opti +com.sun.org.apache.xerces.internal.impl.xs.traversers +com.sun.org.apache.xerces.internal.impl.xs.util +com.sun.org.apache.xerces.internal.jaxp +com.sun.org.apache.xerces.internal.jaxp.datatype +com.sun.org.apache.xerces.internal.jaxp.validation +com.sun.org.apache.xerces.internal.parsers +com.sun.org.apache.xerces.internal.util +com.sun.org.apache.xerces.internal.utils +com.sun.org.apache.xerces.internal.xinclude +com.sun.org.apache.xerces.internal.xni +com.sun.org.apache.xerces.internal.xni.grammars +com.sun.org.apache.xerces.internal.xni.parser +com.sun.org.apache.xerces.internal.xpointer +com.sun.org.apache.xerces.internal.xs +com.sun.org.apache.xerces.internal.xs.datatypes +com.sun.org.apache.xml.internal.dtm +com.sun.org.apache.xml.internal.dtm.ref +com.sun.org.apache.xml.internal.dtm.ref.dom2dtm +com.sun.org.apache.xml.internal.dtm.ref.sax2dtm +com.sun.org.apache.xml.internal.res +com.sun.org.apache.xml.internal.resolver +com.sun.org.apache.xml.internal.resolver.helpers +com.sun.org.apache.xml.internal.resolver.readers +com.sun.org.apache.xml.internal.resolver.tools +com.sun.org.apache.xml.internal.security +com.sun.org.apache.xml.internal.security.algorithms +com.sun.org.apache.xml.internal.security.algorithms.implementations +com.sun.org.apache.xml.internal.security.c14n +com.sun.org.apache.xml.internal.security.c14n.helper +com.sun.org.apache.xml.internal.security.c14n.implementations +com.sun.org.apache.xml.internal.security.encryption +com.sun.org.apache.xml.internal.security.exceptions +com.sun.org.apache.xml.internal.security.keys +com.sun.org.apache.xml.internal.security.keys.content +com.sun.org.apache.xml.internal.security.keys.content.keyvalues +com.sun.org.apache.xml.internal.security.keys.content.x509 +com.sun.org.apache.xml.internal.security.keys.keyresolver +com.sun.org.apache.xml.internal.security.keys.keyresolver.implementations +com.sun.org.apache.xml.internal.security.keys.storage +com.sun.org.apache.xml.internal.security.keys.storage.implementations +com.sun.org.apache.xml.internal.security.signature +com.sun.org.apache.xml.internal.security.signature.reference +com.sun.org.apache.xml.internal.security.transforms +com.sun.org.apache.xml.internal.security.transforms.implementations +com.sun.org.apache.xml.internal.security.transforms.params +com.sun.org.apache.xml.internal.security.utils +com.sun.org.apache.xml.internal.security.utils.resolver +com.sun.org.apache.xml.internal.security.utils.resolver.implementations +com.sun.org.apache.xml.internal.serialize +com.sun.org.apache.xml.internal.serializer +com.sun.org.apache.xml.internal.serializer.utils +com.sun.org.apache.xml.internal.utils +com.sun.org.apache.xml.internal.utils.res +com.sun.org.apache.xpath.internal +com.sun.org.apache.xpath.internal.axes +com.sun.org.apache.xpath.internal.compiler +com.sun.org.apache.xpath.internal.domapi +com.sun.org.apache.xpath.internal.functions +com.sun.org.apache.xpath.internal.jaxp +com.sun.org.apache.xpath.internal.objects +com.sun.org.apache.xpath.internal.operations +com.sun.org.apache.xpath.internal.patterns +com.sun.org.apache.xpath.internal.res +com.sun.org.glassfish.external.amx +com.sun.org.glassfish.external.arc +com.sun.org.glassfish.external.probe.provider +com.sun.org.glassfish.external.probe.provider.annotations +com.sun.org.glassfish.external.statistics +com.sun.org.glassfish.external.statistics.annotations +com.sun.org.glassfish.external.statistics.impl +com.sun.org.glassfish.gmbal +com.sun.org.glassfish.gmbal.util +com.sun.org.omg.CORBA +com.sun.org.omg.CORBA.ValueDefPackage +com.sun.org.omg.CORBA.portable +com.sun.org.omg.SendingContext +com.sun.org.omg.SendingContext.CodeBasePackage +com.sun.pisces +com.sun.prism +com.sun.prism.d3d +com.sun.prism.es2 +com.sun.prism.image +com.sun.prism.impl +com.sun.prism.impl.packrect +com.sun.prism.impl.paint +com.sun.prism.impl.ps +com.sun.prism.impl.shape +com.sun.prism.j2d +com.sun.prism.j2d.paint +com.sun.prism.j2d.print +com.sun.prism.paint +com.sun.prism.ps +com.sun.prism.shader +com.sun.prism.shape +com.sun.prism.sw +com.sun.rmi.rmid +com.sun.rowset +com.sun.rowset.internal +com.sun.rowset.providers +com.sun.scenario +com.sun.scenario.animation +com.sun.scenario.animation.shared +com.sun.scenario.effect +com.sun.scenario.effect.impl +com.sun.scenario.effect.impl.es2 +com.sun.scenario.effect.impl.hw +com.sun.scenario.effect.impl.hw.d3d +com.sun.scenario.effect.impl.prism +com.sun.scenario.effect.impl.prism.ps +com.sun.scenario.effect.impl.prism.sw +com.sun.scenario.effect.impl.state +com.sun.scenario.effect.impl.sw +com.sun.scenario.effect.impl.sw.java +com.sun.scenario.effect.impl.sw.sse +com.sun.scenario.effect.light +com.sun.security.cert.internal.x509 +com.sun.security.ntlm +com.sun.security.sasl +com.sun.security.sasl.digest +com.sun.security.sasl.gsskerb +com.sun.security.sasl.ntlm +com.sun.security.sasl.util +com.sun.swing.internal.plaf.basic.resources +com.sun.swing.internal.plaf.metal.resources +com.sun.swing.internal.plaf.synth.resources +com.sun.tools.classfile +com.sun.tools.corba.se.idl +com.sun.tools.corba.se.idl.constExpr +com.sun.tools.corba.se.idl.som.cff +com.sun.tools.corba.se.idl.som.idlemit +com.sun.tools.corba.se.idl.toJavaPortable +com.sun.tools.doclets.formats.html +com.sun.tools.doclets.formats.html.markup +com.sun.tools.doclets.formats.html.resources +com.sun.tools.doclets.internal.toolkit +com.sun.tools.doclets.internal.toolkit.builders +com.sun.tools.doclets.internal.toolkit.resources +com.sun.tools.doclets.internal.toolkit.taglets +com.sun.tools.doclets.internal.toolkit.util +com.sun.tools.doclets.internal.toolkit.util.links +com.sun.tools.doclint +com.sun.tools.doclint.resources +com.sun.tools.example.debug.expr +com.sun.tools.example.debug.tty +com.sun.tools.extcheck +com.sun.tools.hat +com.sun.tools.hat.internal.model +com.sun.tools.hat.internal.oql +com.sun.tools.hat.internal.parser +com.sun.tools.hat.internal.server +com.sun.tools.hat.internal.util +com.sun.tools.internal.jxc +com.sun.tools.internal.jxc.ap +com.sun.tools.internal.jxc.api +com.sun.tools.internal.jxc.api.impl.j2s +com.sun.tools.internal.jxc.gen.config +com.sun.tools.internal.jxc.model.nav +com.sun.tools.internal.ws +com.sun.tools.internal.ws.api +com.sun.tools.internal.ws.api.wsdl +com.sun.tools.internal.ws.processor +com.sun.tools.internal.ws.processor.generator +com.sun.tools.internal.ws.processor.model +com.sun.tools.internal.ws.processor.model.exporter +com.sun.tools.internal.ws.processor.model.java +com.sun.tools.internal.ws.processor.model.jaxb +com.sun.tools.internal.ws.processor.modeler +com.sun.tools.internal.ws.processor.modeler.annotation +com.sun.tools.internal.ws.processor.modeler.wsdl +com.sun.tools.internal.ws.processor.util +com.sun.tools.internal.ws.resources +com.sun.tools.internal.ws.spi +com.sun.tools.internal.ws.util +com.sun.tools.internal.ws.util.xml +com.sun.tools.internal.ws.wscompile +com.sun.tools.internal.ws.wscompile.plugin.at_generated +com.sun.tools.internal.ws.wsdl.document +com.sun.tools.internal.ws.wsdl.document.http +com.sun.tools.internal.ws.wsdl.document.jaxws +com.sun.tools.internal.ws.wsdl.document.mime +com.sun.tools.internal.ws.wsdl.document.schema +com.sun.tools.internal.ws.wsdl.document.soap +com.sun.tools.internal.ws.wsdl.framework +com.sun.tools.internal.ws.wsdl.parser +com.sun.tools.internal.xjc +com.sun.tools.internal.xjc.addon.accessors +com.sun.tools.internal.xjc.addon.at_generated +com.sun.tools.internal.xjc.addon.code_injector +com.sun.tools.internal.xjc.addon.episode +com.sun.tools.internal.xjc.addon.locator +com.sun.tools.internal.xjc.addon.sync +com.sun.tools.internal.xjc.api +com.sun.tools.internal.xjc.api.impl.s2j +com.sun.tools.internal.xjc.api.util +com.sun.tools.internal.xjc.generator.annotation.spec +com.sun.tools.internal.xjc.generator.bean +com.sun.tools.internal.xjc.generator.bean.field +com.sun.tools.internal.xjc.generator.util +com.sun.tools.internal.xjc.model +com.sun.tools.internal.xjc.model.nav +com.sun.tools.internal.xjc.outline +com.sun.tools.internal.xjc.reader +com.sun.tools.internal.xjc.reader.dtd +com.sun.tools.internal.xjc.reader.dtd.bindinfo +com.sun.tools.internal.xjc.reader.gbind +com.sun.tools.internal.xjc.reader.internalizer +com.sun.tools.internal.xjc.reader.relaxng +com.sun.tools.internal.xjc.reader.xmlschema +com.sun.tools.internal.xjc.reader.xmlschema.bindinfo +com.sun.tools.internal.xjc.reader.xmlschema.ct +com.sun.tools.internal.xjc.reader.xmlschema.parser +com.sun.tools.internal.xjc.runtime +com.sun.tools.internal.xjc.util +com.sun.tools.internal.xjc.writer +com.sun.tools.javac.api +com.sun.tools.javac.code +com.sun.tools.javac.comp +com.sun.tools.javac.file +com.sun.tools.javac.jvm +com.sun.tools.javac.main +com.sun.tools.javac.model +com.sun.tools.javac.nio +com.sun.tools.javac.parser +com.sun.tools.javac.processing +com.sun.tools.javac.resources +com.sun.tools.javac.sym +com.sun.tools.javac.tree +com.sun.tools.javac.util +com.sun.tools.javadoc.api +com.sun.tools.javadoc.resources +com.sun.tools.javah +com.sun.tools.javah.resources +com.sun.tools.javap +com.sun.tools.javap.resources +com.sun.tools.jdeps +com.sun.tools.jdeps.resources +com.sun.tools.jdi +com.sun.tools.jdi.resources +com.sun.tools.script.shell +com.sun.tracing +com.sun.tracing.dtrace +com.sun.webkit +com.sun.webkit.dom +com.sun.webkit.event +com.sun.webkit.graphics +com.sun.webkit.network +com.sun.webkit.network.about +com.sun.webkit.network.data +com.sun.webkit.perf +com.sun.webkit.plugin +com.sun.webkit.text +com.sun.xml.internal.bind +com.sun.xml.internal.bind.annotation +com.sun.xml.internal.bind.api +com.sun.xml.internal.bind.api.impl +com.sun.xml.internal.bind.marshaller +com.sun.xml.internal.bind.unmarshaller +com.sun.xml.internal.bind.util +com.sun.xml.internal.bind.v2 +com.sun.xml.internal.bind.v2.bytecode +com.sun.xml.internal.bind.v2.model.annotation +com.sun.xml.internal.bind.v2.model.core +com.sun.xml.internal.bind.v2.model.impl +com.sun.xml.internal.bind.v2.model.nav +com.sun.xml.internal.bind.v2.model.runtime +com.sun.xml.internal.bind.v2.model.util +com.sun.xml.internal.bind.v2.runtime +com.sun.xml.internal.bind.v2.runtime.output +com.sun.xml.internal.bind.v2.runtime.property +com.sun.xml.internal.bind.v2.runtime.reflect +com.sun.xml.internal.bind.v2.runtime.reflect.opt +com.sun.xml.internal.bind.v2.runtime.unmarshaller +com.sun.xml.internal.bind.v2.schemagen +com.sun.xml.internal.bind.v2.schemagen.episode +com.sun.xml.internal.bind.v2.schemagen.xmlschema +com.sun.xml.internal.bind.v2.util +com.sun.xml.internal.dtdparser +com.sun.xml.internal.fastinfoset +com.sun.xml.internal.fastinfoset.algorithm +com.sun.xml.internal.fastinfoset.alphabet +com.sun.xml.internal.fastinfoset.dom +com.sun.xml.internal.fastinfoset.org.apache.xerces.util +com.sun.xml.internal.fastinfoset.sax +com.sun.xml.internal.fastinfoset.stax +com.sun.xml.internal.fastinfoset.stax.events +com.sun.xml.internal.fastinfoset.stax.factory +com.sun.xml.internal.fastinfoset.stax.util +com.sun.xml.internal.fastinfoset.tools +com.sun.xml.internal.fastinfoset.util +com.sun.xml.internal.fastinfoset.vocab +com.sun.xml.internal.messaging.saaj +com.sun.xml.internal.messaging.saaj.client.p2p +com.sun.xml.internal.messaging.saaj.packaging.mime +com.sun.xml.internal.messaging.saaj.packaging.mime.internet +com.sun.xml.internal.messaging.saaj.packaging.mime.util +com.sun.xml.internal.messaging.saaj.soap +com.sun.xml.internal.messaging.saaj.soap.dynamic +com.sun.xml.internal.messaging.saaj.soap.impl +com.sun.xml.internal.messaging.saaj.soap.name +com.sun.xml.internal.messaging.saaj.soap.ver1_1 +com.sun.xml.internal.messaging.saaj.soap.ver1_2 +com.sun.xml.internal.messaging.saaj.util +com.sun.xml.internal.messaging.saaj.util.transform +com.sun.xml.internal.org.jvnet.fastinfoset +com.sun.xml.internal.org.jvnet.fastinfoset.sax +com.sun.xml.internal.org.jvnet.fastinfoset.sax.helpers +com.sun.xml.internal.org.jvnet.fastinfoset.stax +com.sun.xml.internal.org.jvnet.mimepull +com.sun.xml.internal.org.jvnet.staxex +com.sun.xml.internal.rngom.ast.builder +com.sun.xml.internal.rngom.ast.om +com.sun.xml.internal.rngom.ast.util +com.sun.xml.internal.rngom.binary +com.sun.xml.internal.rngom.binary.visitor +com.sun.xml.internal.rngom.digested +com.sun.xml.internal.rngom.dt +com.sun.xml.internal.rngom.dt.builtin +com.sun.xml.internal.rngom.nc +com.sun.xml.internal.rngom.parse +com.sun.xml.internal.rngom.parse.compact +com.sun.xml.internal.rngom.parse.host +com.sun.xml.internal.rngom.parse.xml +com.sun.xml.internal.rngom.util +com.sun.xml.internal.rngom.xml.sax +com.sun.xml.internal.rngom.xml.util +com.sun.xml.internal.stream +com.sun.xml.internal.stream.buffer +com.sun.xml.internal.stream.buffer.sax +com.sun.xml.internal.stream.buffer.stax +com.sun.xml.internal.stream.dtd +com.sun.xml.internal.stream.dtd.nonvalidating +com.sun.xml.internal.stream.events +com.sun.xml.internal.stream.util +com.sun.xml.internal.stream.writers +com.sun.xml.internal.txw2 +com.sun.xml.internal.txw2.annotation +com.sun.xml.internal.txw2.output +com.sun.xml.internal.ws +com.sun.xml.internal.ws.addressing +com.sun.xml.internal.ws.addressing.model +com.sun.xml.internal.ws.addressing.policy +com.sun.xml.internal.ws.addressing.v200408 +com.sun.xml.internal.ws.api +com.sun.xml.internal.ws.api.addressing +com.sun.xml.internal.ws.api.client +com.sun.xml.internal.ws.api.config.management +com.sun.xml.internal.ws.api.config.management.policy +com.sun.xml.internal.ws.api.databinding +com.sun.xml.internal.ws.api.fastinfoset +com.sun.xml.internal.ws.api.ha +com.sun.xml.internal.ws.api.handler +com.sun.xml.internal.ws.api.message +com.sun.xml.internal.ws.api.message.saaj +com.sun.xml.internal.ws.api.message.stream +com.sun.xml.internal.ws.api.model +com.sun.xml.internal.ws.api.model.soap +com.sun.xml.internal.ws.api.model.wsdl +com.sun.xml.internal.ws.api.model.wsdl.editable +com.sun.xml.internal.ws.api.pipe +com.sun.xml.internal.ws.api.pipe.helper +com.sun.xml.internal.ws.api.policy +com.sun.xml.internal.ws.api.policy.subject +com.sun.xml.internal.ws.api.server +com.sun.xml.internal.ws.api.streaming +com.sun.xml.internal.ws.api.wsdl.parser +com.sun.xml.internal.ws.api.wsdl.writer +com.sun.xml.internal.ws.assembler +com.sun.xml.internal.ws.assembler.dev +com.sun.xml.internal.ws.assembler.jaxws +com.sun.xml.internal.ws.binding +com.sun.xml.internal.ws.client +com.sun.xml.internal.ws.client.dispatch +com.sun.xml.internal.ws.client.sei +com.sun.xml.internal.ws.commons.xmlutil +com.sun.xml.internal.ws.config.management.policy +com.sun.xml.internal.ws.config.metro.dev +com.sun.xml.internal.ws.config.metro.util +com.sun.xml.internal.ws.db +com.sun.xml.internal.ws.db.glassfish +com.sun.xml.internal.ws.developer +com.sun.xml.internal.ws.dump +com.sun.xml.internal.ws.encoding +com.sun.xml.internal.ws.encoding.fastinfoset +com.sun.xml.internal.ws.encoding.policy +com.sun.xml.internal.ws.encoding.soap +com.sun.xml.internal.ws.encoding.soap.streaming +com.sun.xml.internal.ws.encoding.xml +com.sun.xml.internal.ws.fault +com.sun.xml.internal.ws.handler +com.sun.xml.internal.ws.message +com.sun.xml.internal.ws.message.jaxb +com.sun.xml.internal.ws.message.saaj +com.sun.xml.internal.ws.message.source +com.sun.xml.internal.ws.message.stream +com.sun.xml.internal.ws.model +com.sun.xml.internal.ws.model.soap +com.sun.xml.internal.ws.model.wsdl +com.sun.xml.internal.ws.org.objectweb.asm +com.sun.xml.internal.ws.policy +com.sun.xml.internal.ws.policy.jaxws +com.sun.xml.internal.ws.policy.jaxws.spi +com.sun.xml.internal.ws.policy.privateutil +com.sun.xml.internal.ws.policy.sourcemodel +com.sun.xml.internal.ws.policy.sourcemodel.attach +com.sun.xml.internal.ws.policy.sourcemodel.wspolicy +com.sun.xml.internal.ws.policy.spi +com.sun.xml.internal.ws.policy.subject +com.sun.xml.internal.ws.protocol.soap +com.sun.xml.internal.ws.protocol.xml +com.sun.xml.internal.ws.resources +com.sun.xml.internal.ws.runtime.config +com.sun.xml.internal.ws.server +com.sun.xml.internal.ws.server.provider +com.sun.xml.internal.ws.server.sei +com.sun.xml.internal.ws.spi +com.sun.xml.internal.ws.spi.db +com.sun.xml.internal.ws.streaming +com.sun.xml.internal.ws.transport +com.sun.xml.internal.ws.transport.http +com.sun.xml.internal.ws.transport.http.client +com.sun.xml.internal.ws.transport.http.server +com.sun.xml.internal.ws.util +com.sun.xml.internal.ws.util.exception +com.sun.xml.internal.ws.util.pipe +com.sun.xml.internal.ws.util.xml +com.sun.xml.internal.ws.wsdl +com.sun.xml.internal.ws.wsdl.parser +com.sun.xml.internal.ws.wsdl.writer +com.sun.xml.internal.ws.wsdl.writer.document +com.sun.xml.internal.ws.wsdl.writer.document.http +com.sun.xml.internal.ws.wsdl.writer.document.soap +com.sun.xml.internal.ws.wsdl.writer.document.soap12 +com.sun.xml.internal.ws.wsdl.writer.document.xsd +com.sun.xml.internal.xsom +com.sun.xml.internal.xsom.impl +com.sun.xml.internal.xsom.impl.parser +com.sun.xml.internal.xsom.impl.parser.state +com.sun.xml.internal.xsom.impl.scd +com.sun.xml.internal.xsom.impl.util +com.sun.xml.internal.xsom.parser +com.sun.xml.internal.xsom.util +com.sun.xml.internal.xsom.visitor +java.awt.dnd.peer +java.awt.peer +javafx.embed.swt +jdk +jdk.internal.cmm +jdk.internal.dynalink +jdk.internal.dynalink.beans +jdk.internal.dynalink.linker +jdk.internal.dynalink.support +jdk.internal.instrumentation +jdk.internal.org.objectweb.asm +jdk.internal.org.objectweb.asm.commons +jdk.internal.org.objectweb.asm.signature +jdk.internal.org.objectweb.asm.tree +jdk.internal.org.objectweb.asm.tree.analysis +jdk.internal.org.objectweb.asm.util +jdk.internal.org.xml.sax +jdk.internal.org.xml.sax.helpers +jdk.internal.util.xml +jdk.internal.util.xml.impl +jdk.jfr.events +jdk.management.resource.internal +jdk.management.resource.internal.inst +jdk.nashorn.internal +jdk.nashorn.internal.codegen +jdk.nashorn.internal.codegen.types +jdk.nashorn.internal.ir +jdk.nashorn.internal.ir.annotations +jdk.nashorn.internal.ir.debug +jdk.nashorn.internal.ir.visitor +jdk.nashorn.internal.lookup +jdk.nashorn.internal.objects +jdk.nashorn.internal.objects.annotations +jdk.nashorn.internal.parser +jdk.nashorn.internal.runtime +jdk.nashorn.internal.runtime.arrays +jdk.nashorn.internal.runtime.events +jdk.nashorn.internal.runtime.linker +jdk.nashorn.internal.runtime.logging +jdk.nashorn.internal.runtime.options +jdk.nashorn.internal.runtime.regexp +jdk.nashorn.internal.runtime.regexp.joni +jdk.nashorn.internal.runtime.regexp.joni.ast +jdk.nashorn.internal.runtime.regexp.joni.constants +jdk.nashorn.internal.runtime.regexp.joni.encoding +jdk.nashorn.internal.runtime.regexp.joni.exception +jdk.nashorn.internal.scripts +jdk.nashorn.tools +oracle.jrockit.jfr +oracle.jrockit.jfr.events +oracle.jrockit.jfr.jdkevents +oracle.jrockit.jfr.jdkevents.throwabletransform +oracle.jrockit.jfr.openmbean +oracle.jrockit.jfr.parser +oracle.jrockit.jfr.settings +oracle.jrockit.jfr.tools +org.jcp.xml.dsig.internal +org.jcp.xml.dsig.internal.dom +org.omg.stub.javax.management.remote.rmi +org.relaxng.datatype +org.relaxng.datatype.helpers +sun.applet +sun.applet.resources +sun.audio +sun.awt +sun.awt.X11 +sun.awt.datatransfer +sun.awt.dnd +sun.awt.event +sun.awt.geom +sun.awt.im +sun.awt.image +sun.awt.image.codec +sun.awt.motif +sun.awt.resources +sun.awt.shell +sun.awt.util +sun.awt.windows +sun.corba +sun.dc +sun.dc.path +sun.dc.pr +sun.font +sun.instrument +sun.invoke +sun.invoke.anon +sun.invoke.empty +sun.invoke.util +sun.io +sun.java2d +sun.java2d.cmm +sun.java2d.cmm.kcms +sun.java2d.cmm.lcms +sun.java2d.d3d +sun.java2d.jules +sun.java2d.loops +sun.java2d.opengl +sun.java2d.pipe +sun.java2d.pipe.hw +sun.java2d.pisces +sun.java2d.windows +sun.java2d.x11 +sun.java2d.xr +sun.jvmstat.monitor +sun.jvmstat.monitor.event +sun.jvmstat.monitor.remote +sun.jvmstat.perfdata.monitor +sun.jvmstat.perfdata.monitor.protocol.file +sun.jvmstat.perfdata.monitor.protocol.local +sun.jvmstat.perfdata.monitor.protocol.rmi +sun.jvmstat.perfdata.monitor.v1_0 +sun.jvmstat.perfdata.monitor.v2_0 +sun.launcher +sun.launcher.resources +sun.lwawt +sun.lwawt.macosx +sun.management +sun.management.counter +sun.management.counter.perf +sun.management.jdp +sun.management.jmxremote +sun.management.resources +sun.management.snmp +sun.management.snmp.jvminstr +sun.management.snmp.jvmmib +sun.management.snmp.util +sun.misc +sun.misc.resources +sun.net +sun.net.dns +sun.net.ftp +sun.net.ftp.impl +sun.net.httpserver +sun.net.idn +sun.net.sdp +sun.net.smtp +sun.net.spi +sun.net.spi.nameservice +sun.net.spi.nameservice.dns +sun.net.util +sun.net.www +sun.net.www.content.audio +sun.net.www.content.image +sun.net.www.content.text +sun.net.www.http +sun.net.www.protocol.file +sun.net.www.protocol.ftp +sun.net.www.protocol.http +sun.net.www.protocol.http.logging +sun.net.www.protocol.http.ntlm +sun.net.www.protocol.http.spnego +sun.net.www.protocol.https +sun.net.www.protocol.jar +sun.net.www.protocol.mailto +sun.net.www.protocol.netdoc +sun.nio +sun.nio.ch +sun.nio.ch.sctp +sun.nio.cs +sun.nio.cs.ext +sun.nio.fs +sun.print +sun.print.resources +sun.reflect +sun.reflect.annotation +sun.reflect.generics.factory +sun.reflect.generics.parser +sun.reflect.generics.reflectiveObjects +sun.reflect.generics.repository +sun.reflect.generics.scope +sun.reflect.generics.tree +sun.reflect.generics.visitor +sun.reflect.misc +sun.rmi.log +sun.rmi.registry +sun.rmi.rmic +sun.rmi.rmic.iiop +sun.rmi.rmic.newrmic +sun.rmi.rmic.newrmic.jrmp +sun.rmi.runtime +sun.rmi.server +sun.rmi.transport +sun.rmi.transport.proxy +sun.rmi.transport.tcp +sun.security.acl +sun.security.action +sun.security.ec +sun.security.internal.interfaces +sun.security.internal.spec +sun.security.jca +sun.security.jgss +sun.security.jgss.krb5 +sun.security.jgss.spi +sun.security.jgss.spnego +sun.security.jgss.wrapper +sun.security.krb5 +sun.security.krb5.internal +sun.security.krb5.internal.ccache +sun.security.krb5.internal.crypto +sun.security.krb5.internal.crypto.dk +sun.security.krb5.internal.ktab +sun.security.krb5.internal.rcache +sun.security.krb5.internal.tools +sun.security.krb5.internal.util +sun.security.mscapi +sun.security.pkcs +sun.security.pkcs10 +sun.security.pkcs11 +sun.security.pkcs11.wrapper +sun.security.pkcs12 +sun.security.provider +sun.security.provider.certpath +sun.security.provider.certpath.ldap +sun.security.provider.certpath.ssl +sun.security.rsa +sun.security.smartcardio +sun.security.ssl +sun.security.ssl.krb5 +sun.security.timestamp +sun.security.tools +sun.security.tools.jarsigner +sun.security.tools.keytool +sun.security.tools.policytool +sun.security.util +sun.security.validator +sun.security.x509 +sun.swing +sun.swing.icon +sun.swing.plaf +sun.swing.plaf.synth +sun.swing.plaf.windows +sun.swing.table +sun.swing.text +sun.swing.text.html +sun.text +sun.text.bidi +sun.text.normalizer +sun.text.resources +sun.text.resources.en +sun.tools.asm +sun.tools.attach +sun.tools.jar +sun.tools.jar.resources +sun.tools.java +sun.tools.javac +sun.tools.jcmd +sun.tools.jconsole +sun.tools.jconsole.inspector +sun.tools.jinfo +sun.tools.jmap +sun.tools.jps +sun.tools.jstack +sun.tools.jstat +sun.tools.jstatd +sun.tools.native2ascii +sun.tools.native2ascii.resources +sun.tools.serialver +sun.tools.tree +sun.tools.util +sun.tracing +sun.tracing.dtrace +sun.usagetracker +sun.util +sun.util.calendar +sun.util.cldr +sun.util.locale +sun.util.locale.provider +sun.util.logging +sun.util.logging.resources +sun.util.resources +sun.util.resources.en +sun.util.spi +sun.util.xml diff -r 5a66e43d8cbd -r 5bf88dce615f langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdkinternals.properties --- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdkinternals.properties Wed Jul 05 21:57:12 2017 +0200 +++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdkinternals.properties Wed Jul 05 21:58:29 2017 +0200 @@ -28,7 +28,7 @@ sun.security.x509.X500Name=Use javax.security.auth.x500.X500Principal @since 1.4 sun.tools.jar=Use java.util.jar or jar tool @since 1.2 # Internal APIs removed in JDK 9 -com.apple.eawt=Use java.awt.desktop and JEP 272 @since 9 +com.apple.eawt=Use java.awt.Desktop and JEP 272 @since 9 com.apple.concurrent=Removed. See https://bugs.openjdk.java.net/browse/JDK-8148187 com.sun.image.codec.jpeg=Use javax.imageio @since 1.4 sun.awt.image.codec=Use javax.imageio @since 1.4 diff -r 5a66e43d8cbd -r 5bf88dce615f langtools/test/ProblemList.txt --- a/langtools/test/ProblemList.txt Wed Jul 05 21:57:12 2017 +0200 +++ b/langtools/test/ProblemList.txt Wed Jul 05 21:58:29 2017 +0200 @@ -27,9 +27,6 @@ # # javadoc -com/sun/javadoc/testTypeAnnotations/TestTypeAnnotations.java 8006735 generic-all output type annotations in javadoc -com/sun/javadoc/typeAnnotations/smoke/TestSmoke.java 8013406 generic-all Test cases fail in javadoc test TestSmoke.java - jdk/javadoc/tool/6176978/T6176978.java 8152049 generic-all no longer applicable, should delete jdk/javadoc/tool/InlineTagsWithBraces.java 8152050 generic-all API, re-evaluate @bold, @maybe causes doclint to throw up. jdk/javadoc/tool/LangVers.java 8152051 generic-all API, re-evaluate, unsure of this test. diff -r 5a66e43d8cbd -r 5bf88dce615f langtools/test/com/sun/javadoc/testTypeAnnotations/TestTypeAnnotations.java --- a/langtools/test/com/sun/javadoc/testTypeAnnotations/TestTypeAnnotations.java Wed Jul 05 21:57:12 2017 +0200 +++ b/langtools/test/com/sun/javadoc/testTypeAnnotations/TestTypeAnnotations.java Wed Jul 05 21:58:29 2017 +0200 @@ -28,7 +28,6 @@ * @author Bhavesh Patel * @library ../lib * @modules jdk.javadoc - * @ignore 8006735 output type annotations in javadoc * @build JavadocTester * @run main TestTypeAnnotations */ diff -r 5a66e43d8cbd -r 5bf88dce615f langtools/test/com/sun/javadoc/typeAnnotations/smoke/TestSmoke.java --- a/langtools/test/com/sun/javadoc/typeAnnotations/smoke/TestSmoke.java Wed Jul 05 21:57:12 2017 +0200 +++ b/langtools/test/com/sun/javadoc/typeAnnotations/smoke/TestSmoke.java Wed Jul 05 21:58:29 2017 +0200 @@ -29,7 +29,6 @@ * @author Mahmood Ali * @library ../../lib * @modules jdk.javadoc - * @ignore * @build JavadocTester * @run main TestSmoke */ diff -r 5a66e43d8cbd -r 5bf88dce615f langtools/test/jdk/javadoc/doclet/testModules/TestModules.java --- a/langtools/test/jdk/javadoc/doclet/testModules/TestModules.java Wed Jul 05 21:57:12 2017 +0200 +++ b/langtools/test/jdk/javadoc/doclet/testModules/TestModules.java Wed Jul 05 21:58:29 2017 +0200 @@ -23,7 +23,7 @@ /* * @test - * @bug 8154119 8154262 8156077 8157987 + * @bug 8154119 8154262 8156077 8157987 8154261 * @summary Test modules support in javadoc. * @author bpatel * @library ../lib @@ -110,6 +110,17 @@ testModuleTags(); } + @Test + void test7() { + javadoc("-d", "out-moduleSummary", "-use", + "-modulesourcepath", testSrc, + "-addmods", "module1,module2", + "testpkgmdl1", "testpkgmdl2", "testpkg2mdl2"); + checkExit(Exit.OK); + testModuleSummary(); + testNegatedModuleSummary(); + } + @Test void test8() { javadoc("-d", "out-html5-nomodule", "-html5", "-use", @@ -139,12 +150,16 @@ "
      \n" + "
        \n" + "
      • \n" - + ""); + + "
          \n" + + "
        • \n" + + ""); checkOutput("module2-summary.html", found, "
          \n" + "
            \n" + "
          • \n" - + "
        "); + + "
          \n" + + "
        • \n" + + ""); } void testHtml5Description(boolean found) { @@ -171,12 +186,16 @@ "
          \n" + "
            \n" + "
          • \n" - + "
        "); + + "
          \n" + + "
        • \n" + + ""); checkOutput("module2-summary.html", found, "
          \n" + "
            \n" + "
          • \n" - + "
        "); + + "
          \n" + + "
        • \n" + + ""); } void testModuleLink() { @@ -313,4 +332,114 @@ + "
        \n" + ""); } + + void testModuleSummary() { + checkOutput("module1-summary.html", true, + ""); + checkOutput("module1-summary.html", true, + "\n" + + "\n" + + "\n" + + ""); + checkOutput("module1-summary.html", true, + "\n" + + "\n" + + "\n" + + "\n" + + ""); + checkOutput("module1-summary.html", true, + "\n" + + "\n" + + "\n" + + ""); + checkOutput("module1-summary.html", true, + "\n" + + "\n" + + "\n" + + ""); + checkOutput("module2-summary.html", true, + "
      • Description | Modules | " + + "Packages | Services
      • "); + checkOutput("module2-summary.html", true, + "\n" + + "\n" + + "\n" + + ""); + checkOutput("module2-summary.html", true, + "\n" + + "\n" + + "\n" + + "\n" + + ""); + checkOutput("module2-summary.html", true, + "\n" + + "\n" + + "\n" + + ""); + checkOutput("module2-summary.html", true, + "\n" + + "\n" + + "\n" + + ""); + checkOutput("module2-summary.html", true, + "\n" + + "\n" + + "\n" + + ""); + checkOutput("module2-summary.html", true, + "\n" + + "\n" + + "\n" + + ""); + checkOutput("module2-summary.html", true, + "\n" + + "\n" + + "\n" + + "Exported Packages \n" + + "\n" + + "\n" + + "\n" + + "\n" + + ""); + checkOutput("module2-summary.html", true, + "\n" + + "\n" + + "\n" + + "\n" + + ""); + checkOutput("module2-summary.html", true, + "\n" + + "\n" + + "\n" + + "\n" + + ""); + checkOutput("module2-summary.html", true, + "\n" + + "\n" + + "\n" + + "\n" + + ""); + } + + void testNegatedModuleSummary() { + checkOutput("module1-summary.html", false, + "\n" + + "\n" + + "\n" + + ""); + } } diff -r 5a66e43d8cbd -r 5bf88dce615f langtools/test/jdk/javadoc/doclet/testModules/module2/module-info.java --- a/langtools/test/jdk/javadoc/doclet/testModules/module2/module-info.java Wed Jul 05 21:57:12 2017 +0200 +++ b/langtools/test/jdk/javadoc/doclet/testModules/module2/module-info.java Wed Jul 05 21:58:29 2017 +0200 @@ -28,4 +28,10 @@ */ module module2 { exports testpkgmdl2; + + exports testpkg2mdl2 to module1; + + uses testpkgmdl2.TestClassInModule2; + + provides testpkg2mdl2.TestInterfaceInModule2 with testpkgmdl2.TestClassInModule2; } diff -r 5a66e43d8cbd -r 5bf88dce615f langtools/test/jdk/javadoc/doclet/testModules/module2/testpkg2mdl2/TestInterfaceInModule2.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/jdk/javadoc/doclet/testModules/module2/testpkg2mdl2/TestInterfaceInModule2.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 testpkg2mdl2; + +public interface TestInterfaceInModule2 { + void testMethod(); +} diff -r 5a66e43d8cbd -r 5bf88dce615f langtools/test/jdk/javadoc/doclet/testModules/module2/testpkgmdl2/TestClassInModule2.java --- a/langtools/test/jdk/javadoc/doclet/testModules/module2/testpkgmdl2/TestClassInModule2.java Wed Jul 05 21:57:12 2017 +0200 +++ b/langtools/test/jdk/javadoc/doclet/testModules/module2/testpkgmdl2/TestClassInModule2.java Wed Jul 05 21:58:29 2017 +0200 @@ -24,5 +24,8 @@ */ package testpkgmdl2; -public class TestClassInModule2 { +import testpkg2mdl2.TestInterfaceInModule2; + +public class TestClassInModule2 implements TestInterfaceInModule2 { + void testMethod() {} } diff -r 5a66e43d8cbd -r 5bf88dce615f langtools/test/jdk/javadoc/doclet/testStylesheet/TestStylesheet.java --- a/langtools/test/jdk/javadoc/doclet/testStylesheet/TestStylesheet.java Wed Jul 05 21:57:12 2017 +0200 +++ b/langtools/test/jdk/javadoc/doclet/testStylesheet/TestStylesheet.java Wed Jul 05 21:58:29 2017 +0200 @@ -23,7 +23,7 @@ /* * @test - * @bug 4494033 7028815 7052425 8007338 8023608 8008164 8016549 8072461 + * @bug 4494033 7028815 7052425 8007338 8023608 8008164 8016549 8072461 8154261 * @summary Run tests on doclet stylesheet. * @author jamieh * @library ../lib @@ -81,7 +81,8 @@ + " list-style-type:disc;\n" + "}", ".overviewSummary caption, .memberSummary caption, .typeSummary caption,\n" - + ".useSummary caption, .constantsSummary caption, .deprecatedSummary caption {\n" + + ".useSummary caption, .constantsSummary caption, .deprecatedSummary caption,\n" + + ".requiresSummary caption, .packagesSummary caption, .providesSummary caption, .usesSummary caption {\n" + " position:relative;\n" + " text-align:left;\n" + " background-repeat:no-repeat;\n" @@ -96,7 +97,9 @@ + " white-space:pre;\n" + "}", ".overviewSummary caption span, .memberSummary caption span, .typeSummary caption span,\n" - + ".useSummary caption span, .constantsSummary caption span, .deprecatedSummary caption span {\n" + + ".useSummary caption span, .constantsSummary caption span, .deprecatedSummary caption span,\n" + + ".requiresSummary caption span, .packagesSummary caption span, .providesSummary caption span,\n" + + ".usesSummary caption span {\n" + " white-space:nowrap;\n" + " padding-top:5px;\n" + " padding-left:12px;\n" @@ -132,6 +135,9 @@ + "}", // Test the formatting styles for proper content display in use and constant values pages. ".overviewSummary td.colFirst, .overviewSummary th.colFirst,\n" + + ".requiresSummary td.colFirst, .requiresSummary th.colFirst,\n" + + ".packagesSummary td.colFirst, .packagesSummary td.colSecond, .packagesSummary th.colFirst, .packagesSummary th,\n" + + ".usesSummary td.colFirst, .usesSummary th.colFirst,\n" + ".useSummary td.colFirst, .useSummary th.colFirst,\n" + ".overviewSummary td.colOne, .overviewSummary th.colOne,\n" + ".memberSummary td.colFirst, .memberSummary th.colFirst,\n" @@ -141,7 +147,8 @@ + " vertical-align:top;\n" + "}", ".overviewSummary td, .memberSummary td, .typeSummary td,\n" - + ".useSummary td, .constantsSummary td, .deprecatedSummary td {\n" + + ".useSummary td, .constantsSummary td, .deprecatedSummary td,\n" + + ".requiresSummary td, .packagesSummary td, .providesSummary td, .usesSummary td {\n" + " text-align:left;\n" + " padding:0px 0px 12px 10px;\n" + "}", diff -r 5a66e43d8cbd -r 5bf88dce615f langtools/test/jdk/jshell/KullaCompletenessStressTest.java --- a/langtools/test/jdk/jshell/KullaCompletenessStressTest.java Wed Jul 05 21:57:12 2017 +0200 +++ b/langtools/test/jdk/jshell/KullaCompletenessStressTest.java Wed Jul 05 21:58:29 2017 +0200 @@ -37,10 +37,6 @@ public class KullaCompletenessStressTest extends CompletenessStressTest { @Override public File[] getDirectoriesToTest() { - return new File[]{ getKullaSourceDirectory() }; - } - - public File getKullaSourceDirectory() { String src = System.getProperty("test.src"); File file; if (src == null) { @@ -48,6 +44,11 @@ } else { file = new File(src, "../../../src/jdk.jshell/share/classes"); } - return file; + if (!file.exists()) { + System.out.println("jdk.jshell sources are not exist. Test has been skipped. Path: " + file.toString()); + return new File[]{}; + }else { + return new File[]{file}; + } } } diff -r 5a66e43d8cbd -r 5bf88dce615f langtools/test/tools/javac/AnonymousClass/AnonymousClassFlags.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/AnonymousClass/AnonymousClassFlags.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 8161013 + * @summary Verify that anonymous class binaries have the correct flags set + * @modules jdk.jdeps/com.sun.tools.classfile + * @run main AnonymousClassFlags + */ + +import java.util.*; +import java.nio.file.Path; +import java.nio.file.Paths; + +import com.sun.tools.classfile.*; +import static com.sun.tools.classfile.AccessFlags.*; + +public class AnonymousClassFlags { + public static void main(String[] args) throws Exception { + new AnonymousClassFlags().test(System.getProperty("test.classes", ".")); + } + + /** Maps names of anonymous classes to their expected inner_class_access_flags */ + private static Map anonClasses = new LinkedHashMap<>(); + + // ******* TEST CASES ******** + + static Object o1 = new Object() { + { anonClasses.put(getClass().getName(), 0); } + }; + + static void staticMethod() { + Object o2 = new Object() { + { anonClasses.put(getClass().getName(), 0); } + }; + } + + static { + staticMethod(); + + Object o3 = new Object() { + { anonClasses.put(getClass().getName(), 0); } + }; + } + + Object o4 = new Object() { + { anonClasses.put(getClass().getName(), 0); } + }; + + void instanceMethod() { + Object o5 = new Object() { + { anonClasses.put(getClass().getName(), 0); } + }; + } + + { + instanceMethod(); + + Object o6 = new Object() { + { anonClasses.put(getClass().getName(), 0); } + }; + } + + // ******* TEST IMPLEMENTATION ******** + + void test(String classesDir) throws Exception { + staticMethod(); + instanceMethod(); + + Path outerFile = Paths.get(classesDir, getClass().getName() + ".class"); + ClassFile outerClass = ClassFile.read(outerFile); + for (Map.Entry entry : anonClasses.entrySet()) { + Path innerFile = Paths.get(classesDir, entry.getKey() + ".class"); + ClassFile innerClass = ClassFile.read(innerFile); + String name = entry.getKey(); + int expected = entry.getValue(); + assertInnerFlags(outerClass, name, expected); + assertClassFlags(innerClass, name, expected); + assertInnerFlags(innerClass, name, expected); + } + } + + static void assertClassFlags(ClassFile classFile, String name, int expected) { + int mask = ACC_PUBLIC | ACC_FINAL | ACC_INTERFACE | ACC_ABSTRACT | + ACC_SYNTHETIC | ACC_ANNOTATION | ACC_ENUM; + int classExpected = (expected & mask) | ACC_SUPER; + int classActual = classFile.access_flags.flags; + if (classActual != classExpected) { + throw new AssertionError("Incorrect access_flags for class " + name + + ": expected=" + classExpected + ", actual=" + classActual); + } + + } + + static void assertInnerFlags(ClassFile classFile, String name, int expected) throws ConstantPoolException { + int innerActual = lookupInnerFlags(classFile, name).flags; + if (innerActual != expected) { + throw new AssertionError("Incorrect inner_class_access_flags for class " + name + + " in class " + classFile.getName() + + ": expected=" + expected + ", actual=" + innerActual); + } + } + + private static AccessFlags lookupInnerFlags(ClassFile classFile, String innerName) throws ConstantPoolException { + InnerClasses_attribute inners = (InnerClasses_attribute) classFile.getAttribute("InnerClasses"); + if (inners == null) { + throw new AssertionError("InnerClasses attribute missing in class " + classFile.getName()); + } + for (InnerClasses_attribute.Info info : inners.classes) { + String entryName = info.getInnerClassInfo(classFile.constant_pool).getName(); + if (innerName.equals(entryName)) { + return info.inner_class_access_flags; + } + } + throw new AssertionError("No InnerClasses entry in class " + classFile.getName() + " for class " + innerName); + } + +} diff -r 5a66e43d8cbd -r 5bf88dce615f langtools/test/tools/javac/cast/6219964/T6219964.java --- a/langtools/test/tools/javac/cast/6219964/T6219964.java Wed Jul 05 21:57:12 2017 +0200 +++ b/langtools/test/tools/javac/cast/6219964/T6219964.java Wed Jul 05 21:58:29 2017 +0200 @@ -1,8 +1,8 @@ /* * @test /nodynamiccopyright/ - * @bug 6219964 - * @summary Compiler allows illegal cast of anonymous inner class - * @compile/fail/ref=T6219964.out -XDrawDiagnostics T6219964.java + * @bug 6219964 8161013 + * @summary Anonymous class types are not final + * @compile T6219964.java */ public class T6219964 { diff -r 5a66e43d8cbd -r 5bf88dce615f langtools/test/tools/javac/cast/6219964/T6219964.out --- a/langtools/test/tools/javac/cast/6219964/T6219964.out Wed Jul 05 21:57:12 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -T6219964.java:13:27: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.anonymous.class: java.lang.Object, T6219964.I) -1 error diff -r 5a66e43d8cbd -r 5bf88dce615f langtools/test/tools/jdeps/jdkinternals/RemovedJDKInternals.java --- a/langtools/test/tools/jdeps/jdkinternals/RemovedJDKInternals.java Wed Jul 05 21:57:12 2017 +0200 +++ b/langtools/test/tools/jdeps/jdkinternals/RemovedJDKInternals.java Wed Jul 05 21:58:29 2017 +0200 @@ -71,7 +71,7 @@ assertTrue(CompilerUtils.compile(codecSrc, codecDest)); // patch jdk.unsupported and set -cp to codec types - assertTrue(CompilerUtils.compile(Paths.get(TEST_SRC, "src"), + assertTrue(CompilerUtils.compile(Paths.get(TEST_SRC, "src", "p"), CLASSES_DIR, "-Xpatch:jdk.unsupported=" + patchDir, "-cp", codecDest.toString())); diff -r 5a66e43d8cbd -r 5bf88dce615f langtools/test/tools/jdeps/jdkinternals/ShowReplacement.java --- a/langtools/test/tools/jdeps/jdkinternals/ShowReplacement.java Wed Jul 05 21:57:12 2017 +0200 +++ b/langtools/test/tools/jdeps/jdkinternals/ShowReplacement.java Wed Jul 05 21:58:29 2017 +0200 @@ -59,14 +59,17 @@ public void compileAll() throws Exception { CompilerUtils.cleanDir(CLASSES_DIR); - assertTrue(CompilerUtils.compile(Paths.get(TEST_SRC, "p"), + Path tmp = Paths.get("tmp"); + assertTrue(CompilerUtils.compile(Paths.get(TEST_SRC, "src", "apple"), tmp)); + assertTrue(CompilerUtils.compile(Paths.get(TEST_SRC, "src", "q"), CLASSES_DIR, + "-cp", tmp.toString(), "-XaddExports:java.base/sun.security.util=ALL-UNNAMED")); } @Test public void withReplacement() { - Path file = Paths.get("p", "WithRepl.class"); + Path file = Paths.get("q", "WithRepl.class"); String[] output = JdepsUtil.jdeps("-jdkinternals", CLASSES_DIR.resolve(file).toString()); int i = 0; while (!output[i].contains("Suggested Replacement")) { @@ -90,9 +93,29 @@ } } + /* + * A JDK internal class has been removed while its package still exists. + */ @Test public void noReplacement() { - Path file = Paths.get("p", "NoRepl.class"); + Path file = Paths.get("q", "NoRepl.class"); + String[] output = JdepsUtil.jdeps("-jdkinternals", CLASSES_DIR.resolve(file).toString()); + int i = 0; + // expect no replacement + while (i < output.length && !output[i].contains("Suggested Replacement")) { + i++; + } + + // no replacement + assertEquals(output.length-i, 0); + } + + /* + * A JDK internal package has been removed. + */ + @Test + public void removedPackage() { + Path file = Paths.get("q", "RemovedPackage.class"); String[] output = JdepsUtil.jdeps("-jdkinternals", CLASSES_DIR.resolve(file).toString()); int i = 0; // expect no replacement diff -r 5a66e43d8cbd -r 5bf88dce615f langtools/test/tools/jdeps/jdkinternals/p/NoRepl.java --- a/langtools/test/tools/jdeps/jdkinternals/p/NoRepl.java Wed Jul 05 21:57:12 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 p; - -import java.io.IOException; -import java.io.OutputStream; -import sun.security.util.DerEncoder; - -public class NoRepl implements DerEncoder { - public void derEncode(OutputStream out) throws IOException { - throw new IOException(); - } -} diff -r 5a66e43d8cbd -r 5bf88dce615f langtools/test/tools/jdeps/jdkinternals/p/WithRepl.java --- a/langtools/test/tools/jdeps/jdkinternals/p/WithRepl.java Wed Jul 05 21:57:12 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 p; - -import sun.security.util.HostnameChecker; - -public class WithRepl { - public static void main(String[] argv) throws Exception { - HostnameChecker hc = HostnameChecker.getInstance(HostnameChecker.TYPE_LDAP); - } -} diff -r 5a66e43d8cbd -r 5bf88dce615f langtools/test/tools/jdeps/jdkinternals/src/apple/applescript/AppleScriptEngine.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/jdeps/jdkinternals/src/apple/applescript/AppleScriptEngine.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 apple.applescript; + +import javax.script.ScriptEngine; + +public interface AppleScriptEngine extends ScriptEngine { +} diff -r 5a66e43d8cbd -r 5bf88dce615f langtools/test/tools/jdeps/jdkinternals/src/q/NoRepl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/jdeps/jdkinternals/src/q/NoRepl.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 q; + +import java.io.IOException; +import java.io.OutputStream; +import sun.security.util.DerEncoder; + +public class NoRepl implements DerEncoder { + public void derEncode(OutputStream out) throws IOException { + throw new IOException(); + } +} diff -r 5a66e43d8cbd -r 5bf88dce615f langtools/test/tools/jdeps/jdkinternals/src/q/RemovedPackage.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/jdeps/jdkinternals/src/q/RemovedPackage.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 q; + +import apple.applescript.AppleScriptEngine; + +public class RemovedPackage { + AppleScriptEngine scriptEngine; +} diff -r 5a66e43d8cbd -r 5bf88dce615f langtools/test/tools/jdeps/jdkinternals/src/q/WithRepl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/jdeps/jdkinternals/src/q/WithRepl.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 q; + +import sun.security.util.HostnameChecker; + +public class WithRepl { + public static void main(String[] argv) throws Exception { + HostnameChecker hc = HostnameChecker.getInstance(HostnameChecker.TYPE_LDAP); + } +} diff -r 5a66e43d8cbd -r 5bf88dce615f make/CompileJavaModules.gmk --- a/make/CompileJavaModules.gmk Wed Jul 05 21:57:12 2017 +0200 +++ b/make/CompileJavaModules.gmk Wed Jul 05 21:58:29 2017 +0200 @@ -409,6 +409,8 @@ ################################################################################ +jdk.jdeps_COPY := .txt + jdk.jdeps_CLEAN_FILES := $(wildcard \ $(JDK_TOPDIR)/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/*.properties \ $(JDK_TOPDIR)/src/jdk.jdeps/share/classes/com/sun/tools/javap/resources/*.properties) diff -r 5a66e43d8cbd -r 5bf88dce615f make/Javadoc.gmk --- a/make/Javadoc.gmk Wed Jul 05 21:57:12 2017 +0200 +++ b/make/Javadoc.gmk Wed Jul 05 21:58:29 2017 +0200 @@ -424,7 +424,7 @@ @($(call COMMON_JAVADOCFLAGS) ; \ $(call COMMON_JAVADOCTAGS) ; \ $(call OptionOnly,-Xdoclint:reference) ; \ - $(call OptionOnly,-Xdoclint/package:-org.omg.*) ; \ + $(call OptionOnly,-Xdoclint/package:-org.omg.*$(COMMA)jdk.internal.logging.*) ; \ $(call OptionPair,-system,none) ; \ $(call OptionPair,-modulesourcepath,$(RELEASEDOCS_MODULESOURCEPATH)) ; \ $(call OptionPair,-addmods,$(COREAPI_MODULES)) ; \ diff -r 5a66e43d8cbd -r 5bf88dce615f make/common/MakeBase.gmk --- a/make/common/MakeBase.gmk Wed Jul 05 21:57:12 2017 +0200 +++ b/make/common/MakeBase.gmk Wed Jul 05 21:58:29 2017 +0200 @@ -801,15 +801,20 @@ # of the build in case of failure. The command line itself is stored in a file, # and also logged to stdout if the LOG=cmdlines option has been given. # +# NOTE: If the command redirects stdout, the caller needs to wrap it in a +# subshell (by adding parentheses around it), otherwise the redirect to the +# subshell tee process will create a race condition where the target file may +# not be fully written when the make recipe is done. +# # Param 1 - The path to base the name of the log file / command line file on # Param 2 - The command to run ExecuteWithLog = \ $(call LogCmdlines, Exececuting: [$(strip $2)]) \ $(call WriteFile, $2, $(strip $1).cmdline) \ - ( ( $(strip $2) > >($(TEE) $(strip $1).log) 2> >($(TEE) $(strip $1).log >&2) || \ + ( $(strip $2) > >($(TEE) $(strip $1).log) 2> >($(TEE) $(strip $1).log >&2) || \ ( exitcode=$(DOLLAR)? && \ $(CP) $(strip $1).log $(MAKESUPPORT_OUTPUTDIR)/failure-logs/$(subst /,_,$(patsubst $(BUILD_OUTPUT)/%,%,$(strip $1))).log && \ - exit $(DOLLAR)exitcode ) ) && wait ) + exit $(DOLLAR)exitcode ) ) ################################################################################ # Find lib dir for module diff -r 5a66e43d8cbd -r 5bf88dce615f make/common/Modules.gmk --- a/make/common/Modules.gmk Wed Jul 05 21:57:12 2017 +0200 +++ b/make/common/Modules.gmk Wed Jul 05 21:58:29 2017 +0200 @@ -1,5 +1,5 @@ # -# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. # 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,6 @@ # to be deprivileged BOOT_MODULES += \ - java.smartcardio \ jdk.naming.rmi \ # @@ -104,6 +103,7 @@ PLATFORM_MODULES += \ java.compiler \ java.scripting \ + java.smartcardio \ java.sql \ java.sql.rowset \ jdk.accessibility \ diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/.hgtags --- a/nashorn/.hgtags Wed Jul 05 21:57:12 2017 +0200 +++ b/nashorn/.hgtags Wed Jul 05 21:58:29 2017 +0200 @@ -360,3 +360,4 @@ 5d68f5155dded7efec7d5aca5d631caa7ee1042b jdk-9+124 a32d419d73fe881a935b567c57dab9bfe3ed5f92 jdk-9+125 ee90c69a18409533df8f7b602044bf966a28381a jdk-9+126 +ff07be6106fa56b72c163244f45a3ecb4c995564 jdk-9+127 diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/make/project.properties --- a/nashorn/make/project.properties Wed Jul 05 21:57:12 2017 +0200 +++ b/nashorn/make/project.properties Wed Jul 05 21:58:29 2017 +0200 @@ -35,7 +35,9 @@ javac.source=1.9 javac.target=1.9 -javadoc.option=-tag "implSpec:a:Implementation Requirements:" +javadoc.option=\ + -tag "implSpec:a:Implementation Requirements:"\ + -tag "implNote:a:Implementation Note:" # nashorn version information nashorn.version=0.1 diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/samples/prettyprinter.js --- a/nashorn/samples/prettyprinter.js Wed Jul 05 21:57:12 2017 +0200 +++ b/nashorn/samples/prettyprinter.js Wed Jul 05 21:58:29 2017 +0200 @@ -209,7 +209,7 @@ } print("function "); if (func.name) { - print(func.name); + print(func.name.name); } printFunctionBody(func, extra, end); if (funcDecl) { @@ -608,7 +608,7 @@ visitVariable: function(node, extra) { indent(); - print("var " + node.name); + print("var " + node.binding.name); var init = node.initializer; if (init) { print(" = "); diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/NashornCompleter.java --- a/nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/NashornCompleter.java Wed Jul 05 21:57:12 2017 +0200 +++ b/nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/NashornCompleter.java Wed Jul 05 21:58:29 2017 +0200 @@ -439,6 +439,10 @@ args.add("-strict"); } + if (env._es6) { + args.add("--language=es6"); + } + return Parser.create(args.toArray(new String[0])); } } diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/CatchTree.java --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/CatchTree.java Wed Jul 05 21:57:12 2017 +0200 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/CatchTree.java Wed Jul 05 21:58:29 2017 +0200 @@ -38,11 +38,11 @@ */ public interface CatchTree extends Tree { /** - * Returns the catch parameter identifier of the exception caught. + * Returns the catch parameter identifier or parameter binding pattern of the exception caught. * - * @return the catch parameter identifier + * @return the catch parameter identifier or parameter binding pattern */ - IdentifierTree getParameter(); + ExpressionTree getParameter(); /** * Returns the code block of this catch block. diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/CatchTreeImpl.java --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/CatchTreeImpl.java Wed Jul 05 21:57:12 2017 +0200 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/CatchTreeImpl.java Wed Jul 05 21:58:29 2017 +0200 @@ -28,12 +28,12 @@ import jdk.nashorn.internal.ir.CatchNode; final class CatchTreeImpl extends TreeImpl implements CatchTree { - private final IdentifierTree param; + private final ExpressionTree param; private final BlockTree block; private final ExpressionTree condition; CatchTreeImpl(final CatchNode node, - final IdentifierTree param, + final ExpressionTree param, final BlockTree block, final ExpressionTree condition) { super(node); @@ -48,7 +48,7 @@ } @Override - public IdentifierTree getParameter() { + public ExpressionTree getParameter() { return param; } diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ClassDeclarationTree.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ClassDeclarationTree.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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.api.tree; + +import java.util.List; + +/** + * A tree node that represents a class declaration. + * + * @since 9 + */ +public interface ClassDeclarationTree extends StatementTree { + + /** + * Class identifier. + * + * @return the class identifier + */ + IdentifierTree getName(); + + /** + * The expression of the {@code extends} clause. Optional. + * + * @return the class heritage + */ + ExpressionTree getClassHeritage(); + + /** + * Get the constructor method definition. + * + * @return the constructor + */ + PropertyTree getConstructor(); + + /** + * Get other property definitions except for the constructor. + * + * @return the class elements + */ + List getClassElements(); +} diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ClassDeclarationTreeImpl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ClassDeclarationTreeImpl.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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.api.tree; + +import java.util.List; +import jdk.nashorn.internal.ir.VarNode; + +final class ClassDeclarationTreeImpl extends StatementTreeImpl implements ClassDeclarationTree { + + private final IdentifierTree name; + private final ExpressionTree classHeritage; + private final PropertyTree constructor; + private final List classElements; + + ClassDeclarationTreeImpl(final VarNode node, final IdentifierTree name, + final ExpressionTree classHeritage, final PropertyTree constructor, + final List classElements) { + super(node); + this.name = name; + this.classHeritage = classHeritage; + this.constructor = constructor; + this.classElements = classElements; + } + + @Override + public Tree.Kind getKind() { + return Tree.Kind.CLASS; + } + + @Override + public IdentifierTree getName() { + return name; + } + + @Override + public ExpressionTree getClassHeritage() { + return classHeritage; + } + + @Override + public PropertyTree getConstructor() { + return constructor; + } + + @Override + public List getClassElements() { + return classElements; + } + + @Override + public R accept(final TreeVisitor visitor, final D data) { + return visitor.visitClassDeclaration(this, data); + } +} \ No newline at end of file diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ClassExpressionTree.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ClassExpressionTree.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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.api.tree; + +import java.util.List; + +/** + * A tree node that represents a class expression. + * + * @since 9 + */ +public interface ClassExpressionTree extends ExpressionTree { + /** + * Class identifier. Optional. + * + * @return the class identifier + */ + IdentifierTree getName(); + + /** + * The expression of the {@code extends} clause. Optional. + * + * @return the class heritage + */ + ExpressionTree getClassHeritage(); + + /** + * Get the constructor method definition. + * + * @return the constructor + */ + PropertyTree getConstructor(); + + /** + * Get other property definitions except for the constructor. + * + * @return the class elements + */ + List getClassElements(); +} diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ClassExpressionTreeImpl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ClassExpressionTreeImpl.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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.api.tree; + +import java.util.List; +import jdk.nashorn.internal.ir.ClassNode; + +final class ClassExpressionTreeImpl extends ExpressionTreeImpl implements ClassExpressionTree { + + private final IdentifierTree name; + private final ExpressionTree classHeritage; + private final PropertyTree constructor; + private final List classElements; + + ClassExpressionTreeImpl(final ClassNode cn, final IdentifierTree name, + final ExpressionTree classHeritage, final PropertyTree constructor, + final List classElements) { + super(cn); + this.name = name; + this.classHeritage = classHeritage; + this.constructor = constructor; + this.classElements = classElements; + } + + @Override + public Kind getKind() { + return Kind.CLASS_EXPRESSION; + } + + @Override + public IdentifierTree getName() { + return name; + } + + @Override + public ExpressionTree getClassHeritage() { + return classHeritage; + } + + @Override + public PropertyTree getConstructor() { + return constructor; + } + + @Override + public List getClassElements() { + return classElements; + } + + @Override + public R accept(final TreeVisitor visitor, final D data) { + return visitor.visitClassExpression(this, data); + } +} diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/CompilationUnitTree.java --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/CompilationUnitTree.java Wed Jul 05 21:57:12 2017 +0200 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/CompilationUnitTree.java Wed Jul 05 21:58:29 2017 +0200 @@ -62,4 +62,12 @@ * @return the line map for this compilation unit */ LineMap getLineMap(); + + /** + * Return the {@link ModuleTree} associated with this compilation unit. This is null, + * if there is no module information from this compilation unit. + * + * @return the Module info or null + */ + ModuleTree getModule(); } diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/CompilationUnitTreeImpl.java --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/CompilationUnitTreeImpl.java Wed Jul 05 21:57:12 2017 +0200 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/CompilationUnitTreeImpl.java Wed Jul 05 21:58:29 2017 +0200 @@ -32,13 +32,18 @@ implements CompilationUnitTree { private final FunctionNode funcNode; private final List elements; + private final ModuleTree module; CompilationUnitTreeImpl(final FunctionNode node, - final List elements) { + final List elements, + final ModuleTree module) { super(node); this.funcNode = node; - assert funcNode.getKind() == FunctionNode.Kind.SCRIPT : "script function expected"; + assert funcNode.getKind() == FunctionNode.Kind.SCRIPT || + funcNode.getKind() == FunctionNode.Kind.MODULE : + "script or module function expected"; this.elements = elements; + this.module = module; } @Override @@ -67,6 +72,11 @@ } @Override + public ModuleTree getModule() { + return module; + } + + @Override public R accept(final TreeVisitor visitor, final D data) { return visitor.visitCompilationUnit(this, data); } diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/DestructuringDeclTreeImpl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/DestructuringDeclTreeImpl.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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.api.tree; + +import jdk.nashorn.internal.ir.ExpressionStatement; +import jdk.nashorn.internal.parser.TokenType; + +// This implementation of VariableTree represents a destructuring declaration +final class DestructuringDeclTreeImpl extends StatementTreeImpl + implements VariableTree { + + private final TokenType declType; + private final ExpressionTree lhs; + private final ExpressionTree init; + + DestructuringDeclTreeImpl(ExpressionStatement exprStat, final ExpressionTree lhs, final ExpressionTree init) { + super(exprStat); + assert exprStat.destructuringDeclarationType() != null : "expecting a destructuring decl. statement"; + + this.declType = exprStat.destructuringDeclarationType(); + this.lhs = lhs; + this.init = init; + } + + @Override + public Kind getKind() { + return Kind.VARIABLE; + } + + @Override + public ExpressionTree getBinding() { + return lhs; + } + + @Override + public ExpressionTree getInitializer() { + return init; + } + + @Override + public boolean isConst() { + return declType == TokenType.CONST; + } + + @Override + public boolean isLet() { + return declType == TokenType.LET; + } + + @Override + public R accept(final TreeVisitor visitor, final D data) { + return visitor.visitVariable(this, data); + } +} diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ExportEntryTree.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ExportEntryTree.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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.api.tree; + +import java.util.List; + +/** + * A Tree node for export entry in Module information. + */ +public interface ExportEntryTree extends Tree { + /** + * Returns the entry's export name. + * + * @return the export name + */ + public IdentifierTree getExportName(); + + /** + * Returns the entry's module request. + * + * @return the module request + */ + public IdentifierTree getModuleRequest(); + + /** + * Returns the entry's import name. + * + * @return the import name + */ + public IdentifierTree getImportName(); + + /** + * Returns the entry's local name. + * + * @return the local name + */ + public IdentifierTree getLocalName(); +} diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ExportEntryTreeImpl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ExportEntryTreeImpl.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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.api.tree; + +import java.util.List; +import java.util.stream.Collectors; +import jdk.nashorn.internal.ir.FunctionNode; +import jdk.nashorn.internal.ir.IdentNode; +import jdk.nashorn.internal.ir.Module; +import static jdk.nashorn.api.tree.ModuleTreeImpl.identOrNull; + +final class ExportEntryTreeImpl extends TreeImpl implements ExportEntryTree { + private final long startPos, endPos; + private final IdentifierTree exportName; + private final IdentifierTree moduleRequest; + private final IdentifierTree importName; + private final IdentifierTree localName; + + private ExportEntryTreeImpl(final long startPos, final long endPos, + IdentifierTree exportName, + IdentifierTree moduleRequest, + IdentifierTree importName, + IdentifierTree localName) { + super(null); // no underlying Node! + this.startPos = startPos; + this.endPos = endPos; + this.exportName = exportName; + this.moduleRequest = moduleRequest; + this.importName = importName; + this.localName = localName; + } + + private static ExportEntryTreeImpl createExportEntry(Module.ExportEntry entry) { + return new ExportEntryTreeImpl(entry.getStartPosition(), + entry.getEndPosition(), + identOrNull(entry.getExportName()), + identOrNull(entry.getModuleRequest()), + identOrNull(entry.getImportName()), + identOrNull(entry.getLocalName())); + } + + static List createExportList(List exportList) { + return exportList.stream(). + map(ExportEntryTreeImpl::createExportEntry). + collect(Collectors.toList()); + } + + @Override + public Kind getKind() { + return Tree.Kind.EXPORT_ENTRY; + } + + @Override + public R accept(final TreeVisitor visitor, final D data) { + return visitor.visitExportEntry(this, data); + } + + @Override + public long getStartPosition() { + return startPos; + } + + @Override + public long getEndPosition() { + return endPos; + } + + @Override + public IdentifierTree getExportName() { + return exportName; + } + + @Override + public IdentifierTree getModuleRequest() { + return moduleRequest; + } + + @Override + public IdentifierTree getImportName() { + return importName; + } + + @Override + public IdentifierTree getLocalName() { + return localName; + } +} diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ForOfLoopTree.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ForOfLoopTree.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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.api.tree; + +/** + * A tree node for for..of statement. + * + * For example: + *
        + *   for ( variable of expression )
        + *       statement
        + * 
        + * + * @since 9 + */ +public interface ForOfLoopTree extends LoopTree { + /** + * The for..in left hand side expression. + * + * @return the left hand side expression + */ + ExpressionTree getVariable(); + + /** + * The object or array being whose properties are iterated. + * + * @return the object or array expression being iterated + */ + ExpressionTree getExpression(); + + /** + * The statement contained in this for..in statement. + * + * @return the statement + */ + @Override + StatementTree getStatement(); +} + diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ForOfLoopTreeImpl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ForOfLoopTreeImpl.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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.api.tree; + +import jdk.nashorn.internal.ir.ForNode; + +final class ForOfLoopTreeImpl extends StatementTreeImpl implements ForOfLoopTree { + private final ExpressionTree lhsExpr; + private final ExpressionTree expr; + private final StatementTree stat; + + ForOfLoopTreeImpl(final ForNode node, + final ExpressionTree lhsExpr, + final ExpressionTree expr, + final StatementTree stat) { + super(node); + assert node.isForIn() : "for ..in expected"; + this.lhsExpr = lhsExpr; + this.expr = expr; + this.stat = stat; + } + + @Override + public Kind getKind() { + return Kind.FOR_IN_LOOP; + } + + @Override + public ExpressionTree getVariable() { + return lhsExpr; + } + + @Override + public ExpressionTree getExpression() { + return expr; + } + + @Override + public StatementTree getStatement() { + return stat; + } + + @Override + public R accept(final TreeVisitor visitor, final D data) { + return visitor.visitForOfLoop(this, data); + } +} diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/FunctionDeclarationTree.java --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/FunctionDeclarationTree.java Wed Jul 05 21:57:12 2017 +0200 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/FunctionDeclarationTree.java Wed Jul 05 21:58:29 2017 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * 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 @@ import java.util.List; /** - * A tree node for a function declaration. + * A tree node for a function declaration. * * For example: *
        @@ -37,6 +37,12 @@
          *      body
          * 
        * + *
        + *   function* name
        + *      ( parameters )
        + *      body
        + * 
        + * * @since 9 */ public interface FunctionDeclarationTree extends StatementTree { @@ -45,7 +51,7 @@ * * @return name the function declared */ - String getName(); + IdentifierTree getName(); /** * Returns the parameters of this function. @@ -67,4 +73,11 @@ * @return true if this function is strict */ boolean isStrict(); + + /** + * Is this a generator function? + * + * @return true if this is a generator function + */ + boolean isGenerator(); } diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/FunctionDeclarationTreeImpl.java --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/FunctionDeclarationTreeImpl.java Wed Jul 05 21:57:12 2017 +0200 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/FunctionDeclarationTreeImpl.java Wed Jul 05 21:58:29 2017 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * 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,7 +32,7 @@ final class FunctionDeclarationTreeImpl extends StatementTreeImpl implements FunctionDeclarationTree { private final FunctionNode funcNode; - private final String funcName; + private final IdentifierTree funcName; private final List params; private final BlockTree body; @@ -43,7 +43,7 @@ assert node.getInit() instanceof FunctionNode : "function expected"; funcNode = (FunctionNode)node.getInit(); assert funcNode.isDeclared() : "function declaration expected"; - funcName = funcNode.isAnonymous()? null : node.getName().getName(); + funcName = funcNode.isAnonymous()? null : new IdentifierTreeImpl(node.getName()); this.params = params; this.body = body; } @@ -54,7 +54,7 @@ } @Override - public String getName() { + public IdentifierTree getName() { return funcName; } @@ -74,6 +74,11 @@ } @Override + public boolean isGenerator() { + return funcNode.getKind() == FunctionNode.Kind.GENERATOR; + } + + @Override public R accept(final TreeVisitor visitor, final D data) { return visitor.visitFunctionDeclaration(this, data); } diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/FunctionExpressionTree.java --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/FunctionExpressionTree.java Wed Jul 05 21:57:12 2017 +0200 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/FunctionExpressionTree.java Wed Jul 05 21:58:29 2017 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * 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 @@ import java.util.List; /** - * A tree node for a function expression. + * A tree node for function expressions including arrow functions. * * For example: *
        @@ -37,6 +37,10 @@
          *      body
          * 
        * + *
        + *   var func = (x) => x+1
        + * 
        + * * @since 9 */ public interface FunctionExpressionTree extends ExpressionTree { @@ -45,7 +49,7 @@ * * @return name the function declared */ - String getName(); + IdentifierTree getName(); /** * Returns the parameters of this function. @@ -55,11 +59,13 @@ List getParameters(); /** - * Returns the body of code of this function. + * Returns the body of this function. This may be a {@link BlockTree} when this + * function has a block body. This is an {@link ExpressionTree} when the function body + * is a concise expression as in an expression arrow, or in an expression closure. * - * @return the body of code + * @return the body of this function */ - BlockTree getBody(); + Tree getBody(); /** * Is this a strict function? @@ -67,4 +73,18 @@ * @return true if this function is strict */ boolean isStrict(); + + /** + * Is this a arrow function? + * + * @return true if this is a arrow function + */ + boolean isArrow(); + + /** + * Is this a generator function? + * + * @return true if this is a generator function + */ + boolean isGenerator(); } diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/FunctionExpressionTreeImpl.java --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/FunctionExpressionTreeImpl.java Wed Jul 05 21:57:12 2017 +0200 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/FunctionExpressionTreeImpl.java Wed Jul 05 21:58:29 2017 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * 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,9 +31,9 @@ final class FunctionExpressionTreeImpl extends ExpressionTreeImpl implements FunctionExpressionTree { private final FunctionNode funcNode; - private final String funcName; + private final IdentifierTree funcName; private final List params; - private final BlockTree body; + private final Tree body; FunctionExpressionTreeImpl(final FunctionNode node, final List params, @@ -46,11 +46,17 @@ if (node.isAnonymous() || kind == FunctionNode.Kind.GETTER || kind == FunctionNode.Kind.SETTER) { funcName = null; } else { - funcName = node.getIdent().getName(); + funcName = new IdentifierTreeImpl(node.getIdent()); } this.params = params; - this.body = body; + if (node.getFlag(FunctionNode.HAS_EXPRESSION_BODY)) { + StatementTree first = body.getStatements().get(0); + assert first instanceof ReturnTree : "consise func. expression should have a return statement"; + this.body = ((ReturnTree)first).getExpression(); + } else { + this.body = body; + } } @Override @@ -59,7 +65,7 @@ } @Override - public String getName() { + public IdentifierTree getName() { return funcName; } @@ -69,7 +75,7 @@ } @Override - public BlockTree getBody() { + public Tree getBody() { return body; } @@ -79,6 +85,16 @@ } @Override + public boolean isArrow() { + return funcNode.getKind() == FunctionNode.Kind.ARROW; + } + + @Override + public boolean isGenerator() { + return funcNode.getKind() == FunctionNode.Kind.GENERATOR; + } + + @Override public R accept(final TreeVisitor visitor, final D data) { return visitor.visitFunctionExpression(this, data); } diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/IRTranslator.java --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/IRTranslator.java Wed Jul 05 21:57:12 2017 +0200 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/IRTranslator.java Wed Jul 05 21:58:29 2017 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * 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 @@ import java.util.ArrayList; import java.util.Comparator; import java.util.List; +import java.util.Map; import jdk.nashorn.internal.ir.AccessNode; import jdk.nashorn.internal.ir.BinaryNode; import jdk.nashorn.internal.ir.Block; @@ -35,6 +36,7 @@ import jdk.nashorn.internal.ir.CallNode; import jdk.nashorn.internal.ir.CaseNode; import jdk.nashorn.internal.ir.CatchNode; +import jdk.nashorn.internal.ir.ClassNode; import jdk.nashorn.internal.ir.ContinueNode; import jdk.nashorn.internal.ir.DebuggerNode; import jdk.nashorn.internal.ir.EmptyNode; @@ -56,6 +58,7 @@ import jdk.nashorn.internal.ir.SplitNode; import jdk.nashorn.internal.ir.Statement; import jdk.nashorn.internal.ir.SwitchNode; +import jdk.nashorn.internal.ir.TemplateLiteral; import jdk.nashorn.internal.ir.TernaryNode; import jdk.nashorn.internal.ir.ThrowNode; import jdk.nashorn.internal.ir.TryNode; @@ -87,11 +90,14 @@ return null; } - assert (node.getKind() == FunctionNode.Kind.SCRIPT) : "script function expected"; + assert node.getKind() == FunctionNode.Kind.SCRIPT || + node.getKind() == FunctionNode.Kind.MODULE : + "script or module function expected"; final Block body = node.getBody(); return new CompilationUnitTreeImpl(node, - translateStats(body != null? getOrderedStatements(body.getStatements()) : null)); + translateStats(body != null? getOrderedStatements(body.getStatements()) : null), + translateModule(node)); } @Override @@ -184,8 +190,15 @@ @Override public boolean enterExpressionStatement(final ExpressionStatement expressionStatement) { - curStat = new ExpressionStatementTreeImpl(expressionStatement, + if (expressionStatement.destructuringDeclarationType() != null) { + ExpressionTree expr = translateExpr(expressionStatement.getExpression()); + assert expr instanceof AssignmentTree : "destructuring decl. statement does not have assignment"; + AssignmentTree assign = (AssignmentTree)expr; + curStat = new DestructuringDeclTreeImpl(expressionStatement, assign.getVariable(), assign.getExpression()); + } else { + curStat = new ExpressionStatementTreeImpl(expressionStatement, translateExpr(expressionStatement.getExpression())); + } return false; } @@ -209,6 +222,11 @@ translateExpr(forNode.getInit()), translateExpr(forNode.getModify()), translateBlock(forNode.getBody())); + } else if (forNode.isForOf()) { + curStat = new ForOfLoopTreeImpl(forNode, + translateExpr(forNode.getInit()), + translateExpr(forNode.getModify()), + translateBlock(forNode.getBody())); } else { curStat = new ForLoopTreeImpl(forNode, translateExpr(forNode.getInit()), @@ -224,8 +242,7 @@ public boolean enterFunctionNode(final FunctionNode functionNode) { assert !functionNode.isDeclared() || functionNode.isAnonymous() : "should not reach here for function declaration"; - final List paramTrees - = translateExprs(functionNode.getParameters()); + final List paramTrees = translateParameters(functionNode); final BlockTree blockTree = (BlockTree) translateBlock(functionNode.getBody(), true); curExpr = new FunctionExpressionTreeImpl(functionNode, paramTrees, blockTree); @@ -291,14 +308,7 @@ @Override public boolean enterObjectNode(final ObjectNode objectNode) { final List propNodes = objectNode.getElements(); - final List propTrees = new ArrayList<>(propNodes.size()); - for (final PropertyNode propNode : propNodes) { - propTrees.add(new PropertyTreeImpl(propNode, - translateExpr(propNode.getKey()), - translateExpr(propNode.getValue()), - (FunctionExpressionTree) translateExpr(propNode.getGetter()), - (FunctionExpressionTree) translateExpr(propNode.getSetter()))); - } + final List propTrees = translateProperties(propNodes); curExpr = new ObjectLiteralTreeImpl(objectNode, propTrees); return false; } @@ -347,6 +357,12 @@ } @Override + public boolean enterTemplateLiteral(final TemplateLiteral templateLiteral) { + curExpr = new TemplateLiteralTreeImpl(templateLiteral, translateExprs(templateLiteral.getExpressions())); + return false; + } + + @Override public boolean enterTernaryNode(final TernaryNode ternaryNode) { curExpr = new ConditionalExpressionTreeImpl(ternaryNode, translateExpr(ternaryNode.getTest()), @@ -386,6 +402,14 @@ if (unaryNode.isTokenType(TokenType.NEW)) { curExpr = new NewTreeImpl(unaryNode, translateExpr(unaryNode.getExpression())); + } else if (unaryNode.isTokenType(TokenType.YIELD) || + unaryNode.isTokenType(TokenType.YIELD_STAR)) { + curExpr = new YieldTreeImpl(unaryNode, + translateExpr(unaryNode.getExpression())); + } else if (unaryNode.isTokenType(TokenType.SPREAD_ARGUMENT) || + unaryNode.isTokenType(TokenType.SPREAD_ARRAY)) { + curExpr = new SpreadTreeImpl(unaryNode, + translateExpr(unaryNode.getExpression())); } else { curExpr = new UnaryTreeImpl(unaryNode, translateExpr(unaryNode.getExpression())); @@ -399,12 +423,19 @@ if (initNode instanceof FunctionNode && ((FunctionNode)initNode).isDeclared()) { final FunctionNode funcNode = (FunctionNode) initNode; - final List paramTrees - = translateExprs(funcNode.getParameters()); + final List paramTrees = translateParameters(funcNode); final BlockTree blockTree = (BlockTree) translateBlock(funcNode.getBody(), true); curStat = new FunctionDeclarationTreeImpl(varNode, paramTrees, blockTree); + } else if (initNode instanceof ClassNode && ((ClassNode)initNode).isStatement()) { + final ClassNode classNode = (ClassNode) initNode; + + curStat = new ClassDeclarationTreeImpl(varNode, + translateIdent(classNode.getIdent()), + translateExpr(classNode.getClassHeritage()), + translateProperty(classNode.getConstructor()), + translateProperties(classNode.getClassElements())); } else { - curStat = new VariableTreeImpl(varNode, translateExpr(initNode)); + curStat = new VariableTreeImpl(varNode, translateIdent(varNode.getName()), translateExpr(initNode)); } return false; @@ -433,6 +464,25 @@ return false; } + /** + * Callback for entering a ClassNode + * + * @param classNode the node + * @return true if traversal should continue and node children be traversed, false otherwise + */ + @Override + public boolean enterClassNode(final ClassNode classNode) { + assert !classNode.isStatement(): "should not reach here for class declaration"; + + curExpr = new ClassExpressionTreeImpl(classNode, + translateIdent(classNode.getIdent()), + translateExpr(classNode.getClassHeritage()), + translateProperty(classNode.getConstructor()), + translateProperties(classNode.getClassElements())); + + return false; + } + private StatementTree translateBlock(final Block blockNode) { return translateBlock(blockNode, false); } @@ -493,6 +543,24 @@ return statTrees; } + private List translateParameters(final FunctionNode func) { + Map paramExprs = func.getParameterExpressions(); + if (paramExprs != null) { + List params = func.getParameters(); + final List exprTrees = new ArrayList<>(params.size()); + for (final IdentNode ident : params) { + Expression expr = paramExprs.containsKey(ident)? paramExprs.get(ident) : ident; + curExpr = null; + expr.accept(this); + assert curExpr != null; + exprTrees.add(curExpr); + } + return exprTrees; + } else { + return translateExprs(func.getParameters()); + } + } + private List translateExprs(final List exprs) { if (exprs == null) { return null; @@ -532,4 +600,25 @@ private static IdentifierTree translateIdent(final IdentNode ident) { return new IdentifierTreeImpl(ident); } + + private List translateProperties(final List propNodes) { + final List propTrees = new ArrayList<>(propNodes.size()); + for (final PropertyNode propNode : propNodes) { + propTrees.add(translateProperty(propNode)); + } + return propTrees; + } + + private PropertyTree translateProperty(final PropertyNode propNode) { + return new PropertyTreeImpl(propNode, + translateExpr(propNode.getKey()), + translateExpr(propNode.getValue()), + (FunctionExpressionTree) translateExpr(propNode.getGetter()), + (FunctionExpressionTree) translateExpr(propNode.getSetter())); + } + + private ModuleTree translateModule(final FunctionNode func) { + return func.getKind() == FunctionNode.Kind.MODULE? + ModuleTreeImpl.create(func) : null; + } } diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/IdentifierTree.java --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/IdentifierTree.java Wed Jul 05 21:57:12 2017 +0200 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/IdentifierTree.java Wed Jul 05 21:58:29 2017 +0200 @@ -42,4 +42,46 @@ * @return the name of this identifier */ String getName(); + + /** + * Is this a rest parameter for a function or rest elements of an array? + * + * @return true if this is a rest parameter + */ + boolean isRestParameter(); + + /** + * Is this super identifier? + * + * @return true if this is super identifier + */ + boolean isSuper(); + + /** + * Is this 'this' identifier? + * + * @return true if this is 'this' identifier + */ + boolean isThis(); + + /** + * Is this "*" used in module export entry? + * + * @return true if this "*" used in module export entry? + */ + boolean isStar(); + + /** + * Is this "default" used in module export entry? + * + * @return true if this 'default' used in module export entry? + */ + boolean isDefault(); + + /** + * Is this "*default*" used in module export entry? + * + * @return true if this '*default*' used in module export entry? + */ + boolean isStarDefaultStar(); } diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/IdentifierTreeImpl.java --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/IdentifierTreeImpl.java Wed Jul 05 21:57:12 2017 +0200 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/IdentifierTreeImpl.java Wed Jul 05 21:58:29 2017 +0200 @@ -27,6 +27,7 @@ package jdk.nashorn.api.tree; import jdk.nashorn.internal.ir.IdentNode; +import jdk.nashorn.internal.ir.Module; final class IdentifierTreeImpl extends ExpressionTreeImpl implements IdentifierTree { private final String name; @@ -47,6 +48,37 @@ } @Override + public boolean isRestParameter() { + return ((IdentNode)node).isRestParameter(); + } + + @Override + public boolean isSuper() { + final IdentNode ident = (IdentNode)node; + return ident.isDirectSuper() || "super".equals(ident.getName()); + } + + @Override + public boolean isThis() { + return "this".equals(((IdentNode)node).getName()); + } + + @Override + public boolean isStar() { + return Module.STAR_NAME.equals(((IdentNode)node).getName()); + } + + @Override + public boolean isDefault() { + return Module.DEFAULT_NAME.equals(((IdentNode)node).getName()); + } + + @Override + public boolean isStarDefaultStar() { + return Module.DEFAULT_EXPORT_BINDING_NAME.equals(((IdentNode)node).getName()); + } + + @Override public R accept(final TreeVisitor visitor, final D data) { return visitor.visitIdentifier(this, data); } diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ImportEntryTree.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ImportEntryTree.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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.api.tree; + +import java.util.List; + +/** + * A Tree node for import entry of Module information. + */ +public interface ImportEntryTree extends Tree { + /** + * Returns the entry's module request. + * + * @return the module request + */ + public IdentifierTree getModuleRequest(); + + /** + * Returns the entry's import name. + * + * @return the import name + */ + public IdentifierTree getImportName(); + + /** + * Returns the entry's local name. + * + * @return the local name + */ + public IdentifierTree getLocalName(); +} diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ImportEntryTreeImpl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ImportEntryTreeImpl.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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.api.tree; + +import java.util.List; +import java.util.stream.Collectors; +import jdk.nashorn.internal.ir.FunctionNode; +import jdk.nashorn.internal.ir.IdentNode; +import jdk.nashorn.internal.ir.Module; +import static jdk.nashorn.api.tree.ModuleTreeImpl.identOrNull; + +final class ImportEntryTreeImpl extends TreeImpl implements ImportEntryTree { + private final long startPos, endPos; + private final IdentifierTree moduleRequest; + private final IdentifierTree importName; + private final IdentifierTree localName; + + private ImportEntryTreeImpl(final long startPos, final long endPos, + IdentifierTree moduleRequest, + IdentifierTree importName, + IdentifierTree localName) { + super(null); // No underlying Node! + this.startPos = startPos; + this.endPos = endPos; + this.moduleRequest = moduleRequest; + this.importName = importName; + this.localName = localName; + } + + private static ImportEntryTreeImpl createImportEntry(Module.ImportEntry entry) { + return new ImportEntryTreeImpl(entry.getStartPosition(), + entry.getEndPosition(), + identOrNull(entry.getModuleRequest()), + identOrNull(entry.getImportName()), + identOrNull(entry.getLocalName())); + } + + static List createImportList(List importList) { + return importList.stream(). + map(ImportEntryTreeImpl::createImportEntry). + collect(Collectors.toList()); + } + + @Override + public Kind getKind() { + return Tree.Kind.IMPORT_ENTRY; + } + + @Override + public R accept(final TreeVisitor visitor, final D data) { + return visitor.visitImportEntry(this, data); + } + + @Override + public long getStartPosition() { + return startPos; + } + + @Override + public long getEndPosition() { + return endPos; + } + + @Override + public IdentifierTree getModuleRequest() { + return moduleRequest; + } + + @Override + public IdentifierTree getImportName() { + return importName; + } + + @Override + public IdentifierTree getLocalName() { + return localName; + } +} diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ModuleTree.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ModuleTree.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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.api.tree; + +import java.util.List; + +/** + * A Tree node for Module information. + */ +public interface ModuleTree extends Tree { + /** + * Returns the list of import entries. + * + * @return the import entries + */ + public List getImportEntries(); + + /** + * Returns the list of local export entries. + * + * @return the local export entries + */ + public List getLocalExportEntries(); + + /** + * Returns the list of indirect export entries. + * + * @return the indirect export entries + */ + public List getIndirectExportEntries(); + + /** + * Returns the list of star export entries. + * + * @return the star export entries + */ + public List getStarExportEntries(); +} diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ModuleTreeImpl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ModuleTreeImpl.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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.api.tree; + +import java.util.List; +import java.util.stream.Collectors; +import jdk.nashorn.internal.ir.FunctionNode; +import jdk.nashorn.internal.ir.IdentNode; +import jdk.nashorn.internal.ir.Module; +import static jdk.nashorn.api.tree.ExportEntryTreeImpl.createExportList; +import static jdk.nashorn.api.tree.ImportEntryTreeImpl.createImportList; + +final class ModuleTreeImpl extends TreeImpl implements ModuleTree { + + private final Module mod; + private final List imports; + private final List localExports; + private final List indirectExports; + private final List starExports; + + private ModuleTreeImpl(final FunctionNode func, + final List imports, + final List localExports, + final List indirectExports, + final List starExports) { + super(func); + assert func.getKind() == FunctionNode.Kind.MODULE : "module function node expected"; + this.mod = func.getModule(); + this.imports = imports; + this.localExports = localExports; + this.indirectExports = indirectExports; + this.starExports = starExports; + } + + static ModuleTreeImpl create(final FunctionNode func) { + final Module mod = func.getModule(); + return new ModuleTreeImpl(func, + createImportList(mod.getImportEntries()), + createExportList(mod.getLocalExportEntries()), + createExportList(mod.getIndirectExportEntries()), + createExportList(mod.getStarExportEntries())); + } + + @Override + public Kind getKind() { + return Tree.Kind.MODULE; + } + + @Override + public List getImportEntries() { + return imports; + } + + @Override + public List getLocalExportEntries() { + return localExports; + } + + @Override + public List getIndirectExportEntries() { + return indirectExports; + } + + @Override + public List getStarExportEntries() { + return starExports; + } + + @Override + public R accept(final TreeVisitor visitor, final D data) { + return visitor.visitModule(this, data); + } + + static IdentifierTree identOrNull(final IdentNode node) { + return node != null? new IdentifierTreeImpl(node) : null; + } +} diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/Parser.java --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/Parser.java Wed Jul 05 21:57:12 2017 +0200 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/Parser.java Wed Jul 05 21:58:29 2017 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * 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,6 +130,8 @@ *
        "--no-syntax-extensions" or "-nse"
        disable ECMAScript syntax extensions
        *
        "-scripting"
        enable scripting mode extensions
        *
        "-strict"
        enable ECMAScript strict mode
        + *
        "--language=es6"
        enable ECMAScript 6 parsing mode
        + *
        "--es6-module"
        enable ECMAScript 6 module parsing mode. This option implies --language=es6
        * * * @throws NullPointerException if options array or any of its element is null @@ -148,6 +150,8 @@ case "-nse": case "-scripting": case "-strict": + case "--language=es6": + case "--es6-module": break; default: throw new IllegalArgumentException(opt); diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ParserImpl.java --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ParserImpl.java Wed Jul 05 21:57:12 2017 +0200 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ParserImpl.java Wed Jul 05 21:58:29 2017 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * 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,6 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ - package jdk.nashorn.api.tree; import java.io.File; @@ -31,6 +30,7 @@ import java.io.Reader; import java.net.URL; import java.nio.file.Path; +import java.util.Arrays; import java.util.Map; import java.util.Objects; import jdk.nashorn.api.scripting.NashornException; @@ -47,51 +47,94 @@ final class ParserImpl implements Parser { private final ScriptEnvironment env; + private final boolean moduleMode; ParserImpl(final String... args) throws IllegalArgumentException { - Objects.requireNonNull(args); - Options options = new Options("nashorn"); - options.process(args); - this.env = new ScriptEnvironment(options, - new PrintWriter(System.out), new PrintWriter(System.err)); + Objects.requireNonNull(args); + + // handle the parser specific "--es6-module" option + boolean seenModuleOption = false; + for (int idx = 0; idx < args.length; idx++) { + final String opt = args[idx]; + if (opt.equals("--es6-module")) { + seenModuleOption = true; + /* + * Nashorn parser does not understand parser API specific + * option. This option implies --language=es6. So, we change + * the option to --language=es6. Note that if user specified + * --language=es6 explicitly, that is okay. Nashorn tolerates + * repeated options! + */ + args[idx] = "--language=es6"; + break; + } + } + this.moduleMode = seenModuleOption; + + // append "--parse-only to signal to the Nashorn that it + // is being used in "parse only" mode. + String[] newArgs = Arrays.copyOf(args, args.length + 1, String[].class); + newArgs[args.length] = "--parse-only"; + Options options = new Options("nashorn"); + options.process(newArgs); + this.env = new ScriptEnvironment(options, + new PrintWriter(System.out), new PrintWriter(System.err)); } @Override public CompilationUnitTree parse(final File file, final DiagnosticListener listener) throws IOException, NashornException { + if (moduleMode) { + return parseModule(file, listener); + } final Source src = Source.sourceFor(Objects.requireNonNull(file).getName(), file); return translate(makeParser(src, listener).parse()); } @Override public CompilationUnitTree parse(final Path path, final DiagnosticListener listener) throws IOException, NashornException { + if (moduleMode) { + return parseModule(path, listener); + } final Source src = Source.sourceFor(Objects.requireNonNull(path).toString(), path); return translate(makeParser(src, listener).parse()); } @Override public CompilationUnitTree parse(final URL url, final DiagnosticListener listener) throws IOException, NashornException { + if (moduleMode) { + return parseModule(url, listener); + } final Source src = Source.sourceFor(url.toString(), url); return translate(makeParser(src, listener).parse()); } @Override public CompilationUnitTree parse(final String name, final Reader reader, final DiagnosticListener listener) throws IOException, NashornException { + if (moduleMode) { + return parseModule(name, reader, listener); + } final Source src = Source.sourceFor(Objects.requireNonNull(name), Objects.requireNonNull(reader)); return translate(makeParser(src, listener).parse()); } @Override public CompilationUnitTree parse(final String name, final String code, final DiagnosticListener listener) throws NashornException { + if (moduleMode) { + return parseModule(name, code, listener); + } final Source src = Source.sourceFor(name, code); return translate(makeParser(src, listener).parse()); } @Override public CompilationUnitTree parse(final ScriptObjectMirror scriptObj, final DiagnosticListener listener) throws NashornException { - final Map map = Objects.requireNonNull(scriptObj); + if (moduleMode) { + return parseModule(scriptObj, listener); + } + final Map map = Objects.requireNonNull(scriptObj); if (map.containsKey("script") && map.containsKey("name")) { final String script = JSType.toString(map.get("script")); - final String name = JSType.toString(map.get("name")); + final String name = JSType.toString(map.get("name")); final Source src = Source.sourceFor(name, script); return translate(makeParser(src, listener).parse()); } else { @@ -99,12 +142,55 @@ } } + private CompilationUnitTree parseModule(File file, DiagnosticListener listener) throws IOException, NashornException { + final Source src = Source.sourceFor(Objects.requireNonNull(file).getName(), file); + return makeModule(src, listener); + } + + private CompilationUnitTree parseModule(Path path, DiagnosticListener listener) throws IOException, NashornException { + final Source src = Source.sourceFor(Objects.requireNonNull(path).toString(), path); + return makeModule(src, listener); + } + + private CompilationUnitTree parseModule(URL url, DiagnosticListener listener) throws IOException, NashornException { + final Source src = Source.sourceFor(url.toString(), url); + return makeModule(src, listener); + } + + private CompilationUnitTree parseModule(String name, Reader reader, DiagnosticListener listener) throws IOException, NashornException { + final Source src = Source.sourceFor(Objects.requireNonNull(name), Objects.requireNonNull(reader)); + return makeModule(src, listener); + } + + private CompilationUnitTree parseModule(String name, String code, DiagnosticListener listener) throws NashornException { + final Source src = Source.sourceFor(name, code); + return makeModule(src, listener); + } + + private CompilationUnitTree parseModule(ScriptObjectMirror scriptObj, DiagnosticListener listener) throws NashornException { + final Map map = Objects.requireNonNull(scriptObj); + if (map.containsKey("script") && map.containsKey("name")) { + final String script = JSType.toString(map.get("script")); + final String name = JSType.toString(map.get("name")); + final Source src = Source.sourceFor(name, script); + return makeModule(src, listener); + } else { + throw new IllegalArgumentException("can't find 'script' and 'name' properties"); + } + } + + private CompilationUnitTree makeModule(Source src, DiagnosticListener listener) { + final FunctionNode modFunc = makeParser(src, listener).parseModule(src.getName()); + return new IRTranslator().translate(modFunc); + } + private jdk.nashorn.internal.parser.Parser makeParser(final Source source, final DiagnosticListener listener) { - final ErrorManager errMgr = listener != null? new ListenerErrorManager(listener) : new Context.ThrowErrorManager(); + final ErrorManager errMgr = listener != null ? new ListenerErrorManager(listener) : new Context.ThrowErrorManager(); return new jdk.nashorn.internal.parser.Parser(env, source, errMgr); } private static class ListenerErrorManager extends ErrorManager { + private final DiagnosticListener listener; ListenerErrorManager(final DiagnosticListener listener) { diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/PropertyTree.java --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/PropertyTree.java Wed Jul 05 21:57:12 2017 +0200 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/PropertyTree.java Wed Jul 05 21:58:29 2017 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -60,4 +60,18 @@ * @return the getter function of the property */ public FunctionExpressionTree getSetter(); + + /** + * Is this a class static property? + * + * @return true if this is a static property + */ + public boolean isStatic(); + + /** + * Is this a computed property? + * + * @return true if this is a computed property + */ + public boolean isComputed(); } diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/PropertyTreeImpl.java --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/PropertyTreeImpl.java Wed Jul 05 21:57:12 2017 +0200 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/PropertyTreeImpl.java Wed Jul 05 21:58:29 2017 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * 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,8 @@ private final ExpressionTree value; private final FunctionExpressionTree getter; private final FunctionExpressionTree setter; + private final boolean isStatic, isComputed; + PropertyTreeImpl(final PropertyNode node, final ExpressionTree key, final ExpressionTree value, @@ -42,6 +44,8 @@ this.value = value; this.getter = getter; this.setter = setter; + this.isStatic = node.isStatic(); + this.isComputed = node.isComputed(); } @Override @@ -70,6 +74,16 @@ } @Override + public boolean isStatic() { + return isStatic; + } + + @Override + public boolean isComputed() { + return isComputed; + } + + @Override public R accept(final TreeVisitor visitor, final D data) { return visitor.visitProperty(this, data); } diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/RegExpLiteralTree.java --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/RegExpLiteralTree.java Wed Jul 05 21:57:12 2017 +0200 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/RegExpLiteralTree.java Wed Jul 05 21:58:29 2017 +0200 @@ -30,7 +30,7 @@ * * @since 9 */ -public interface RegExpLiteralTree extends Tree { +public interface RegExpLiteralTree extends ExpressionTree { /** * Regular expression pattern to match. * diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/SimpleTreeVisitorES5_1.java --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/SimpleTreeVisitorES5_1.java Wed Jul 05 21:57:12 2017 +0200 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/SimpleTreeVisitorES5_1.java Wed Jul 05 21:58:29 2017 +0200 @@ -61,6 +61,45 @@ return null; } + /** + * Visits a {@code ModuleTree} tree by calling {@code + * visitUnknown}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code visitUnknown} + */ + @Override + public R visitModule(ModuleTree node, P p) { + return visitUnknown(node, p); + } + + /** + * Visits an {@code ExportEntryTree} tree by calling {@code + * visitUnknown}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code visitUnknown} + */ + @Override + public R visitExportEntry(ExportEntryTree node, P p) { + return visitUnknown(node, p); + } + + /** + * Visits an {@code ImportEntryTree} tree by calling {@code + * visitUnknown}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code visitUnknown} + */ + @Override + public R visitImportEntry(ImportEntryTree node, P p) { + return visitUnknown(node, p); + } + @Override public R visitBinary(final BinaryTree node, final P r) { node.getLeftOperand().accept(this, r); @@ -105,6 +144,32 @@ return null; } + /** + * Visits a {@code ClassDeclarationTree} tree by calling {@code + * visitUnknown}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code visitUnknown} + */ + @Override + public R visitClassDeclaration(ClassDeclarationTree node, P p) { + return visitUnknown(node, p); + } + + /** + * Visits a {@code ClassExpressionTree} tree by calling {@code + * visitUnknown}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code visitUnknown} + */ + @Override + public R visitClassExpression(ClassExpressionTree node, P p) { + return visitUnknown(node, p); + } + @Override public R visitConditionalExpression(final ConditionalExpressionTree node, final P r) { node.getCondition().accept(this, r); @@ -173,6 +238,19 @@ return null; } + /** + * Visits a {@code ForOfLoopTree} tree by calling {@code + * visitUnknown}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code visitUnknown} + */ + @Override + public R visitForOfLoop(ForOfLoopTree node, P p) { + return visitUnknown(node, p); + } + @Override public R visitFunctionCall(final FunctionCallTree node, final P r) { node.getFunctionSelect().accept(this, r); @@ -305,11 +383,37 @@ return null; } + /** + * Visits a {@code TemplateLiteralTree} tree by calling {@code + * visitUnknown}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code visitUnknown} + */ + @Override + public R visitTemplateLiteral(TemplateLiteralTree node, P p) { + return visitUnknown(node, p); + } + @Override public R visitEmptyStatement(final EmptyStatementTree node, final P r) { return null; } + /** + * Visits a {@code SpreadTree} tree by calling {@code + * visitUnknown}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code visitUnknown} + */ + @Override + public R visitSpread(SpreadTree node, P p) { + return visitUnknown(node, p); + } + @Override public R visitSwitch(final SwitchTree node, final P r) { node.getExpression().accept(this, r); @@ -382,9 +486,36 @@ return null; } + /** + * Visits a {@code YieldTree} tree by calling {@code + * visitUnknown}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code visitUnknown} + */ @Override - public R visitUnknown(final Tree node, final P r) { + public R visitYield(YieldTree node, P p) { + return visitUnknown(node, p); + } + + /** + * {@inheritDoc} + * + * @implSpec The default implementation of this method in {@code + * SimpleTreeVisitorES5_1} will always throw {@code + * UnknownTypeException}. This behavior is not required of a + * subclass. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return abnormal return by throwing exception always + * @throws UnknownTreeException + * a visitor implementation may optionally throw this exception + */ + @Override + public R visitUnknown(final Tree node, final P p) { // unknown in ECMAScript 5.1 edition - throw new UnknownTreeException(node, r); + throw new UnknownTreeException(node, p); } } diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/SimpleTreeVisitorES6.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/SimpleTreeVisitorES6.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,226 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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.api.tree; + +import java.util.List; + +/** + * A simple implementation of the TreeVisitor for ECMAScript edition 6. + * + *

        The visit methods corresponding to ES 6 language constructs walk the + * "components" of the given tree by calling accept method passing the + * current visitor and the additional parameter. + * + *

        For constructs introduced in later versions, {@code visitUnknown} + * is called instead which throws {@link UnknownTreeException}. + * + *

        Methods in this class may be overridden subject to their + * general contract. Note that annotating methods in concrete + * subclasses with {@link java.lang.Override @Override} will help + * ensure that methods are overridden as intended. + * + * @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. + */ +public class SimpleTreeVisitorES6 extends SimpleTreeVisitorES5_1 { + @Override + public R visitCompilationUnit(final CompilationUnitTree node, final P r) { + final ModuleTree mod = node.getModule(); + if (mod != null) { + mod.accept(this, r); + } + return super.visitCompilationUnit(node, r); + } + + /** + * Visit Module tree. + * + * @param node node being visited + * @param p extra parameter passed to the visitor + * @return value from the visitor + */ + @Override + public R visitModule(ModuleTree node, P p) { + node.getImportEntries().forEach(e -> visitImportEntry(e, p)); + node.getLocalExportEntries().forEach(e -> visitExportEntry(e, p)); + node.getIndirectExportEntries().forEach(e -> visitExportEntry(e, p)); + node.getStarExportEntries().forEach(e -> visitExportEntry(e, p)); + return null; + } + + /** + * Visit Module ExportEntry tree. + * + * @param node node being visited + * @param p extra parameter passed to the visitor + * @return value from the visitor + */ + @Override + public R visitExportEntry(ExportEntryTree node, P p) { + return null; + } + + /** + * Visit Module ImportEntry tree. + * + * @param node node being visited + * @param p extra parameter passed to the visitor + * @return value from the visitor + */ + @Override + public R visitImportEntry(ImportEntryTree node, P p) { + return null; + } + + /** + * Visit class statement tree. + * + * @param node node being visited + * @param p extra parameter passed to the visitor + * @return value from the visitor + */ + @Override + public R visitClassDeclaration(ClassDeclarationTree node, P p) { + node.getName().accept(this, p); + final ExpressionTree heritage = node.getClassHeritage(); + if (heritage != null) { + heritage.accept(this, p); + } + final PropertyTree constructor = node.getConstructor(); + if (constructor != null) { + constructor.accept(this, p); + } + final List elements = node.getClassElements(); + if (elements != null) { + for (PropertyTree prop : elements) { + prop.accept(this, p); + } + } + + return null; + } + + /** + * Visit class expression tree. + * + * @param node node being visited + * @param p extra parameter passed to the visitor + * @return value from the visitor + */ + @Override + public R visitClassExpression(ClassExpressionTree node, P p) { + node.getName().accept(this, p); + final ExpressionTree heritage = node.getClassHeritage(); + if (heritage != null) { + heritage.accept(this, p); + } + final PropertyTree constructor = node.getConstructor(); + if (constructor != null) { + constructor.accept(this, p); + } + final List elements = node.getClassElements(); + if (elements != null) { + for (PropertyTree prop : elements) { + prop.accept(this, p); + } + } + + return null; + } + + /** + * Visit for..of statement tree. + * + * @param node node being visited + * @param p extra parameter passed to the visitor + * @return value from the visitor + */ + @Override + public R visitForOfLoop(final ForOfLoopTree node, final P p) { + node.getVariable().accept(this, p); + node.getExpression().accept(this, p); + final StatementTree stat = node.getStatement(); + if (stat != null) { + stat.accept(this, p); + } + return null; + } + + /** + * Visit 'yield' expression tree. + * + * @param node node being visited + * @param p extra parameter passed to the visitor + * @return value from the visitor + */ + @Override + public R visitYield(YieldTree node, P p) { + node.getExpression().accept(this, p); + return null; + } + + /** + * Visit 'spread' expression tree. + * + * @param node node being visited + * @param p extra parameter passed to the visitor + * @return value from the visitor + */ + @Override + public R visitSpread(SpreadTree node, P p) { + node.getExpression().accept(this, p); + return null; + } + + /** + * Visit template literal tree. + * + * @param node node being visited + * @param p extra parameter passed to the visitor + * @return value from the visitor + */ + @Override + public R visitTemplateLiteral(TemplateLiteralTree node, P p) { + final List expressions = node.getExpressions(); + for (ExpressionTree expr : expressions) { + expr.accept(this, p); + } + return null; + } + + @Override + public R visitVariable(final VariableTree node, final P r) { + final ExpressionTree expr = node.getBinding(); + if (expr != null) { + expr.accept(this, r); + } + super.visitVariable(node, r); + return null; + } +} diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/SpreadTree.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/SpreadTree.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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.api.tree; + +/** + * A tree node for spread operator in array elements, function call arguments. + */ +public interface SpreadTree extends ExpressionTree { + /** + * Returns the expression that is being spread. + * + * @return The expression that is being spread. + */ + ExpressionTree getExpression(); +} diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/SpreadTreeImpl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/SpreadTreeImpl.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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.api.tree; + +import jdk.nashorn.internal.ir.Expression; + +final class SpreadTreeImpl extends ExpressionTreeImpl + implements SpreadTree { + + private final ExpressionTree expr; + + SpreadTreeImpl(final Expression exprNode, final ExpressionTree expr) { + super(exprNode); + this.expr = expr; + } + + @Override + public Tree.Kind getKind() { + return Tree.Kind.SPREAD; + } + + @Override + public ExpressionTree getExpression() { + return expr; + } + + @Override + public R accept(final TreeVisitor visitor, final D data) { + return visitor.visitSpread(this, data); + } +} diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/TemplateLiteralTree.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/TemplateLiteralTree.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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.api.tree; + +import java.util.List; + +/** + * A tree node for template literal strings. + * + * For example: + *

        + * `This is a String with ${computed} values in it`
        + * 
        + * + * @since 9 + * + */ +public interface TemplateLiteralTree extends ExpressionTree { + /** + * Returns the list of expressions in this template string + * + * @return the list of expressions in this template string + */ + List getExpressions(); +} diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/TemplateLiteralTreeImpl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/TemplateLiteralTreeImpl.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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.api.tree; + +import java.util.List; +import jdk.nashorn.internal.ir.Expression; + +final class TemplateLiteralTreeImpl extends ExpressionTreeImpl + implements TemplateLiteralTree { + + private final List expressions; + + TemplateLiteralTreeImpl(Expression node, List expressions) { + super(node); + this.expressions = expressions; + } + + @Override + public Kind getKind() { + return Kind.TEMPLATE_LITERAL; + } + + @Override + public List getExpressions() { + return expressions; + } + + + @Override + public R accept(final TreeVisitor visitor, final D data) { + return visitor.visitTemplateLiteral(this, data); + } +} diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/Tree.java --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/Tree.java Wed Jul 05 21:57:12 2017 +0200 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/Tree.java Wed Jul 05 21:58:29 2017 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * 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,6 +65,16 @@ BREAK(BreakTree.class), /** + * Used for instances of {@link ClassDeclarationTree}. + */ + CLASS(ClassDeclarationTree.class), + + /** + * Used for instances of {@link ClassExpressionTree}. + */ + CLASS_EXPRESSION(ClassExpressionTree.class), + + /** * Used for instances of {@link CaseTree}. */ CASE(CaseTree.class), @@ -150,6 +160,21 @@ LABELED_STATEMENT(LabeledStatementTree.class), /** + * Used for instances of {@link ModuleTree}. + */ + MODULE(ModuleTree.class), + + /** + * Used for instances of {@link ExportEntryTree}. + */ + EXPORT_ENTRY(ExportEntryTree.class), + + /** + * Used for instances of {@link ImportEntryTree}. + */ + IMPORT_ENTRY(ImportEntryTree.class), + + /** * Used for instances of {@link FunctionDeclarationTree}. */ FUNCTION(FunctionDeclarationTree.class), @@ -185,6 +210,11 @@ REGEXP_LITERAL(RegExpLiteralTree.class), /** + * Used for instances of {@link TemplateLiteralTree}. + */ + TEMPLATE_LITERAL(TemplateLiteralTree.class), + + /** * Used for instances of {@link ReturnTree}. */ RETURN(ReturnTree.class), @@ -286,7 +316,7 @@ /** * Used for instances of {@link UnaryTree} representing logical - * void operator {@code typeof}. + * void operator {@code void}. */ VOID(UnaryTree.class), @@ -495,6 +525,18 @@ OR_ASSIGNMENT(CompoundAssignmentTree.class), /** + * Used for instances of {@link SpreadTree} representing + * spread "operator" for arrays and function call arguments. + */ + SPREAD(SpreadTree.class), + + /** + * Used for instances of {@link YieldTree} representing (generator) + * yield expression {@code yield expr}. + */ + YIELD(YieldTree.class), + + /** * Used for instances of {@link LiteralTree} representing * a number literal expression of type {@code double}. */ diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/TreeImpl.java --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/TreeImpl.java Wed Jul 05 21:57:12 2017 +0200 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/TreeImpl.java Wed Jul 05 21:58:29 2017 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * 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,10 +137,15 @@ return Kind.BITWISE_COMPLEMENT; case DELETE: return Kind.DELETE; + case SPREAD_ARRAY: + case SPREAD_ARGUMENT: + return Kind.SPREAD; case TYPEOF: return Kind.TYPEOF; case VOID: return Kind.VOID; + case YIELD: + return Kind.YIELD; case IN: return Kind.IN; case INSTANCEOF: diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/TreeVisitor.java --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/TreeVisitor.java Wed Jul 05 21:57:12 2017 +0200 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/TreeVisitor.java Wed Jul 05 21:58:29 2017 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -118,6 +118,24 @@ R visitCatch(CatchTree node, P p); /** + * Visit class statement tree. + * + * @param node node being visited + * @param p extra parameter passed to the visitor + * @return value from the visitor + */ + R visitClassDeclaration(ClassDeclarationTree node, P p); + + /** + * Visit class expression tree. + * + * @param node node being visited + * @param p extra parameter passed to the visitor + * @return value from the visitor + */ + R visitClassExpression(ClassExpressionTree node, P p); + + /** * Visit conditional expression tree. * * @param node node being visited @@ -190,6 +208,15 @@ R visitForInLoop(ForInLoopTree node, P p); /** + * Visit for..of statement tree. + * + * @param node node being visited + * @param p extra parameter passed to the visitor + * @return value from the visitor + */ + R visitForOfLoop(ForOfLoopTree node, P p); + + /** * Visit function call expression tree. * * @param node node being visited @@ -216,7 +243,7 @@ */ R visitFunctionExpression(FunctionExpressionTree node, P p); - /** + /** * Visit identifier tree. * * @param node node being visited @@ -334,6 +361,15 @@ R visitRegExpLiteral(RegExpLiteralTree node, P p); /** + * Visit template literal tree. + * + * @param node node being visited + * @param p extra parameter passed to the visitor + * @return value from the visitor + */ + R visitTemplateLiteral(TemplateLiteralTree node, P p); + + /** * Visit an empty statement tree. * * @param node node being visited @@ -343,6 +379,15 @@ R visitEmptyStatement(EmptyStatementTree node, P p); /** + * Visit 'spread' expression tree. + * + * @param node node being visited + * @param p extra parameter passed to the visitor + * @return value from the visitor + */ + R visitSpread(SpreadTree node, P p); + + /** * Visit 'switch' statement tree. * * @param node node being visited @@ -370,6 +415,33 @@ R visitCompilationUnit(CompilationUnitTree node, P p); /** + * Visit Module tree. + * + * @param node node being visited + * @param p extra parameter passed to the visitor + * @return value from the visitor + */ + R visitModule(ModuleTree node, P p); + + /** + * Visit Module ExportEntry tree. + * + * @param node node being visited + * @param p extra parameter passed to the visitor + * @return value from the visitor + */ + R visitExportEntry(ExportEntryTree node, P p); + + /** + * Visit Module ImportEntry tree. + * + * @param node node being visited + * @param p extra parameter passed to the visitor + * @return value from the visitor + */ + R visitImportEntry(ImportEntryTree node, P p); + + /** * Visit 'try' statement tree. * * @param node node being visited @@ -424,6 +496,15 @@ R visitWith(WithTree node, P p); /** + * Visit 'yield' expression tree. + * + * @param node node being visited + * @param p extra parameter passed to the visitor + * @return value from the visitor + */ + R visitYield(YieldTree node, P p); + + /** * Visit unknown expression/statement tree. This fallback will be * called if new Tree subtypes are introduced in future. A specific * implementation may throw {{@linkplain UnknownTreeException unknown tree exception} diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/VariableTree.java --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/VariableTree.java Wed Jul 05 21:57:12 2017 +0200 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/VariableTree.java Wed Jul 05 21:58:29 2017 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * 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,22 +26,26 @@ package jdk.nashorn.api.tree; /** - * A tree node for a variable declaration. + * A tree node for a variable declaration statement. * * For example: *
        - *   var name initializer ;
        + *   var name [ initializer ] ;
        + *   var binding_pattern [ initializer ];
          * 
        * * @since 9 */ public interface VariableTree extends StatementTree { /** - * Returns the name of this variable. + * Returns the binding of this declaration. This is an {@link IdentifierTree} + * for a binding identifier case (simple variable declaration). + * This is an {@link ObjectLiteralTree} or a {@link ArrayLiteralTree} for a + * destructuring declaration. * - * @return the name of this variable + * @return the binding expression of this declaration */ - String getName(); + ExpressionTree getBinding(); /** * Returns the initial value expression for this variable. This is @@ -50,4 +54,18 @@ * @return the initial value expression */ ExpressionTree getInitializer(); + + /** + * Is this a const declaration? + * + * @return true if this is a const declaration + */ + boolean isConst(); + + /** + * Is this a let declaration? + * + * @return true if this is a let declaration + */ + boolean isLet(); } diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/VariableTreeImpl.java --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/VariableTreeImpl.java Wed Jul 05 21:57:12 2017 +0200 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/VariableTreeImpl.java Wed Jul 05 21:58:29 2017 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * 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,12 +28,12 @@ import jdk.nashorn.internal.ir.VarNode; final class VariableTreeImpl extends StatementTreeImpl implements VariableTree { - private final String name; + private final IdentifierTree ident; private final ExpressionTree init; - VariableTreeImpl(final VarNode node, final ExpressionTree init) { + VariableTreeImpl(final VarNode node, final IdentifierTree ident, final ExpressionTree init) { super(node); - this.name = node.getName().getName(); + this.ident = ident; this.init = init; } @@ -43,8 +43,8 @@ } @Override - public String getName() { - return name; + public ExpressionTree getBinding() { + return ident; } @Override @@ -53,6 +53,16 @@ } @Override + public boolean isConst() { + return ((VarNode)node).isConst(); + } + + @Override + public boolean isLet() { + return ((VarNode)node).isLet(); + } + + @Override public R accept(final TreeVisitor visitor, final D data) { return visitor.visitVariable(this, data); } diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/YieldTree.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/YieldTree.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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.api.tree; + +/** + * A tree node for yield expressions used in generator functions. + * + * For example: + *
        + * function* id(){
        + *     var index = 0;
        + *     while(index < 10)
        + *         yield index++;
        + * }
        + * 
        + * + * @since 9 + */ +public interface YieldTree extends ExpressionTree { + /** + * Returns the expression that is yielded. + * + * @return The expression that is yielded. + */ + ExpressionTree getExpression(); + + /** + * Is this a yield * expression in a generator function? + * + * For example: + *
        +     * function* id(){
        +     *     yield 1;
        +     *     yield * anotherGeneratorFunc();
        +     *     yield 10;
        +     * }
        +     * 
        + * + * + * @return true if this is a yield * expression + */ + boolean isStar(); +} diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/YieldTreeImpl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/YieldTreeImpl.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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.api.tree; + +import jdk.nashorn.internal.ir.Expression; +import jdk.nashorn.internal.ir.UnaryNode; +import jdk.nashorn.internal.parser.TokenType; + +final class YieldTreeImpl extends ExpressionTreeImpl + implements YieldTree { + + private final ExpressionTree expr; + + YieldTreeImpl(final Expression exprNode, final ExpressionTree expr) { + super(exprNode); + this.expr = expr; + } + + @Override + public Kind getKind() { + return Kind.YIELD; + } + + @Override + public ExpressionTree getExpression() { + return expr; + } + + @Override + public boolean isStar() { + return ((UnaryNode) node).isTokenType(TokenType.YIELD_STAR); + } + + @Override + public R accept(final TreeVisitor visitor, final D data) { + return visitor.visitYield(this, data); + } +} diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/SplitIntoFunctions.java --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/SplitIntoFunctions.java Wed Jul 05 21:57:12 2017 +0200 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/SplitIntoFunctions.java Wed Jul 05 21:58:29 2017 +0200 @@ -167,6 +167,7 @@ createIdent(name), originalFn.getName() + "$" + name, isProgram ? Collections.singletonList(createReturnParamIdent()) : Collections.emptyList(), + null, FunctionNode.Kind.NORMAL, // We only need IS_SPLIT conservatively, in case it contains any array units so that we force // the :callee's existence, to force :scope to never be in a slot lower than 2. This is actually diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/ClassNode.java --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/ClassNode.java Wed Jul 05 21:57:12 2017 +0200 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/ClassNode.java Wed Jul 05 21:58:29 2017 +0200 @@ -42,6 +42,7 @@ private final PropertyNode constructor; private final List classElements; private final int line; + private final boolean isStatement; /** * Constructor. @@ -53,15 +54,17 @@ * @param classHeritage class heritage * @param constructor constructor * @param classElements class elements + * @param isStatement is this a statement or an expression? */ public ClassNode(final int line, final long token, final int finish, final IdentNode ident, final Expression classHeritage, final PropertyNode constructor, - final List classElements) { + final List classElements, final boolean isStatement) { super(token, finish); this.line = line; this.ident = ident; this.classHeritage = classHeritage; this.constructor = constructor; this.classElements = classElements; + this.isStatement = isStatement; } /** @@ -101,6 +104,15 @@ } /** + * Returns if this class was a statement or an expression + * + * @return true if this class was a statement + */ + public boolean isStatement() { + return isStatement; + } + + /** * Returns the line number. * * @return the line number diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/ExpressionStatement.java --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/ExpressionStatement.java Wed Jul 05 21:57:12 2017 +0200 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/ExpressionStatement.java Wed Jul 05 21:58:29 2017 +0200 @@ -27,6 +27,7 @@ import jdk.nashorn.internal.ir.annotations.Immutable; import jdk.nashorn.internal.ir.visitor.NodeVisitor; +import jdk.nashorn.internal.parser.TokenType; /** * IR representation for executing bare expressions. Basically, an expression @@ -39,6 +40,23 @@ /** Expression to execute. */ private final Expression expression; + private final TokenType destructuringDecl; + + /** + * Constructor + * + * @param lineNumber line number + * @param token token + * @param finish finish + * @param expression the expression to execute + * @param destructuringDecl does this statement represent a destructuring declaration? + */ + public ExpressionStatement(final int lineNumber, final long token, final int finish, + final Expression expression, final TokenType destructuringDecl) { + super(lineNumber, token, finish); + this.expression = expression; + this.destructuringDecl = destructuringDecl; + } /** * Constructor @@ -49,13 +67,13 @@ * @param expression the expression to execute */ public ExpressionStatement(final int lineNumber, final long token, final int finish, final Expression expression) { - super(lineNumber, token, finish); - this.expression = expression; + this(lineNumber, token, finish, expression, null); } private ExpressionStatement(final ExpressionStatement expressionStatement, final Expression expression) { super(expressionStatement); this.expression = expression; + this.destructuringDecl = null; } @Override @@ -81,6 +99,15 @@ } /** + * Return declaration type if this expression statement is a destructuring declaration + * + * @return declaration type (LET, VAR, CONST) if destructuring declaration, null otherwise. + */ + public TokenType destructuringDeclarationType() { + return destructuringDecl; + } + + /** * Reset the expression to be executed * @param expression the expression * @return new or same execute node diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/FunctionNode.java --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/FunctionNode.java Wed Jul 05 21:57:12 2017 +0200 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/FunctionNode.java Wed Jul 05 21:58:29 2017 +0200 @@ -35,6 +35,7 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; +import java.util.Map; import jdk.nashorn.internal.codegen.CompileUnit; import jdk.nashorn.internal.codegen.Compiler; import jdk.nashorn.internal.codegen.CompilerConstants; @@ -106,6 +107,9 @@ /** List of parameters. */ private final List parameters; + /** Map of ES6 function parameter expressions. */ + private final Map parameterExpressions; + /** First token of function. **/ private final long firstToken; @@ -242,6 +246,9 @@ /** Does this function use new.target? */ public static final int ES6_USES_NEW_TARGET = 1 << 25; + /** Does this function have expression as its body? */ + public static final int HAS_EXPRESSION_BODY = 1 << 26; + /** Does this function or any nested functions contain an eval? */ private static final int HAS_DEEP_EVAL = HAS_EVAL | HAS_NESTED_EVAL; @@ -306,6 +313,7 @@ * @param ident the identifier * @param name the name of the function * @param parameters parameter list + * @param paramExprs the ES6 function parameter expressions * @param kind kind of function as in {@link FunctionNode.Kind} * @param flags initial flags * @param body body of the function @@ -324,6 +332,7 @@ final IdentNode ident, final String name, final List parameters, + final Map paramExprs, final FunctionNode.Kind kind, final int flags, final Block body, @@ -338,6 +347,7 @@ this.name = name; this.kind = kind; this.parameters = parameters; + this.parameterExpressions = paramExprs; this.firstToken = firstToken; this.lastToken = lastToken; this.namespace = namespace; @@ -375,6 +385,7 @@ this.lastToken = lastToken; this.body = body; this.parameters = parameters; + this.parameterExpressions = functionNode.parameterExpressions; this.thisProperties = thisProperties; this.rootClass = rootClass; this.source = source; @@ -977,6 +988,15 @@ } /** + * Get the ES6 style parameter expressions of this function. This may be null. + * + * @return a Map of parameter IdentNode to Expression node (for ES6 parameter expressions) + */ + public Map getParameterExpressions() { + return parameterExpressions; + } + + /** * Return the number of parameters to this function * @return the number of parameters */ diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/TemplateLiteral.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/TemplateLiteral.java Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.nashorn.internal.ir; + +import java.util.Collections; +import java.util.List; +import jdk.nashorn.internal.codegen.types.Type; +import jdk.nashorn.internal.ir.visitor.NodeVisitor; + +/** + * Represents ES6 template string expression. Note that this Node class is used + * only in "parse only" mode. In evaluation mode, Parser directly folds template + * literal as string concatenation. Parser API uses this node to represent ES6 + * template literals "as is" rather than as a String concatenation. + */ +public final class TemplateLiteral extends Expression { + private static final long serialVersionUID = 1L; + private final List exprs; + + public TemplateLiteral(final List exprs) { + super(exprs.get(0).getToken(), exprs.get(exprs.size() - 1).finish); + this.exprs = exprs; + } + + @Override + public Type getType() { + return Type.STRING; + } + + @Override + public Node accept(NodeVisitor visitor) { + if (visitor.enterTemplateLiteral(this)) { + return visitor.leaveTemplateLiteral(this); + } + + return this; + } + + @Override + public void toString(StringBuilder sb, boolean printType) { + for (Expression expr : exprs) { + sb.append(expr); + } + } + + /** + * The list of expressions that are part of this template literal. + * + * @return the list of expressions that are part of this template literal. + */ + public List getExpressions() { + return Collections.unmodifiableList(exprs); + } +} \ No newline at end of file diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/visitor/NodeVisitor.java --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/visitor/NodeVisitor.java Wed Jul 05 21:57:12 2017 +0200 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/visitor/NodeVisitor.java Wed Jul 05 21:58:29 2017 +0200 @@ -59,6 +59,7 @@ import jdk.nashorn.internal.ir.SplitNode; import jdk.nashorn.internal.ir.SplitReturn; import jdk.nashorn.internal.ir.SwitchNode; +import jdk.nashorn.internal.ir.TemplateLiteral; import jdk.nashorn.internal.ir.TernaryNode; import jdk.nashorn.internal.ir.ThrowNode; import jdk.nashorn.internal.ir.TryNode; @@ -738,6 +739,26 @@ } /** + * Callback for entering a TemplateLiteral (used only in --parse-only mode) + * + * @param templateLiteral the node + * @return true if traversal should continue and node children be traversed, false otherwise + */ + public boolean enterTemplateLiteral(final TemplateLiteral templateLiteral) { + return enterDefault(templateLiteral); + } + + /** + * Callback for leaving a TemplateLiteral (used only in --parse-only mode) + * + * @param templateLiteral the node + * @return processed node, which will replace the original one, or the original node + */ + public Node leaveTemplateLiteral(final TemplateLiteral templateLiteral) { + return leaveDefault(templateLiteral); + } + + /** * Callback for entering a TernaryNode * * @param ternaryNode the node diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/Parser.java --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/Parser.java Wed Jul 05 21:57:12 2017 +0200 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/Parser.java Wed Jul 05 21:58:29 2017 +0200 @@ -127,6 +127,7 @@ import jdk.nashorn.internal.ir.RuntimeNode; import jdk.nashorn.internal.ir.Statement; import jdk.nashorn.internal.ir.SwitchNode; +import jdk.nashorn.internal.ir.TemplateLiteral; import jdk.nashorn.internal.ir.TernaryNode; import jdk.nashorn.internal.ir.ThrowNode; import jdk.nashorn.internal.ir.TryNode; @@ -545,7 +546,7 @@ sb.append(ident.getName()); final String name = namespace.uniqueName(sb.toString()); - assert parentFunction != null || name.equals(PROGRAM.symbolName()) : "name = " + name; + assert parentFunction != null || kind == FunctionNode.Kind.MODULE || name.equals(PROGRAM.symbolName()) : "name = " + name; int flags = 0; if (isStrictMode) { @@ -575,6 +576,7 @@ ident, function.getName(), parameters, + function.getParameterExpressions(), kind, function.getFlags(), body, @@ -623,19 +625,6 @@ } /** - * Get the statements in a case clause. - */ - private List caseStatementList() { - final ParserContextBlockNode newBlock = newBlock(); - try { - statementList(); - } finally { - restoreBlock(newBlock); - } - return newBlock.getStatements(); - } - - /** * Get all the statements generated by a single statement. * @return Statements. */ @@ -855,17 +844,6 @@ }); } - private static Expression newBinaryExpression(final long op, final Expression lhs, final Expression rhs) { - final TokenType opType = Token.descType(op); - - // Build up node. - if (BinaryNode.isLogical(opType)) { - return new BinaryNode(op, new JoinPredecessorExpression(lhs), new JoinPredecessorExpression(rhs)); - } - return new BinaryNode(op, lhs, rhs); - } - - /** * Reduce increment/decrement to simpler operations. * @param firstToken First token. @@ -1268,7 +1246,7 @@ className = getIdent(); } - return classTail(classLineNumber, classToken, className); + return classTail(classLineNumber, classToken, className, isStatement); } private static final class ClassElementKey { @@ -1317,7 +1295,8 @@ * static MethodDefinition[?Yield] * ; */ - private ClassNode classTail(final int classLineNumber, final long classToken, final IdentNode className) { + private ClassNode classTail(final int classLineNumber, final long classToken, + final IdentNode className, final boolean isStatement) { final boolean oldStrictMode = isStrictMode; isStrictMode = true; try { @@ -1399,7 +1378,7 @@ } classElements.trimToSize(); - return new ClassNode(classLineNumber, classToken, finish, className, classHeritage, constructor, classElements); + return new ClassNode(classLineNumber, classToken, finish, className, classHeritage, constructor, classElements, isStatement); } finally { isStrictMode = oldStrictMode; } @@ -1601,6 +1580,9 @@ private List variableDeclarationList(final TokenType varType, final boolean isStatement, final int sourceOrder) { // VAR tested in caller. assert varType == VAR || varType == LET || varType == CONST; + final int varLine = line; + final long varToken = token; + next(); final List bindings = new ArrayList<>(); @@ -1613,9 +1595,6 @@ Expression missingAssignment = null; while (true) { - // Get starting token. - final int varLine = line; - final long varToken = token; // Get name of var. if (type == YIELD && inGeneratorFunction()) { expect(IDENT); @@ -1627,10 +1606,14 @@ if (isDestructuring) { final int finalVarFlags = varFlags; verifyDestructuringBindingPattern(binding, new Consumer() { + @Override public void accept(final IdentNode identNode) { verifyIdent(identNode, contextString); - final VarNode var = new VarNode(varLine, varToken, sourceOrder, identNode.getFinish(), identNode.setIsDeclaredHere(), null, finalVarFlags); - appendStatement(var); + if (!env._parse_only) { + // don't bother adding a variable if we are just parsing! + final VarNode var = new VarNode(varLine, varToken, sourceOrder, identNode.getFinish(), identNode.setIsDeclaredHere(), null, finalVarFlags); + appendStatement(var); + } } }); } @@ -1682,7 +1665,7 @@ assert init != null || !isStatement; binding = init == null ? binding : verifyAssignment(Token.recast(varToken, ASSIGN), binding, init); if (isStatement) { - appendStatement(new ExpressionStatement(varLine, binding.getToken(), finish, binding)); + appendStatement(new ExpressionStatement(varLine, binding.getToken(), finish, binding, varType)); } else if (init == null) { if (missingAssignment == null) { missingAssignment = binding; @@ -1748,7 +1731,8 @@ * Verify destructuring variable declaration binding pattern and extract bound variable declarations. */ private void verifyDestructuringBindingPattern(final Expression pattern, final Consumer identifierCallback) { - assert pattern instanceof ObjectNode || pattern instanceof LiteralNode.ArrayLiteralNode; + assert (pattern instanceof BinaryNode && ((BinaryNode)pattern).isTokenType(ASSIGN)) || + pattern instanceof ObjectNode || pattern instanceof LiteralNode.ArrayLiteralNode; pattern.accept(new NodeVisitor(new LexicalContext()) { @Override public boolean enterLiteralNode(final LiteralNode literalNode) { @@ -1857,9 +1841,8 @@ // Get expression and add as statement. final Expression expression = expression(); - ExpressionStatement expressionStatement = null; if (expression != null) { - expressionStatement = new ExpressionStatement(expressionLine, expressionToken, finish, expression); + ExpressionStatement expressionStatement = new ExpressionStatement(expressionLine, expressionToken, finish, expression); appendStatement(expressionStatement); } else { expect(null); @@ -2625,6 +2608,10 @@ final long catchToken = token; next(); expect(LPAREN); + + // FIXME: ES6 catch parameter can be a BindingIdentifier or a BindingPattern + // We need to generalize this here! + // http://www.ecma-international.org/ecma-262/6.0/ final IdentNode exception = getIdent(); // ECMA 12.4.1 strict mode restrictions @@ -4021,12 +4008,18 @@ ParserContextFunctionNode currentFunction = lc.getCurrentFunction(); if (currentFunction != null) { - // desugar to: param = (param === undefined) ? initializer : param; - // possible alternative: if (param === undefined) param = initializer; - BinaryNode test = new BinaryNode(Token.recast(paramToken, EQ_STRICT), ident, newUndefinedLiteral(paramToken, finish)); - TernaryNode value = new TernaryNode(Token.recast(paramToken, TERNARY), test, new JoinPredecessorExpression(initializer), new JoinPredecessorExpression(ident)); - BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), ident, value); - lc.getFunctionBody(currentFunction).appendStatement(new ExpressionStatement(paramLine, assignment.getToken(), assignment.getFinish(), assignment)); + if (env._parse_only) { + // keep what is seen in source "as is" and save it as parameter expression + BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), ident, initializer); + currentFunction.addParameterExpression(ident, assignment); + } else { + // desugar to: param = (param === undefined) ? initializer : param; + // possible alternative: if (param === undefined) param = initializer; + BinaryNode test = new BinaryNode(Token.recast(paramToken, EQ_STRICT), ident, newUndefinedLiteral(paramToken, finish)); + TernaryNode value = new TernaryNode(Token.recast(paramToken, TERNARY), test, new JoinPredecessorExpression(initializer), new JoinPredecessorExpression(ident)); + BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), ident, value); + lc.getFunctionBody(currentFunction).appendStatement(new ExpressionStatement(paramLine, assignment.getToken(), assignment.getFinish(), assignment)); + } } } @@ -4050,16 +4043,31 @@ // binding pattern with initializer. desugar to: (param === undefined) ? initializer : param Expression initializer = assignmentExpression(false); - // TODO initializer must not contain yield expression if yield=true (i.e. this is generator function's parameter list) - BinaryNode test = new BinaryNode(Token.recast(paramToken, EQ_STRICT), ident, newUndefinedLiteral(paramToken, finish)); - value = new TernaryNode(Token.recast(paramToken, TERNARY), test, new JoinPredecessorExpression(initializer), new JoinPredecessorExpression(ident)); + + if (env._parse_only) { + // we don't want the synthetic identifier in parse only mode + value = initializer; + } else { + // TODO initializer must not contain yield expression if yield=true (i.e. this is generator function's parameter list) + BinaryNode test = new BinaryNode(Token.recast(paramToken, EQ_STRICT), ident, newUndefinedLiteral(paramToken, finish)); + value = new TernaryNode(Token.recast(paramToken, TERNARY), test, new JoinPredecessorExpression(initializer), new JoinPredecessorExpression(ident)); + } } ParserContextFunctionNode currentFunction = lc.getCurrentFunction(); if (currentFunction != null) { // destructuring assignment BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), pattern, value); - lc.getFunctionBody(currentFunction).appendStatement(new ExpressionStatement(paramLine, assignment.getToken(), assignment.getFinish(), assignment)); + if (env._parse_only) { + // in parse-only mode, represent source tree "as is" + if (ident.isDefaultParameter()) { + currentFunction.addParameterExpression(ident, assignment); + } else { + currentFunction.addParameterExpression(ident, pattern); + } + } else { + lc.getFunctionBody(currentFunction).appendStatement(new ExpressionStatement(paramLine, assignment.getToken(), assignment.getFinish(), assignment)); + } } } parameters.add(ident); @@ -4077,7 +4085,9 @@ ParserContextFunctionNode currentFunction = lc.getCurrentFunction(); if (currentFunction != null) { // declare function-scope variables for destructuring bindings - lc.getFunctionBody(currentFunction).appendStatement(new VarNode(paramLine, Token.recast(paramToken, VAR), pattern.getFinish(), identNode, null)); + if (!env._parse_only) { + lc.getFunctionBody(currentFunction).appendStatement(new VarNode(paramLine, Token.recast(paramToken, VAR), pattern.getFinish(), identNode, null)); + } // detect duplicate bounds names in parameter list currentFunction.addParameterBinding(identNode); currentFunction.setSimpleParameterList(false); @@ -4136,6 +4146,7 @@ // the note below for reasoning on skipping happening before instead of after RBRACE for // details). if (parseBody) { + functionNode.setFlag(FunctionNode.HAS_EXPRESSION_BODY); final ReturnNode returnNode = new ReturnNode(functionNode.getLineNumber(), expr.getToken(), lastFinish, expr); appendStatement(returnNode); } @@ -4305,7 +4316,7 @@ } private RuntimeNode referenceError(final Expression lhs, final Expression rhs, final boolean earlyError) { - if (earlyError) { + if (env._parse_only || earlyError) { throw error(JSErrorType.REFERENCE_ERROR, AbstractParser.message("invalid.lvalue"), lhs.getToken()); } final ArrayList args = new ArrayList<>(); @@ -4838,10 +4849,14 @@ ParserContextFunctionNode currentFunction = lc.getCurrentFunction(); if (currentFunction != null) { - BinaryNode test = new BinaryNode(Token.recast(paramToken, EQ_STRICT), ident, newUndefinedLiteral(paramToken, finish)); - TernaryNode value = new TernaryNode(Token.recast(paramToken, TERNARY), test, new JoinPredecessorExpression(initializer), new JoinPredecessorExpression(ident)); - BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), ident, value); - lc.getFunctionBody(currentFunction).appendStatement(new ExpressionStatement(paramLine, assignment.getToken(), assignment.getFinish(), assignment)); + if (env._parse_only) { + currentFunction.addParameterExpression(ident, param); + } else { + BinaryNode test = new BinaryNode(Token.recast(paramToken, EQ_STRICT), ident, newUndefinedLiteral(paramToken, finish)); + TernaryNode value = new TernaryNode(Token.recast(paramToken, TERNARY), test, new JoinPredecessorExpression(initializer), new JoinPredecessorExpression(ident)); + BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), ident, value); + lc.getFunctionBody(currentFunction).appendStatement(new ExpressionStatement(paramLine, assignment.getToken(), assignment.getFinish(), assignment)); + } currentFunction.addParameterBinding(ident); currentFunction.setSimpleParameterList(false); @@ -4855,10 +4870,14 @@ ParserContextFunctionNode currentFunction = lc.getCurrentFunction(); if (currentFunction != null) { - BinaryNode test = new BinaryNode(Token.recast(paramToken, EQ_STRICT), ident, newUndefinedLiteral(paramToken, finish)); - TernaryNode value = new TernaryNode(Token.recast(paramToken, TERNARY), test, new JoinPredecessorExpression(initializer), new JoinPredecessorExpression(ident)); - BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), param, value); - lc.getFunctionBody(currentFunction).appendStatement(new ExpressionStatement(paramLine, assignment.getToken(), assignment.getFinish(), assignment)); + if (env._parse_only) { + currentFunction.addParameterExpression(ident, param); + } else { + BinaryNode test = new BinaryNode(Token.recast(paramToken, EQ_STRICT), ident, newUndefinedLiteral(paramToken, finish)); + TernaryNode value = new TernaryNode(Token.recast(paramToken, TERNARY), test, new JoinPredecessorExpression(initializer), new JoinPredecessorExpression(ident)); + BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), param, value); + lc.getFunctionBody(currentFunction).appendStatement(new ExpressionStatement(paramLine, assignment.getToken(), assignment.getFinish(), assignment)); + } } return ident; } @@ -4872,8 +4891,12 @@ ParserContextFunctionNode currentFunction = lc.getCurrentFunction(); if (currentFunction != null) { - BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), param, ident); - lc.getFunctionBody(currentFunction).appendStatement(new ExpressionStatement(paramLine, assignment.getToken(), assignment.getFinish(), assignment)); + if (env._parse_only) { + currentFunction.addParameterExpression(ident, param); + } else { + BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), param, ident); + lc.getFunctionBody(currentFunction).appendStatement(new ExpressionStatement(paramLine, assignment.getToken(), assignment.getFinish(), assignment)); + } } return ident; } @@ -4982,20 +5005,37 @@ return literal; } - Expression concat = literal; - TokenType lastLiteralType; - do { - final Expression expression = expression(); - if (type != TEMPLATE_MIDDLE && type != TEMPLATE_TAIL) { - throw error(AbstractParser.message("unterminated.template.expression"), token); - } - concat = new BinaryNode(Token.recast(lastLiteralToken, TokenType.ADD), concat, expression); - lastLiteralType = type; - lastLiteralToken = token; - literal = getLiteral(); - concat = new BinaryNode(Token.recast(lastLiteralToken, TokenType.ADD), concat, literal); - } while (lastLiteralType == TEMPLATE_MIDDLE); - return concat; + if (env._parse_only) { + List exprs = new ArrayList<>(); + exprs.add(literal); + TokenType lastLiteralType; + do { + final Expression expression = expression(); + if (type != TEMPLATE_MIDDLE && type != TEMPLATE_TAIL) { + throw error(AbstractParser.message("unterminated.template.expression"), token); + } + exprs.add(expression); + lastLiteralType = type; + literal = getLiteral(); + exprs.add(literal); + } while (lastLiteralType == TEMPLATE_MIDDLE); + return new TemplateLiteral(exprs); + } else { + Expression concat = literal; + TokenType lastLiteralType; + do { + final Expression expression = expression(); + if (type != TEMPLATE_MIDDLE && type != TEMPLATE_TAIL) { + throw error(AbstractParser.message("unterminated.template.expression"), token); + } + concat = new BinaryNode(Token.recast(lastLiteralToken, TokenType.ADD), concat, expression); + lastLiteralType = type; + lastLiteralToken = token; + literal = getLiteral(); + concat = new BinaryNode(Token.recast(lastLiteralToken, TokenType.ADD), concat, literal); + } while (lastLiteralType == TEMPLATE_MIDDLE); + return concat; + } } /** diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/ParserContextFunctionNode.java --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/ParserContextFunctionNode.java Wed Jul 05 21:57:12 2017 +0200 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/ParserContextFunctionNode.java Wed Jul 05 21:58:29 2017 +0200 @@ -24,9 +24,12 @@ */ package jdk.nashorn.internal.parser; +import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Map; import jdk.nashorn.internal.codegen.Namespace; +import jdk.nashorn.internal.ir.Expression; import jdk.nashorn.internal.ir.FunctionNode; import jdk.nashorn.internal.ir.IdentNode; import jdk.nashorn.internal.ir.Module; @@ -70,6 +73,7 @@ private Module module; private int debugFlags; + private Map parameterExpressions; /** * @param token The token for the function @@ -170,6 +174,22 @@ } /** + * Return ES6 function parameter expressions + * + * @return ES6 function parameter expressions + */ + public Map getParameterExpressions() { + return parameterExpressions; + } + + void addParameterExpression(IdentNode ident, Expression node) { + if (parameterExpressions == null) { + parameterExpressions = new HashMap<>(); + } + parameterExpressions.put(ident, node); + } + + /** * Set last token * @param token New last token */ diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/test/script/basic/JDK-8075207.js --- a/nashorn/test/script/basic/JDK-8075207.js Wed Jul 05 21:57:12 2017 +0200 +++ b/nashorn/test/script/basic/JDK-8075207.js Wed Jul 05 21:58:29 2017 +0200 @@ -61,7 +61,7 @@ Assert.assertTrue(stats.get(2) instanceof VariableTree); var print_hello = stats.get(1); -Assert.assertEquals(print_hello.name, "print_hello"); +Assert.assertEquals(print_hello.name.name, "print_hello"); var print_hello_stats = print_hello.body.statements; Assert.assertTrue(print_hello_stats.get(0) instanceof VariableTree); Assert.assertTrue(print_hello_stats.get(1) instanceof ExpressionStatementTree); diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/test/script/basic/JDK-8075448.js --- a/nashorn/test/script/basic/JDK-8075448.js Wed Jul 05 21:57:12 2017 +0200 +++ b/nashorn/test/script/basic/JDK-8075448.js Wed Jul 05 21:58:29 2017 +0200 @@ -44,6 +44,6 @@ var stats = ast.sourceElements; Assert.assertTrue(stats[0] instanceof VariableTree); -Assert.assertEquals(stats[0].name, "i"); +Assert.assertEquals(stats[0].binding.name, "i"); Assert.assertTrue(stats[1] instanceof ForLoopTree); diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/test/script/basic/es6/let-const-switch.js.EXPECTED --- a/nashorn/test/script/basic/es6/let-const-switch.js.EXPECTED Wed Jul 05 21:57:12 2017 +0200 +++ b/nashorn/test/script/basic/es6/let-const-switch.js.EXPECTED Wed Jul 05 21:58:29 2017 +0200 @@ -1,12 +1,12 @@ -1 -2 -0 -1 -2 -0 -SyntaxError: test/script/basic/es6/let-const-switch.js#34:8:1:25 Unsupported let declaration in unprotected switch statement -switch (x) { case 0: let x = 1; } - ^ -SyntaxError: test/script/basic/es6/let-const-switch.js#34:8:1:27 Unsupported const declaration in unprotected switch statement -switch (x) { case 0: const x = 1; } - ^ +1 +2 +0 +1 +2 +0 +SyntaxError: test/script/basic/es6/let-const-switch.js#34:8:1:21 Unsupported let declaration in unprotected switch statement +switch (x) { case 0: let x = 1; } + ^ +SyntaxError: test/script/basic/es6/let-const-switch.js#34:8:1:21 Unsupported const declaration in unprotected switch statement +switch (x) { case 0: const x = 1; } + ^ diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/test/script/nosecurity/parserapi.js --- a/nashorn/test/script/nosecurity/parserapi.js Wed Jul 05 21:57:12 2017 +0200 +++ b/nashorn/test/script/nosecurity/parserapi.js Wed Jul 05 21:58:29 2017 +0200 @@ -62,6 +62,26 @@ var result = {}; for (var i in obj) { var val = obj[i]; + // skip these ES6 specific properties to reduce noise + // in the output - unless there were set to true + if (typeof(val) == 'boolean' && val == false) { + switch (i) { + case "computed": + case "static": + case "restParameter": + case "this": + case "super": + case "star": + case "default": + case "starDefaultStar": + case "arrow": + case "generator": + case "let": + case "const": + continue; + } + } + if (val instanceof Parser.Tree) { result[i] = this.convert(val); } else if (val instanceof Parser.List) { diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/test/script/nosecurity/parserapi.js.EXPECTED --- a/nashorn/test/script/nosecurity/parserapi.js.EXPECTED Wed Jul 05 21:57:12 2017 +0200 +++ b/nashorn/test/script/nosecurity/parserapi.js.EXPECTED Wed Jul 05 21:58:29 2017 +0200 @@ -1,4 +1,4 @@ -[ +[ { "endPosition": "1113", "kind": "COMPILATION_UNIT", @@ -6,8 +6,13 @@ { "endPosition": "1123", "kind": "VARIABLE", - "name": "x", - "startPosition": "1117", + "binding": { + "endPosition": "1118", + "kind": "IDENTIFIER", + "name": "x", + "startPosition": "1117" + }, + "startPosition": "1113", "initializer": { "endPosition": "1123", "kind": "ARRAY_LITERAL", @@ -18,8 +23,13 @@ { "endPosition": "1147", "kind": "VARIABLE", - "name": "y", - "startPosition": "1129", + "binding": { + "endPosition": "1130", + "kind": "IDENTIFIER", + "name": "y", + "startPosition": "1129" + }, + "startPosition": "1125", "initializer": { "endPosition": "1147", "kind": "ARRAY_LITERAL", @@ -55,8 +65,13 @@ { "endPosition": "1165", "kind": "VARIABLE", - "name": "z", - "startPosition": "1153", + "binding": { + "endPosition": "1154", + "kind": "IDENTIFIER", + "name": "z", + "startPosition": "1153" + }, + "startPosition": "1149", "initializer": { "endPosition": "1165", "kind": "ARRAY_LITERAL", @@ -82,8 +97,13 @@ { "endPosition": "1200", "kind": "VARIABLE", - "name": "k", - "startPosition": "1171", + "binding": { + "endPosition": "1172", + "kind": "IDENTIFIER", + "name": "k", + "startPosition": "1171" + }, + "startPosition": "1167", "initializer": { "endPosition": "1200", "kind": "ARRAY_LITERAL", @@ -132,8 +152,8 @@ "sourceName": "parsertests/array_literal.js", "strict": "false", "startPosition": "1113" -} -, +} +, { "endPosition": "1126", "kind": "COMPILATION_UNIT", @@ -406,8 +426,8 @@ "sourceName": "parsertests/assignmentExpr.js", "strict": "false", "startPosition": "1126" -} -, +} +, { "endPosition": "1116", "kind": "COMPILATION_UNIT", @@ -912,8 +932,8 @@ "sourceName": "parsertests/binaryExpr.js", "strict": "false", "startPosition": "1116" -} -, +} +, { "endPosition": "1117", "kind": "COMPILATION_UNIT", @@ -959,8 +979,8 @@ "sourceName": "parsertests/block.js", "strict": "false", "startPosition": "1117" -} -, +} +, { "endPosition": "1117", "kind": "COMPILATION_UNIT", @@ -1060,8 +1080,8 @@ "sourceName": "parsertests/breakStat.js", "strict": "false", "startPosition": "1117" -} -, +} +, { "endPosition": "1117", "kind": "COMPILATION_UNIT", @@ -1098,8 +1118,8 @@ "sourceName": "parsertests/condExpr.js", "strict": "false", "startPosition": "1117" -} -, +} +, { "endPosition": "1120", "kind": "COMPILATION_UNIT", @@ -1199,8 +1219,8 @@ "sourceName": "parsertests/continueStat.js", "strict": "false", "startPosition": "1120" -} -, +} +, { "endPosition": "1118", "kind": "COMPILATION_UNIT", @@ -1214,8 +1234,8 @@ "sourceName": "parsertests/debuggerStat.js", "strict": "false", "startPosition": "1118" -} -, +} +, { "endPosition": "1137", "kind": "COMPILATION_UNIT", @@ -1223,7 +1243,12 @@ { "endPosition": "1172", "kind": "FUNCTION", - "name": "hello", + "name": { + "endPosition": "1151", + "kind": "IDENTIFIER", + "name": "hello", + "startPosition": "1146" + }, "body": { "endPosition": "1170", "kind": "BLOCK", @@ -1262,7 +1287,12 @@ { "endPosition": "1203", "kind": "FUNCTION", - "name": "hello", + "name": { + "endPosition": "1187", + "kind": "IDENTIFIER", + "name": "hello", + "startPosition": "1182" + }, "body": { "endPosition": "1201", "kind": "BLOCK", @@ -1308,7 +1338,12 @@ { "endPosition": "1240", "kind": "FUNCTION", - "name": "hello", + "name": { + "endPosition": "1218", + "kind": "IDENTIFIER", + "name": "hello", + "startPosition": "1213" + }, "body": { "endPosition": "1238", "kind": "BLOCK", @@ -1366,8 +1401,13 @@ { "endPosition": "1282", "kind": "VARIABLE", - "name": "hello", - "startPosition": "1245", + "binding": { + "endPosition": "1250", + "kind": "IDENTIFIER", + "name": "hello", + "startPosition": "1245" + }, + "startPosition": "1241", "initializer": { "endPosition": "1264", "kind": "FUNCTION_EXPRESSION", @@ -1410,12 +1450,22 @@ { "endPosition": "1331", "kind": "VARIABLE", - "name": "hello", - "startPosition": "1288", + "binding": { + "endPosition": "1293", + "kind": "IDENTIFIER", + "name": "hello", + "startPosition": "1288" + }, + "startPosition": "1284", "initializer": { "endPosition": "1313", "kind": "FUNCTION_EXPRESSION", - "name": "hello", + "name": { + "endPosition": "1310", + "kind": "IDENTIFIER", + "name": "hello", + "startPosition": "1305" + }, "body": { "endPosition": "1329", "kind": "BLOCK", @@ -1473,7 +1523,12 @@ { "endPosition": "1380", "kind": "FUNCTION", - "name": "test", + "name": { + "endPosition": "1361", + "kind": "IDENTIFIER", + "name": "test", + "startPosition": "1357" + }, "body": { "endPosition": "1377", "kind": "BLOCK", @@ -1500,8 +1555,8 @@ "sourceName": "parsertests/functions.js", "strict": "false", "startPosition": "1137" -} -, +} +, { "endPosition": "1114", "kind": "COMPILATION_UNIT", @@ -1604,8 +1659,8 @@ "sourceName": "parsertests/ifStat.js", "strict": "false", "startPosition": "1114" -} -, +} +, { "endPosition": "1113", "kind": "COMPILATION_UNIT", @@ -1668,8 +1723,8 @@ "sourceName": "parsertests/labelledStat.js", "strict": "false", "startPosition": "1113" -} -, +} +, { "endPosition": "1125", "kind": "COMPILATION_UNIT", @@ -2066,8 +2121,8 @@ "sourceName": "parsertests/lhsExpr.js", "strict": "false", "startPosition": "1125" -} -, +} +, { "endPosition": "1110", "kind": "COMPILATION_UNIT", @@ -2350,8 +2405,8 @@ "sourceName": "parsertests/loopStat.js", "strict": "false", "startPosition": "1110" -} -, +} +, { "endPosition": "1125", "kind": "COMPILATION_UNIT", @@ -2608,6 +2663,7 @@ "expression": { "endPosition": "1272", "kind": "IDENTIFIER", + "this": "true", "name": "this", "startPosition": "1268" }, @@ -2650,6 +2706,7 @@ "expression": { "endPosition": "1300", "kind": "IDENTIFIER", + "this": "true", "name": "this", "startPosition": "1296" }, @@ -2705,8 +2762,8 @@ "sourceName": "parsertests/objectLitExpr.js", "strict": "false", "startPosition": "1125" -} -, +} +, { "endPosition": "1118", "kind": "COMPILATION_UNIT", @@ -2781,8 +2838,8 @@ "sourceName": "parsertests/parenExpr.js", "strict": "false", "startPosition": "1118" -} -, +} +, { "endPosition": "1119", "kind": "COMPILATION_UNIT", @@ -2791,6 +2848,7 @@ "expression": { "endPosition": "1123", "kind": "IDENTIFIER", + "this": "true", "name": "this", "startPosition": "1119" }, @@ -2995,8 +3053,8 @@ "sourceName": "parsertests/primaryExpr.js", "strict": "false", "startPosition": "1119" -} -, +} +, { "endPosition": "1114", "kind": "COMPILATION_UNIT", @@ -3004,8 +3062,13 @@ { "endPosition": "1127", "kind": "VARIABLE", - "name": "x", - "startPosition": "1118", + "binding": { + "endPosition": "1119", + "kind": "IDENTIFIER", + "name": "x", + "startPosition": "1118" + }, + "startPosition": "1114", "initializer": { "endPosition": "1127", "kind": "REGEXP_LITERAL", @@ -3017,8 +3080,13 @@ { "endPosition": "1143", "kind": "VARIABLE", - "name": "y", - "startPosition": "1133", + "binding": { + "endPosition": "1134", + "kind": "IDENTIFIER", + "name": "y", + "startPosition": "1133" + }, + "startPosition": "1129", "initializer": { "endPosition": "1143", "kind": "REGEXP_LITERAL", @@ -3030,8 +3098,13 @@ { "endPosition": "1168", "kind": "VARIABLE", - "name": "z", - "startPosition": "1149", + "binding": { + "endPosition": "1150", + "kind": "IDENTIFIER", + "name": "z", + "startPosition": "1149" + }, + "startPosition": "1145", "initializer": { "endPosition": "1168", "kind": "REGEXP_LITERAL", @@ -3044,8 +3117,8 @@ "sourceName": "parsertests/regexp_literal.js", "strict": "false", "startPosition": "1114" -} -, +} +, { "endPosition": "1118", "kind": "COMPILATION_UNIT", @@ -3144,8 +3217,8 @@ "sourceName": "parsertests/returnStat.js", "strict": "false", "startPosition": "1118" -} -, +} +, { "endPosition": "1111", "kind": "COMPILATION_UNIT", @@ -3309,8 +3382,8 @@ "sourceName": "parsertests/switchStat.js", "strict": "false", "startPosition": "1111" -} -, +} +, { "endPosition": "1110", "kind": "COMPILATION_UNIT", @@ -3421,8 +3494,8 @@ "sourceName": "parsertests/throwStat.js", "strict": "false", "startPosition": "1110" -} -, +} +, { "endPosition": "1121", "kind": "COMPILATION_UNIT", @@ -3783,8 +3856,8 @@ "sourceName": "parsertests/tryCatchStat.js", "strict": "false", "startPosition": "1121" -} -, +} +, { "endPosition": "1115", "kind": "COMPILATION_UNIT", @@ -3969,8 +4042,8 @@ "sourceName": "parsertests/unaryExpr.js", "strict": "false", "startPosition": "1115" -} -, +} +, { "endPosition": "1122", "kind": "COMPILATION_UNIT", @@ -3989,7 +4062,12 @@ { "endPosition": "1165", "kind": "FUNCTION", - "name": "f", + "name": { + "endPosition": "1146", + "kind": "IDENTIFIER", + "name": "f", + "startPosition": "1145" + }, "body": { "endPosition": "1162", "kind": "BLOCK", @@ -4016,8 +4094,8 @@ "sourceName": "parsertests/useStrict.js", "strict": "true", "startPosition": "1122" -} -, +} +, { "endPosition": "1143", "kind": "COMPILATION_UNIT", @@ -4025,26 +4103,46 @@ { "endPosition": "1148", "kind": "VARIABLE", - "name": "a", - "startPosition": "1147" + "binding": { + "endPosition": "1148", + "kind": "IDENTIFIER", + "name": "a", + "startPosition": "1147" + }, + "startPosition": "1143" }, { "endPosition": "1155", "kind": "VARIABLE", - "name": "a", - "startPosition": "1154" + "binding": { + "endPosition": "1155", + "kind": "IDENTIFIER", + "name": "a", + "startPosition": "1154" + }, + "startPosition": "1150" }, { "endPosition": "1158", "kind": "VARIABLE", - "name": "b", - "startPosition": "1157" + "binding": { + "endPosition": "1158", + "kind": "IDENTIFIER", + "name": "b", + "startPosition": "1157" + }, + "startPosition": "1150" }, { "endPosition": "1200", "kind": "VARIABLE", - "name": "a", - "startPosition": "1190", + "binding": { + "endPosition": "1191", + "kind": "IDENTIFIER", + "name": "a", + "startPosition": "1190" + }, + "startPosition": "1186", "initializer": { "endPosition": "1200", "kind": "STRING_LITERAL", @@ -4055,8 +4153,13 @@ { "endPosition": "1212", "kind": "VARIABLE", - "name": "a", - "startPosition": "1207", + "binding": { + "endPosition": "1208", + "kind": "IDENTIFIER", + "name": "a", + "startPosition": "1207" + }, + "startPosition": "1203", "initializer": { "endPosition": "1212", "kind": "NUMBER_LITERAL", @@ -4067,8 +4170,13 @@ { "endPosition": "1219", "kind": "VARIABLE", - "name": "b", - "startPosition": "1214", + "binding": { + "endPosition": "1215", + "kind": "IDENTIFIER", + "name": "b", + "startPosition": "1214" + }, + "startPosition": "1203", "initializer": { "endPosition": "1219", "kind": "NUMBER_LITERAL", @@ -4079,8 +4187,13 @@ { "endPosition": "1226", "kind": "VARIABLE", - "name": "c", - "startPosition": "1221", + "binding": { + "endPosition": "1222", + "kind": "IDENTIFIER", + "name": "c", + "startPosition": "1221" + }, + "startPosition": "1203", "initializer": { "endPosition": "1226", "kind": "NUMBER_LITERAL", @@ -4092,8 +4205,8 @@ "sourceName": "parsertests/varDecl.js", "strict": "false", "startPosition": "1143" -} -, +} +, { "endPosition": "1111", "kind": "COMPILATION_UNIT", @@ -4142,8 +4255,8 @@ "sourceName": "parsertests/withStat.js", "strict": "false", "startPosition": "1111" -} -, +} +, { "fileName": "parsernegativetests/caseoutofswitch.js", "code": "case (1090, 4)", @@ -4152,8 +4265,8 @@ "position": "1090", "message": "parsernegativetests/caseoutofswitch.js:29:0 Expected an operand but found case\ncase 23:\n^", "lineNumber": "29" -} -, +} +, { "fileName": "parsernegativetests/caseoutofswitch.js", "code": "default (1112, 7)", @@ -4162,8 +4275,8 @@ "position": "1112", "message": "parsernegativetests/caseoutofswitch.js:31:0 Expected an operand but found default\ndefault:\n^", "lineNumber": "31" -} -, +} +, { "endPosition": "1090", "kind": "COMPILATION_UNIT", @@ -4240,8 +4353,8 @@ "sourceName": "parsernegativetests/caseoutofswitch.js", "strict": "false", "startPosition": "1090" -} -, +} +, { "fileName": "parsernegativetests/illegalbreak.js", "code": "break (1090, 5)", @@ -4250,8 +4363,8 @@ "position": "1090", "message": "parsernegativetests/illegalbreak.js:29:0 Illegal break statement\nbreak;\n^", "lineNumber": "29" -} -, +} +, { "fileName": "parsernegativetests/illegalbreak.js", "code": "ident (1103, 3)", @@ -4260,8 +4373,8 @@ "position": "1103", "message": "parsernegativetests/illegalbreak.js:30:6 Undefined Label \"foo\"\nbreak foo;\n ^", "lineNumber": "30" -} -, +} +, { "endPosition": "1090", "kind": "COMPILATION_UNIT", @@ -4290,8 +4403,8 @@ "sourceName": "parsernegativetests/illegalbreak.js", "strict": "false", "startPosition": "1090" -} -, +} +, { "fileName": "parsernegativetests/illegalcontinue.js", "code": "continue (1090, 8)", @@ -4300,8 +4413,8 @@ "position": "1090", "message": "parsernegativetests/illegalcontinue.js:29:0 Illegal continue statement\ncontinue;\n^", "lineNumber": "29" -} -, +} +, { "fileName": "parsernegativetests/illegalcontinue.js", "code": "ident (1109, 3)", @@ -4310,8 +4423,8 @@ "position": "1109", "message": "parsernegativetests/illegalcontinue.js:30:9 Undefined Label \"foo\"\ncontinue foo;\n ^", "lineNumber": "30" -} -, +} +, { "endPosition": "1090", "kind": "COMPILATION_UNIT", @@ -4340,8 +4453,8 @@ "sourceName": "parsernegativetests/illegalcontinue.js", "strict": "false", "startPosition": "1090" -} -, +} +, { "fileName": "parsernegativetests/illegallvalue.js", "code": "decimal (1090, 2)", @@ -4350,8 +4463,8 @@ "position": "1090", "message": "parsernegativetests/illegallvalue.js:29:0 Invalid left hand side for assignment\n44 = 54;\n^", "lineNumber": "29" -} -, +} +, { "fileName": "parsernegativetests/illegallvalue.js", "code": "decimal (1099, 3)", @@ -4360,8 +4473,8 @@ "position": "1099", "message": "parsernegativetests/illegallvalue.js:30:0 Invalid left hand side for assignment\n233 += 33;\n^", "lineNumber": "30" -} -, +} +, { "fileName": "parsernegativetests/illegallvalue.js", "code": "decimal (1110, 4)", @@ -4370,8 +4483,8 @@ "position": "1110", "message": "parsernegativetests/illegallvalue.js:31:0 Invalid left hand side for assignment\n3423 -= 234;\n^", "lineNumber": "31" -} -, +} +, { "endPosition": "1090", "kind": "COMPILATION_UNIT", @@ -4410,8 +4523,8 @@ "sourceName": "parsernegativetests/illegallvalue.js", "strict": "false", "startPosition": "1090" -} -, +} +, { "fileName": "parsernegativetests/illegaloperator.js", "code": "* (1093, 1)", @@ -4420,8 +4533,8 @@ "position": "1093", "message": "parsernegativetests/illegaloperator.js:29:3 Expected an operand but found *\nx ** y\n ^", "lineNumber": "29" -} -, +} +, { "endPosition": "1090", "kind": "COMPILATION_UNIT", @@ -4440,8 +4553,8 @@ "sourceName": "parsernegativetests/illegaloperator.js", "strict": "false", "startPosition": "1090" -} -, +} +, { "fileName": "parsernegativetests/keywordident.js", "code": "var (1094, 3)", @@ -4450,8 +4563,8 @@ "position": "1094", "message": "parsernegativetests/keywordident.js:29:4 Expected ident but found var\nvar var = 23;\n ^", "lineNumber": "29" -} -, +} +, { "endPosition": "1090", "kind": "COMPILATION_UNIT", @@ -4469,8 +4582,13 @@ { "endPosition": "1115", "kind": "VARIABLE", - "name": "x", - "startPosition": "1108", + "binding": { + "endPosition": "1109", + "kind": "IDENTIFIER", + "name": "x", + "startPosition": "1108" + }, + "startPosition": "1104", "initializer": { "endPosition": "1115", "kind": "NUMBER_LITERAL", @@ -4482,8 +4600,8 @@ "sourceName": "parsernegativetests/keywordident.js", "strict": "false", "startPosition": "1090" -} -, +} +, { "fileName": "parsernegativetests/parenmissing.js", "code": "; (1096, 1)", @@ -4492,8 +4610,8 @@ "position": "1096", "message": "parsernegativetests/parenmissing.js:29:6 Expected ) but found ;\n(1 + 2;\n ^", "lineNumber": "29" -} -, +} +, { "fileName": "parsernegativetests/parenmissing.js", "code": ") (1103, 1)", @@ -4502,8 +4620,8 @@ "position": "1103", "message": "parsernegativetests/parenmissing.js:30:5 Expected ; but found )\nx * y);\n ^", "lineNumber": "30" -} -, +} +, { "endPosition": "1090", "kind": "COMPILATION_UNIT", @@ -4554,8 +4672,8 @@ "sourceName": "parsernegativetests/parenmissing.js", "strict": "false", "startPosition": "1090" -} -, +} +, { "fileName": "parsernegativetests/repeatedproperty.js", "code": "ident (1111, 3)", @@ -4564,8 +4682,8 @@ "position": "1111", "message": "parsernegativetests/repeatedproperty.js:29:21 Property \"foo\" already defined\nvar obj = { foo: 34, get foo() { return 'hello' } };\n ^", "lineNumber": "29" -} -, +} +, { "fileName": "parsernegativetests/repeatedproperty.js", "code": "ident (1165, 3)", @@ -4574,8 +4692,8 @@ "position": "1165", "message": "parsernegativetests/repeatedproperty.js:30:22 Property \"foo\" already defined\nvar obj1 = { foo: 34, set foo(x) { } };\n ^", "lineNumber": "30" -} -, +} +, { "fileName": "parsernegativetests/repeatedproperty.js", "code": "ident (1205, 3)", @@ -4584,8 +4702,8 @@ "position": "1205", "message": "parsernegativetests/repeatedproperty.js:31:22 Property \"foo\" already defined\nvar obj2 = { foo: 34, set foo(x) { } };\n ^", "lineNumber": "31" -} -, +} +, { "fileName": "parsernegativetests/repeatedproperty.js", "code": "ident (1251, 3)", @@ -4594,8 +4712,8 @@ "position": "1251", "message": "parsernegativetests/repeatedproperty.js:32:28 Property \"bar\" already defined\nvar obj3 = { get bar() { }, get bar() {} };\n ^", "lineNumber": "32" -} -, +} +, { "fileName": "parsernegativetests/repeatedproperty.js", "code": "ident (1296, 3)", @@ -4604,8 +4722,8 @@ "position": "1296", "message": "parsernegativetests/repeatedproperty.js:33:29 Property \"bar\" already defined\nvar obj4 = { set bar(x) { }, set bar(x) {} };\n ^", "lineNumber": "33" -} -, +} +, { "endPosition": "1090", "kind": "COMPILATION_UNIT", @@ -4664,8 +4782,8 @@ "sourceName": "parsernegativetests/repeatedproperty.js", "strict": "false", "startPosition": "1090" -} -, +} +, { "fileName": "parsernegativetests/strict_repeatedproperty.js", "code": "ident (1126, 3)", @@ -4674,8 +4792,8 @@ "position": "1126", "message": "parsernegativetests/strict_repeatedproperty.js:31:21 Property \"foo\" already defined\nvar obj = { foo: 34, foo: 'hello' };\n ^", "lineNumber": "31" -} -, +} +, { "endPosition": "1090", "kind": "COMPILATION_UNIT", @@ -4705,8 +4823,8 @@ "sourceName": "parsernegativetests/strict_repeatedproperty.js", "strict": "true", "startPosition": "1090" -} -, +} +, { "fileName": "parsernegativetests/strict_repeatparam.js", "code": "ident (1122, 1)", @@ -4715,8 +4833,8 @@ "position": "1122", "message": "parsernegativetests/strict_repeatparam.js:31:17 strict mode function cannot have duplicate parameter name \"x\"\nfunction func(x, x) {}\n ^", "lineNumber": "31" -} -, +} +, { "endPosition": "1090", "kind": "COMPILATION_UNIT", @@ -4746,8 +4864,8 @@ "sourceName": "parsernegativetests/strict_repeatparam.js", "strict": "true", "startPosition": "1090" -} -, +} +, { "fileName": "parsernegativetests/strict_with.js", "code": "with (1105, 4)", @@ -4756,8 +4874,8 @@ "position": "1105", "message": "parsernegativetests/strict_with.js:31:0 \"with\" statement cannot be used in strict mode\nwith({}) {}\n^", "lineNumber": "31" -} -, +} +, { "fileName": "parsernegativetests/strict_with.js", "code": ") (1112, 1)", @@ -4766,8 +4884,8 @@ "position": "1112", "message": "parsernegativetests/strict_with.js:31:7 Expected ; but found )\nwith({}) {}\n ^", "lineNumber": "31" -} -, +} +, { "endPosition": "1090", "kind": "COMPILATION_UNIT", @@ -4807,8 +4925,8 @@ "sourceName": "parsernegativetests/strict_with.js", "strict": "true", "startPosition": "1090" -} -, +} +, { "fileName": "parsernegativetests/toplevelreturn.js", "code": "return (1090, 6)", @@ -4817,8 +4935,8 @@ "position": "1090", "message": "parsernegativetests/toplevelreturn.js:29:0 Invalid return statement\nreturn;\n^", "lineNumber": "29" -} -, +} +, { "fileName": "parsernegativetests/toplevelreturn.js", "code": "return (1098, 6)", @@ -4827,8 +4945,8 @@ "position": "1098", "message": "parsernegativetests/toplevelreturn.js:30:0 Invalid return statement\nreturn 23;\n^", "lineNumber": "30" -} -, +} +, { "endPosition": "1090", "kind": "COMPILATION_UNIT", @@ -4857,8 +4975,8 @@ "sourceName": "parsernegativetests/toplevelreturn.js", "strict": "false", "startPosition": "1090" -} -, +} +, { "endPosition": "1136", "kind": "COMPILATION_UNIT", @@ -4866,7 +4984,12 @@ { "endPosition": "1222", "kind": "FUNCTION", - "name": "Parser", + "name": { + "endPosition": "1151", + "kind": "IDENTIFIER", + "name": "Parser", + "startPosition": "1145" + }, "body": { "endPosition": "1220", "kind": "BLOCK", @@ -4898,6 +5021,7 @@ "expression": { "endPosition": "1193", "kind": "IDENTIFIER", + "this": "true", "name": "this", "startPosition": "1189" }, @@ -5165,8 +5289,13 @@ { "endPosition": "1718", "kind": "VARIABLE", - "name": "tree", - "startPosition": "1669", + "binding": { + "endPosition": "1673", + "kind": "IDENTIFIER", + "name": "tree", + "startPosition": "1669" + }, + "startPosition": "1665", "initializer": { "endPosition": "1718", "kind": "FUNCTION_INVOCATION", @@ -5177,6 +5306,7 @@ "expression": { "endPosition": "1680", "kind": "IDENTIFIER", + "this": "true", "name": "this", "startPosition": "1676" }, @@ -5272,6 +5402,7 @@ "expression": { "endPosition": "1790", "kind": "IDENTIFIER", + "this": "true", "name": "this", "startPosition": "1786" }, @@ -5429,7 +5560,7 @@ "endPosition": "2016", "kind": "FUNCTION_EXPRESSION", "body": { - "endPosition": "2994", + "endPosition": "3634", "kind": "BLOCK", "statements": [ { @@ -5554,8 +5685,13 @@ { "endPosition": "2169", "kind": "VARIABLE", - "name": "obj", - "startPosition": "2132", + "binding": { + "endPosition": "2135", + "kind": "IDENTIFIER", + "name": "obj", + "startPosition": "2132" + }, + "startPosition": "2128", "initializer": { "endPosition": "2169", "kind": "FUNCTION_INVOCATION", @@ -5591,8 +5727,13 @@ { "endPosition": "2190", "kind": "VARIABLE", - "name": "result", - "startPosition": "2179", + "binding": { + "endPosition": "2185", + "kind": "IDENTIFIER", + "name": "result", + "startPosition": "2179" + }, + "startPosition": "2175", "initializer": { "endPosition": "2190", "kind": "OBJECT_LITERAL", @@ -5603,8 +5744,13 @@ { "endPosition": "2206", "kind": "VARIABLE", - "name": "i", - "startPosition": "2205" + "binding": { + "endPosition": "2206", + "kind": "IDENTIFIER", + "name": "i", + "startPosition": "2205" + }, + "startPosition": "2201" }, { "expression": { @@ -5613,7 +5759,7 @@ "name": "obj", "startPosition": "2210" }, - "endPosition": "2975", + "endPosition": "3615", "kind": "FOR_IN_LOOP", "forEach": "false", "variable": { @@ -5623,14 +5769,19 @@ "startPosition": "2205" }, "statement": { - "endPosition": "2975", + "endPosition": "3615", "kind": "BLOCK", "statements": [ { "endPosition": "2241", "kind": "VARIABLE", - "name": "val", - "startPosition": "2229", + "binding": { + "endPosition": "2232", + "kind": "IDENTIFIER", + "name": "val", + "startPosition": "2229" + }, + "startPosition": "2225", "initializer": { "expression": { "endPosition": "2238", @@ -5652,605 +5803,836 @@ { "condition": { "leftOperand": { - "endPosition": "2258", + "leftOperand": { + "expression": { + "endPosition": "2384", + "kind": "IDENTIFIER", + "name": "val", + "startPosition": "2381" + }, + "endPosition": "2384", + "kind": "TYPEOF", + "startPosition": "2374" + }, + "endPosition": "2397", + "kind": "EQUAL_TO", + "rightOperand": { + "endPosition": "2397", + "kind": "STRING_LITERAL", + "value": "boolean", + "startPosition": "2390" + }, + "startPosition": "2374" + }, + "endPosition": "2414", + "kind": "CONDITIONAL_AND", + "rightOperand": { + "leftOperand": { + "endPosition": "2405", + "kind": "IDENTIFIER", + "name": "val", + "startPosition": "2402" + }, + "endPosition": "2414", + "kind": "EQUAL_TO", + "rightOperand": { + "endPosition": "2414", + "kind": "BOOLEAN_LITERAL", + "value": "false", + "startPosition": "2409" + }, + "startPosition": "2402" + }, + "startPosition": "2374" + }, + "endPosition": "2881", + "kind": "IF", + "startPosition": "2370", + "thenStatement": { + "endPosition": "2881", + "kind": "BLOCK", + "statements": [ + { + "cases": [ + { + "expression": { + "endPosition": "2473", + "kind": "STRING_LITERAL", + "value": "computed", + "startPosition": "2465" + }, + "endPosition": "2475", + "kind": "CASE", + "statements": [], + "startPosition": "2459" + }, + { + "expression": { + "endPosition": "2504", + "kind": "STRING_LITERAL", + "value": "static", + "startPosition": "2498" + }, + "endPosition": "2506", + "kind": "CASE", + "statements": [], + "startPosition": "2492" + }, + { + "expression": { + "endPosition": "2542", + "kind": "STRING_LITERAL", + "value": "restParameter", + "startPosition": "2529" + }, + "endPosition": "2544", + "kind": "CASE", + "statements": [], + "startPosition": "2523" + }, + { + "expression": { + "endPosition": "2571", + "kind": "STRING_LITERAL", + "value": "this", + "startPosition": "2567" + }, + "endPosition": "2573", + "kind": "CASE", + "statements": [], + "startPosition": "2561" + }, + { + "expression": { + "endPosition": "2601", + "kind": "STRING_LITERAL", + "value": "super", + "startPosition": "2596" + }, + "endPosition": "2603", + "kind": "CASE", + "statements": [], + "startPosition": "2590" + }, + { + "expression": { + "endPosition": "2630", + "kind": "STRING_LITERAL", + "value": "star", + "startPosition": "2626" + }, + "endPosition": "2632", + "kind": "CASE", + "statements": [], + "startPosition": "2620" + }, + { + "expression": { + "endPosition": "2662", + "kind": "STRING_LITERAL", + "value": "default", + "startPosition": "2655" + }, + "endPosition": "2664", + "kind": "CASE", + "statements": [], + "startPosition": "2649" + }, + { + "expression": { + "endPosition": "2702", + "kind": "STRING_LITERAL", + "value": "starDefaultStar", + "startPosition": "2687" + }, + "endPosition": "2704", + "kind": "CASE", + "statements": [], + "startPosition": "2681" + }, + { + "expression": { + "endPosition": "2732", + "kind": "STRING_LITERAL", + "value": "arrow", + "startPosition": "2727" + }, + "endPosition": "2734", + "kind": "CASE", + "statements": [], + "startPosition": "2721" + }, + { + "expression": { + "endPosition": "2766", + "kind": "STRING_LITERAL", + "value": "generator", + "startPosition": "2757" + }, + "endPosition": "2768", + "kind": "CASE", + "statements": [], + "startPosition": "2751" + }, + { + "expression": { + "endPosition": "2794", + "kind": "STRING_LITERAL", + "value": "let", + "startPosition": "2791" + }, + "endPosition": "2796", + "kind": "CASE", + "statements": [], + "startPosition": "2785" + }, + { + "expression": { + "endPosition": "2824", + "kind": "STRING_LITERAL", + "value": "const", + "startPosition": "2819" + }, + "endPosition": "2856", + "kind": "CASE", + "statements": [ + { + "endPosition": "2856", + "kind": "CONTINUE", + "startPosition": "2847" + } + ], + "startPosition": "2813" + } + ], + "expression": { + "endPosition": "2439", + "kind": "IDENTIFIER", + "name": "i", + "startPosition": "2438" + }, + "endPosition": "2871", + "kind": "SWITCH", + "startPosition": "2430" + } + ], + "startPosition": "2416" + } + }, + { + "condition": { + "leftOperand": { + "endPosition": "2898", "kind": "IDENTIFIER", "name": "val", - "startPosition": "2255" + "startPosition": "2895" }, "expression": { - "endPosition": "2258", + "endPosition": "2898", "kind": "IDENTIFIER", "name": "val", - "startPosition": "2255" + "startPosition": "2895" }, - "endPosition": "2281", + "endPosition": "2921", "kind": "INSTANCE_OF", "rightOperand": { "identifier": "Tree", "expression": { - "endPosition": "2276", + "endPosition": "2916", "kind": "IDENTIFIER", "name": "Parser", - "startPosition": "2270" + "startPosition": "2910" }, - "endPosition": "2281", + "endPosition": "2921", "kind": "MEMBER_SELECT", - "startPosition": "2270" + "startPosition": "2910" }, "type": { "identifier": "Tree", "expression": { - "endPosition": "2276", + "endPosition": "2916", "kind": "IDENTIFIER", "name": "Parser", - "startPosition": "2270" + "startPosition": "2910" }, - "endPosition": "2281", + "endPosition": "2921", "kind": "MEMBER_SELECT", - "startPosition": "2270" + "startPosition": "2910" }, - "startPosition": "2255" + "startPosition": "2895" }, "elseStatement": { "condition": { "leftOperand": { - "endPosition": "2350", + "endPosition": "2990", "kind": "IDENTIFIER", "name": "val", - "startPosition": "2347" + "startPosition": "2987" }, "expression": { - "endPosition": "2350", + "endPosition": "2990", "kind": "IDENTIFIER", "name": "val", - "startPosition": "2347" + "startPosition": "2987" }, - "endPosition": "2373", + "endPosition": "3013", "kind": "INSTANCE_OF", "rightOperand": { "identifier": "List", "expression": { - "endPosition": "2368", + "endPosition": "3008", "kind": "IDENTIFIER", "name": "Parser", - "startPosition": "2362" + "startPosition": "3002" }, - "endPosition": "2373", + "endPosition": "3013", "kind": "MEMBER_SELECT", - "startPosition": "2362" + "startPosition": "3002" }, "type": { "identifier": "List", "expression": { - "endPosition": "2368", + "endPosition": "3008", "kind": "IDENTIFIER", "name": "Parser", - "startPosition": "2362" + "startPosition": "3002" }, - "endPosition": "2373", + "endPosition": "3013", "kind": "MEMBER_SELECT", - "startPosition": "2362" + "startPosition": "3002" }, - "startPosition": "2347" + "startPosition": "2987" }, "elseStatement": { - "endPosition": "2969", + "endPosition": "3609", "kind": "BLOCK", "statements": [ { "cases": [ { "expression": { - "endPosition": "2625", + "endPosition": "3265", "kind": "STRING_LITERAL", "value": "number", - "startPosition": "2619" + "startPosition": "3259" }, - "endPosition": "2627", + "endPosition": "3267", "kind": "CASE", "statements": [], - "startPosition": "2613" + "startPosition": "3253" }, { "expression": { - "endPosition": "2656", + "endPosition": "3296", "kind": "STRING_LITERAL", "value": "string", - "startPosition": "2650" + "startPosition": "3290" }, - "endPosition": "2658", + "endPosition": "3298", "kind": "CASE", "statements": [], - "startPosition": "2644" + "startPosition": "3284" }, { "expression": { - "endPosition": "2688", + "endPosition": "3328", "kind": "STRING_LITERAL", "value": "boolean", - "startPosition": "2681" + "startPosition": "3321" }, - "endPosition": "2762", + "endPosition": "3402", "kind": "CASE", "statements": [ { "expression": { "expression": { - "endPosition": "2734", + "endPosition": "3374", "kind": "FUNCTION_INVOCATION", "functionSelect": { - "endPosition": "2729", + "endPosition": "3369", "kind": "IDENTIFIER", "name": "String", - "startPosition": "2723" + "startPosition": "3363" }, "arguments": [ { - "endPosition": "2733", + "endPosition": "3373", "kind": "IDENTIFIER", "name": "val", - "startPosition": "2730" + "startPosition": "3370" } ], - "startPosition": "2723" + "startPosition": "3363" }, - "endPosition": "2734", + "endPosition": "3374", "kind": "ASSIGNMENT", "variable": { "expression": { - "endPosition": "2717", + "endPosition": "3357", "kind": "IDENTIFIER", "name": "result", - "startPosition": "2711" + "startPosition": "3351" }, - "endPosition": "2720", + "endPosition": "3360", "kind": "ARRAY_ACCESS", "index": { - "endPosition": "2719", + "endPosition": "3359", "kind": "IDENTIFIER", "name": "i", - "startPosition": "2718" + "startPosition": "3358" }, - "startPosition": "2711" + "startPosition": "3351" }, - "startPosition": "2711" + "startPosition": "3351" }, - "endPosition": "2734", + "endPosition": "3374", "kind": "EXPRESSION_STATEMENT", - "startPosition": "2711" + "startPosition": "3351" }, { - "endPosition": "2762", + "endPosition": "3402", "kind": "BREAK", - "startPosition": "2756" + "startPosition": "3396" } ], - "startPosition": "2675" + "startPosition": "3315" }, { - "endPosition": "2945", + "endPosition": "3585", "kind": "CASE", "statements": [ { "condition": { "leftOperand": { "leftOperand": { - "endPosition": "2815", + "endPosition": "3455", "kind": "IDENTIFIER", "name": "val", - "startPosition": "2812" + "startPosition": "3452" }, "expression": { - "endPosition": "2815", + "endPosition": "3455", "kind": "IDENTIFIER", "name": "val", - "startPosition": "2812" + "startPosition": "3452" }, - "endPosition": "2841", + "endPosition": "3481", "kind": "INSTANCE_OF", "rightOperand": { "identifier": "Long", "expression": { "identifier": "lang", "expression": { - "endPosition": "2831", + "endPosition": "3471", "kind": "IDENTIFIER", "name": "java", - "startPosition": "2827" + "startPosition": "3467" }, - "endPosition": "2836", + "endPosition": "3476", "kind": "MEMBER_SELECT", - "startPosition": "2827" + "startPosition": "3467" }, - "endPosition": "2841", + "endPosition": "3481", "kind": "MEMBER_SELECT", - "startPosition": "2827" + "startPosition": "3467" }, "type": { "identifier": "Long", "expression": { "identifier": "lang", "expression": { - "endPosition": "2831", + "endPosition": "3471", "kind": "IDENTIFIER", "name": "java", - "startPosition": "2827" + "startPosition": "3467" }, - "endPosition": "2836", + "endPosition": "3476", "kind": "MEMBER_SELECT", - "startPosition": "2827" + "startPosition": "3467" }, - "endPosition": "2841", + "endPosition": "3481", "kind": "MEMBER_SELECT", - "startPosition": "2827" + "startPosition": "3467" }, - "startPosition": "2812" + "startPosition": "3452" }, - "endPosition": "2871", + "endPosition": "3511", "kind": "CONDITIONAL_OR", "rightOperand": { "leftOperand": { - "endPosition": "2848", + "endPosition": "3488", "kind": "IDENTIFIER", "name": "val", - "startPosition": "2845" + "startPosition": "3485" }, "expression": { - "endPosition": "2848", + "endPosition": "3488", "kind": "IDENTIFIER", "name": "val", - "startPosition": "2845" + "startPosition": "3485" }, - "endPosition": "2871", + "endPosition": "3511", "kind": "INSTANCE_OF", "rightOperand": { "identifier": "Enum", "expression": { - "endPosition": "2866", + "endPosition": "3506", "kind": "IDENTIFIER", "name": "Parser", - "startPosition": "2860" + "startPosition": "3500" }, - "endPosition": "2871", + "endPosition": "3511", "kind": "MEMBER_SELECT", - "startPosition": "2860" + "startPosition": "3500" }, "type": { "identifier": "Enum", "expression": { - "endPosition": "2866", + "endPosition": "3506", "kind": "IDENTIFIER", "name": "Parser", - "startPosition": "2860" + "startPosition": "3500" }, - "endPosition": "2871", + "endPosition": "3511", "kind": "MEMBER_SELECT", - "startPosition": "2860" + "startPosition": "3500" }, - "startPosition": "2845" + "startPosition": "3485" }, - "startPosition": "2812" + "startPosition": "3452" }, - "endPosition": "2945", + "endPosition": "3585", "kind": "IF", - "startPosition": "2808", + "startPosition": "3448", "thenStatement": { - "endPosition": "2945", + "endPosition": "3585", "kind": "BLOCK", "statements": [ { "expression": { "expression": { - "endPosition": "2922", + "endPosition": "3562", "kind": "FUNCTION_INVOCATION", "functionSelect": { - "endPosition": "2917", + "endPosition": "3557", "kind": "IDENTIFIER", "name": "String", - "startPosition": "2911" + "startPosition": "3551" }, "arguments": [ { - "endPosition": "2921", + "endPosition": "3561", "kind": "IDENTIFIER", "name": "val", - "startPosition": "2918" + "startPosition": "3558" } ], - "startPosition": "2911" + "startPosition": "3551" }, - "endPosition": "2922", + "endPosition": "3562", "kind": "ASSIGNMENT", "variable": { "expression": { - "endPosition": "2905", + "endPosition": "3545", "kind": "IDENTIFIER", "name": "result", - "startPosition": "2899" + "startPosition": "3539" }, - "endPosition": "2908", + "endPosition": "3548", "kind": "ARRAY_ACCESS", "index": { - "endPosition": "2907", + "endPosition": "3547", "kind": "IDENTIFIER", "name": "i", - "startPosition": "2906" + "startPosition": "3546" }, - "startPosition": "2899" + "startPosition": "3539" }, - "startPosition": "2899" + "startPosition": "3539" }, - "endPosition": "2922", + "endPosition": "3562", "kind": "EXPRESSION_STATEMENT", - "startPosition": "2899" + "startPosition": "3539" } ], - "startPosition": "2873" + "startPosition": "3513" } } ], - "startPosition": "2779" + "startPosition": "3419" } ], "expression": { "expression": { - "endPosition": "2593", + "endPosition": "3233", "kind": "IDENTIFIER", "name": "val", - "startPosition": "2590" + "startPosition": "3230" }, - "endPosition": "2593", + "endPosition": "3233", "kind": "TYPEOF", - "startPosition": "2583" + "startPosition": "3223" }, - "endPosition": "2959", + "endPosition": "3599", "kind": "SWITCH", - "startPosition": "2575" + "startPosition": "3215" } ], - "startPosition": "2561" + "startPosition": "3201" }, - "endPosition": "2969", + "endPosition": "3609", "kind": "IF", - "startPosition": "2343", + "startPosition": "2983", "thenStatement": { - "endPosition": "2555", + "endPosition": "3195", "kind": "BLOCK", "statements": [ { - "endPosition": "2420", + "endPosition": "3060", "kind": "VARIABLE", - "name": "arr", - "startPosition": "2393", + "binding": { + "endPosition": "3036", + "kind": "IDENTIFIER", + "name": "arr", + "startPosition": "3033" + }, + "startPosition": "3029", "initializer": { "constructorExpression": { - "endPosition": "2420", + "endPosition": "3060", "kind": "FUNCTION_INVOCATION", "functionSelect": { - "endPosition": "2408", + "endPosition": "3048", "kind": "IDENTIFIER", "name": "Array", - "startPosition": "2403" + "startPosition": "3043" }, "arguments": [ { - "endPosition": "2419", + "endPosition": "3059", "kind": "FUNCTION_INVOCATION", "functionSelect": { "identifier": "size", "expression": { - "endPosition": "2412", + "endPosition": "3052", "kind": "IDENTIFIER", "name": "val", - "startPosition": "2409" + "startPosition": "3049" }, - "endPosition": "2417", + "endPosition": "3057", "kind": "MEMBER_SELECT", - "startPosition": "2409" + "startPosition": "3049" }, "arguments": [], - "startPosition": "2409" + "startPosition": "3049" } ], - "startPosition": "2403" + "startPosition": "3043" }, - "endPosition": "2420", + "endPosition": "3060", "kind": "NEW", - "startPosition": "2399" + "startPosition": "3039" } }, { - "endPosition": "2444", + "endPosition": "3084", "kind": "VARIABLE", - "name": "j", - "startPosition": "2443" + "binding": { + "endPosition": "3084", + "kind": "IDENTIFIER", + "name": "j", + "startPosition": "3083" + }, + "startPosition": "3079" }, { "expression": { - "endPosition": "2451", + "endPosition": "3091", "kind": "IDENTIFIER", "name": "val", - "startPosition": "2448" + "startPosition": "3088" }, - "endPosition": "2515", + "endPosition": "3155", "kind": "FOR_IN_LOOP", "forEach": "false", "variable": { - "endPosition": "2444", + "endPosition": "3084", "kind": "IDENTIFIER", "name": "j", - "startPosition": "2443" + "startPosition": "3083" }, "statement": { - "endPosition": "2515", + "endPosition": "3155", "kind": "BLOCK", "statements": [ { "expression": { "expression": { - "endPosition": "2500", + "endPosition": "3140", "kind": "FUNCTION_INVOCATION", "functionSelect": { "identifier": "convert", "expression": { - "endPosition": "2484", + "endPosition": "3124", "kind": "IDENTIFIER", + "this": "true", "name": "this", - "startPosition": "2480" + "startPosition": "3120" }, - "endPosition": "2492", + "endPosition": "3132", "kind": "MEMBER_SELECT", - "startPosition": "2480" + "startPosition": "3120" }, "arguments": [ { "expression": { - "endPosition": "2496", + "endPosition": "3136", "kind": "IDENTIFIER", "name": "val", - "startPosition": "2493" + "startPosition": "3133" }, - "endPosition": "2499", + "endPosition": "3139", "kind": "ARRAY_ACCESS", "index": { - "endPosition": "2498", + "endPosition": "3138", "kind": "IDENTIFIER", "name": "j", - "startPosition": "2497" + "startPosition": "3137" }, - "startPosition": "2493" + "startPosition": "3133" } ], - "startPosition": "2480" + "startPosition": "3120" }, - "endPosition": "2500", + "endPosition": "3140", "kind": "ASSIGNMENT", "variable": { "expression": { - "endPosition": "2474", + "endPosition": "3114", "kind": "IDENTIFIER", "name": "arr", - "startPosition": "2471" + "startPosition": "3111" }, - "endPosition": "2477", + "endPosition": "3117", "kind": "ARRAY_ACCESS", "index": { - "endPosition": "2476", + "endPosition": "3116", "kind": "IDENTIFIER", "name": "j", - "startPosition": "2475" + "startPosition": "3115" }, - "startPosition": "2471" + "startPosition": "3111" }, - "startPosition": "2471" + "startPosition": "3111" }, - "endPosition": "2500", + "endPosition": "3140", "kind": "EXPRESSION_STATEMENT", - "startPosition": "2471" + "startPosition": "3111" } ], - "startPosition": "2453" + "startPosition": "3093" }, - "startPosition": "2434" + "startPosition": "3074" }, { "expression": { "expression": { - "endPosition": "2544", + "endPosition": "3184", "kind": "IDENTIFIER", "name": "arr", - "startPosition": "2541" + "startPosition": "3181" }, - "endPosition": "2544", + "endPosition": "3184", "kind": "ASSIGNMENT", "variable": { "expression": { - "endPosition": "2535", + "endPosition": "3175", "kind": "IDENTIFIER", "name": "result", - "startPosition": "2529" + "startPosition": "3169" }, - "endPosition": "2538", + "endPosition": "3178", "kind": "ARRAY_ACCESS", "index": { - "endPosition": "2537", + "endPosition": "3177", "kind": "IDENTIFIER", "name": "i", - "startPosition": "2536" + "startPosition": "3176" }, - "startPosition": "2529" + "startPosition": "3169" }, - "startPosition": "2529" + "startPosition": "3169" }, - "endPosition": "2544", + "endPosition": "3184", "kind": "EXPRESSION_STATEMENT", - "startPosition": "2529" + "startPosition": "3169" } ], - "startPosition": "2375" + "startPosition": "3015" } }, - "endPosition": "2969", + "endPosition": "3609", "kind": "IF", - "startPosition": "2251", + "startPosition": "2891", "thenStatement": { - "endPosition": "2337", + "endPosition": "2977", "kind": "BLOCK", "statements": [ { "expression": { "expression": { - "endPosition": "2326", + "endPosition": "2966", "kind": "FUNCTION_INVOCATION", "functionSelect": { "identifier": "convert", "expression": { - "endPosition": "2313", + "endPosition": "2953", "kind": "IDENTIFIER", + "this": "true", "name": "this", - "startPosition": "2309" + "startPosition": "2949" }, - "endPosition": "2321", + "endPosition": "2961", "kind": "MEMBER_SELECT", - "startPosition": "2309" + "startPosition": "2949" }, "arguments": [ { - "endPosition": "2325", + "endPosition": "2965", "kind": "IDENTIFIER", "name": "val", - "startPosition": "2322" + "startPosition": "2962" } ], - "startPosition": "2309" + "startPosition": "2949" }, - "endPosition": "2326", + "endPosition": "2966", "kind": "ASSIGNMENT", "variable": { "expression": { - "endPosition": "2303", + "endPosition": "2943", "kind": "IDENTIFIER", "name": "result", - "startPosition": "2297" + "startPosition": "2937" }, - "endPosition": "2306", + "endPosition": "2946", "kind": "ARRAY_ACCESS", "index": { - "endPosition": "2305", + "endPosition": "2945", "kind": "IDENTIFIER", "name": "i", - "startPosition": "2304" + "startPosition": "2944" }, - "startPosition": "2297" + "startPosition": "2937" }, - "startPosition": "2297" + "startPosition": "2937" }, - "endPosition": "2326", + "endPosition": "2966", "kind": "EXPRESSION_STATEMENT", - "startPosition": "2297" + "startPosition": "2937" } ], - "startPosition": "2283" + "startPosition": "2923" } } ], @@ -6260,14 +6642,14 @@ }, { "expression": { - "endPosition": "2993", + "endPosition": "3633", "kind": "IDENTIFIER", "name": "result", - "startPosition": "2987" + "startPosition": "3627" }, - "endPosition": "2994", + "endPosition": "3634", "kind": "RETURN", - "startPosition": "2980" + "startPosition": "3620" } ], "startPosition": "2016" @@ -6305,105 +6687,120 @@ }, "startPosition": "1974" }, - "endPosition": "2996", + "endPosition": "3636", "kind": "EXPRESSION_STATEMENT", "startPosition": "1974" }, { - "endPosition": "3726", + "endPosition": "4366", "kind": "FUNCTION", - "name": "processFiles", + "name": { + "endPosition": "3659", + "kind": "IDENTIFIER", + "name": "processFiles", + "startPosition": "3647" + }, "body": { - "endPosition": "3724", + "endPosition": "4364", "kind": "BLOCK", "statements": [ { - "endPosition": "3070", + "endPosition": "3710", "kind": "VARIABLE", - "name": "File", - "startPosition": "3038", + "binding": { + "endPosition": "3682", + "kind": "IDENTIFIER", + "name": "File", + "startPosition": "3678" + }, + "startPosition": "3674", "initializer": { - "endPosition": "3070", + "endPosition": "3710", "kind": "FUNCTION_INVOCATION", "functionSelect": { "identifier": "type", "expression": { - "endPosition": "3049", + "endPosition": "3689", "kind": "IDENTIFIER", "name": "Java", - "startPosition": "3045" + "startPosition": "3685" }, - "endPosition": "3054", + "endPosition": "3694", "kind": "MEMBER_SELECT", - "startPosition": "3045" + "startPosition": "3685" }, "arguments": [ { - "endPosition": "3068", + "endPosition": "3708", "kind": "STRING_LITERAL", "value": "java.io.File", - "startPosition": "3056" + "startPosition": "3696" } ], - "startPosition": "3045" + "startPosition": "3685" } }, { - "endPosition": "3126", + "endPosition": "3766", "kind": "VARIABLE", - "name": "files", - "startPosition": "3080", + "binding": { + "endPosition": "3725", + "kind": "IDENTIFIER", + "name": "files", + "startPosition": "3720" + }, + "startPosition": "3716", "initializer": { - "endPosition": "3126", + "endPosition": "3766", "kind": "FUNCTION_INVOCATION", "functionSelect": { "identifier": "listFiles", "expression": { "constructorExpression": { - "endPosition": "3114", + "endPosition": "3754", "kind": "FUNCTION_INVOCATION", "functionSelect": { - "endPosition": "3096", + "endPosition": "3736", "kind": "IDENTIFIER", "name": "File", - "startPosition": "3092" + "startPosition": "3732" }, "arguments": [ { "leftOperand": { - "endPosition": "3104", + "endPosition": "3744", "kind": "IDENTIFIER", "name": "__DIR__", - "startPosition": "3097" + "startPosition": "3737" }, - "endPosition": "3113", + "endPosition": "3753", "kind": "PLUS", "rightOperand": { - "endPosition": "3113", + "endPosition": "3753", "kind": "IDENTIFIER", "name": "subdir", - "startPosition": "3107" + "startPosition": "3747" }, - "startPosition": "3097" + "startPosition": "3737" } ], - "startPosition": "3092" + "startPosition": "3732" }, - "endPosition": "3114", + "endPosition": "3754", "kind": "NEW", - "startPosition": "3088" + "startPosition": "3728" }, - "endPosition": "3124", + "endPosition": "3764", "kind": "MEMBER_SELECT", - "startPosition": "3088" + "startPosition": "3728" }, "arguments": [], - "startPosition": "3088" + "startPosition": "3728" } }, { "expression": { - "endPosition": "3160", + "endPosition": "3800", "kind": "FUNCTION_INVOCATION", "functionSelect": { "identifier": "sort", @@ -6412,751 +6809,786 @@ "expression": { "identifier": "util", "expression": { - "endPosition": "3136", + "endPosition": "3776", "kind": "IDENTIFIER", "name": "java", - "startPosition": "3132" + "startPosition": "3772" }, - "endPosition": "3141", + "endPosition": "3781", "kind": "MEMBER_SELECT", - "startPosition": "3132" + "startPosition": "3772" }, - "endPosition": "3148", + "endPosition": "3788", "kind": "MEMBER_SELECT", - "startPosition": "3132" + "startPosition": "3772" }, - "endPosition": "3153", + "endPosition": "3793", "kind": "MEMBER_SELECT", - "startPosition": "3132" + "startPosition": "3772" }, "arguments": [ { - "endPosition": "3159", + "endPosition": "3799", "kind": "IDENTIFIER", "name": "files", - "startPosition": "3154" + "startPosition": "3794" } ], - "startPosition": "3132" + "startPosition": "3772" }, - "endPosition": "3160", + "endPosition": "3800", "kind": "EXPRESSION_STATEMENT", - "startPosition": "3132" + "startPosition": "3772" }, { - "endPosition": "3184", + "endPosition": "3824", "kind": "VARIABLE", - "name": "file", - "startPosition": "3180" + "binding": { + "endPosition": "3824", + "kind": "IDENTIFIER", + "name": "file", + "startPosition": "3820" + }, + "startPosition": "3816" }, { "expression": { - "endPosition": "3193", + "endPosition": "3833", "kind": "IDENTIFIER", "name": "files", - "startPosition": "3188" + "startPosition": "3828" }, - "endPosition": "3724", + "endPosition": "4364", "kind": "FOR_IN_LOOP", "forEach": "true", "variable": { - "endPosition": "3184", + "endPosition": "3824", "kind": "IDENTIFIER", "name": "file", - "startPosition": "3180" + "startPosition": "3820" }, "statement": { - "endPosition": "3724", + "endPosition": "4364", "kind": "BLOCK", "statements": [ { "condition": { - "endPosition": "3234", + "endPosition": "3874", "kind": "FUNCTION_INVOCATION", "functionSelect": { "identifier": "endsWith", "expression": { "identifier": "name", "expression": { - "endPosition": "3213", + "endPosition": "3853", "kind": "IDENTIFIER", "name": "file", - "startPosition": "3209" + "startPosition": "3849" }, - "endPosition": "3218", + "endPosition": "3858", "kind": "MEMBER_SELECT", - "startPosition": "3209" + "startPosition": "3849" }, - "endPosition": "3227", + "endPosition": "3867", "kind": "MEMBER_SELECT", - "startPosition": "3209" + "startPosition": "3849" }, "arguments": [ { - "endPosition": "3232", + "endPosition": "3872", "kind": "STRING_LITERAL", "value": ".js", - "startPosition": "3229" + "startPosition": "3869" } ], - "startPosition": "3209" + "startPosition": "3849" }, - "endPosition": "3718", + "endPosition": "4358", "kind": "IF", - "startPosition": "3205", + "startPosition": "3845", "thenStatement": { - "endPosition": "3718", + "endPosition": "4358", "kind": "BLOCK", "statements": [ { - "endPosition": "3278", + "endPosition": "3918", "kind": "VARIABLE", - "name": "script", - "startPosition": "3254", + "binding": { + "endPosition": "3900", + "kind": "IDENTIFIER", + "name": "script", + "startPosition": "3894" + }, + "startPosition": "3890", "initializer": { - "endPosition": "3278", + "endPosition": "3918", "kind": "FUNCTION_INVOCATION", "functionSelect": { - "endPosition": "3272", + "endPosition": "3912", "kind": "IDENTIFIER", "name": "readFully", - "startPosition": "3263" + "startPosition": "3903" }, "arguments": [ { - "endPosition": "3277", + "endPosition": "3917", "kind": "IDENTIFIER", "name": "file", - "startPosition": "3273" + "startPosition": "3913" } ], - "startPosition": "3263" + "startPosition": "3903" } }, { - "endPosition": "3317", + "endPosition": "3957", "kind": "VARIABLE", - "name": "parser", - "startPosition": "3296", + "binding": { + "endPosition": "3942", + "kind": "IDENTIFIER", + "name": "parser", + "startPosition": "3936" + }, + "startPosition": "3932", "initializer": { "constructorExpression": { - "endPosition": "3317", + "endPosition": "3957", "kind": "FUNCTION_INVOCATION", "functionSelect": { - "endPosition": "3315", + "endPosition": "3955", "kind": "IDENTIFIER", "name": "Parser", - "startPosition": "3309" + "startPosition": "3949" }, "arguments": [], - "startPosition": "3309" + "startPosition": "3949" }, - "endPosition": "3317", + "endPosition": "3957", "kind": "NEW", - "startPosition": "3305" + "startPosition": "3945" } }, { - "endPosition": "3578", + "endPosition": "4218", "kind": "VARIABLE", - "name": "tree", - "startPosition": "3335", + "binding": { + "endPosition": "3979", + "kind": "IDENTIFIER", + "name": "tree", + "startPosition": "3975" + }, + "startPosition": "3971", "initializer": { - "endPosition": "3578", + "endPosition": "4218", "kind": "FUNCTION_INVOCATION", "functionSelect": { "identifier": "parse", "expression": { - "endPosition": "3348", + "endPosition": "3988", "kind": "IDENTIFIER", "name": "parser", - "startPosition": "3342" + "startPosition": "3982" }, - "endPosition": "3354", + "endPosition": "3994", "kind": "MEMBER_SELECT", - "startPosition": "3342" + "startPosition": "3982" }, "arguments": [ { "leftOperand": { "leftOperand": { - "endPosition": "3361", + "endPosition": "4001", "kind": "IDENTIFIER", "name": "subdir", - "startPosition": "3355" + "startPosition": "3995" }, - "endPosition": "3366", + "endPosition": "4006", "kind": "PLUS", "rightOperand": { - "endPosition": "3366", + "endPosition": "4006", "kind": "STRING_LITERAL", "value": "/", - "startPosition": "3365" + "startPosition": "4005" }, - "startPosition": "3355" + "startPosition": "3995" }, - "endPosition": "3379", + "endPosition": "4019", "kind": "PLUS", "rightOperand": { "identifier": "name", "expression": { - "endPosition": "3374", + "endPosition": "4014", "kind": "IDENTIFIER", "name": "file", - "startPosition": "3370" + "startPosition": "4010" }, - "endPosition": "3379", + "endPosition": "4019", "kind": "MEMBER_SELECT", - "startPosition": "3370" + "startPosition": "4010" }, - "startPosition": "3355" + "startPosition": "3995" }, { - "endPosition": "3387", + "endPosition": "4027", "kind": "IDENTIFIER", "name": "script", - "startPosition": "3381" + "startPosition": "4021" }, { - "endPosition": "3426", + "endPosition": "4066", "kind": "FUNCTION_EXPRESSION", "body": { - "endPosition": "3559", + "endPosition": "4199", "kind": "BLOCK", "statements": [ { "expression": { - "endPosition": "3526", + "endPosition": "4166", "kind": "FUNCTION_INVOCATION", "functionSelect": { - "endPosition": "3453", + "endPosition": "4093", "kind": "IDENTIFIER", "name": "print", - "startPosition": "3448" + "startPosition": "4088" }, "arguments": [ { - "endPosition": "3525", + "endPosition": "4165", "kind": "FUNCTION_INVOCATION", "functionSelect": { "identifier": "replace", "expression": { - "endPosition": "3505", + "endPosition": "4145", "kind": "FUNCTION_INVOCATION", "functionSelect": { "identifier": "stringify", "expression": { - "endPosition": "3458", + "endPosition": "4098", "kind": "IDENTIFIER", "name": "JSON", - "startPosition": "3454" + "startPosition": "4094" }, - "endPosition": "3468", + "endPosition": "4108", "kind": "MEMBER_SELECT", - "startPosition": "3454" + "startPosition": "4094" }, "arguments": [ { - "endPosition": "3495", + "endPosition": "4135", "kind": "FUNCTION_INVOCATION", "functionSelect": { "identifier": "convert", "expression": { - "endPosition": "3475", + "endPosition": "4115", "kind": "IDENTIFIER", "name": "parser", - "startPosition": "3469" + "startPosition": "4109" }, - "endPosition": "3483", + "endPosition": "4123", "kind": "MEMBER_SELECT", - "startPosition": "3469" + "startPosition": "4109" }, "arguments": [ { - "endPosition": "3494", + "endPosition": "4134", "kind": "IDENTIFIER", "name": "diagnostic", - "startPosition": "3484" + "startPosition": "4124" } ], - "startPosition": "3469" + "startPosition": "4109" }, { - "endPosition": "3501", + "endPosition": "4141", "kind": "NULL_LITERAL", - "startPosition": "3497" + "startPosition": "4137" }, { - "endPosition": "3504", + "endPosition": "4144", "kind": "NUMBER_LITERAL", "value": "2", - "startPosition": "3503" + "startPosition": "4143" } ], - "startPosition": "3454" + "startPosition": "4094" }, - "endPosition": "3513", + "endPosition": "4153", "kind": "MEMBER_SELECT", - "startPosition": "3454" + "startPosition": "4094" }, "arguments": [ { - "endPosition": "3520", + "endPosition": "4160", "kind": "REGEXP_LITERAL", "options": "g", "pattern": "\\\\r", - "startPosition": "3514" + "startPosition": "4154" }, { - "endPosition": "3523", + "endPosition": "4163", "kind": "STRING_LITERAL", "value": "", - "startPosition": "3523" + "startPosition": "4163" } ], - "startPosition": "3513" + "startPosition": "4153" } ], - "startPosition": "3448" + "startPosition": "4088" }, - "endPosition": "3526", + "endPosition": "4166", "kind": "EXPRESSION_STATEMENT", - "startPosition": "3448" + "startPosition": "4088" }, { "expression": { - "endPosition": "3558", + "endPosition": "4198", "kind": "FUNCTION_INVOCATION", "functionSelect": { - "endPosition": "3553", + "endPosition": "4193", "kind": "IDENTIFIER", "name": "print", - "startPosition": "3548" + "startPosition": "4188" }, "arguments": [ { - "endPosition": "3556", + "endPosition": "4196", "kind": "STRING_LITERAL", "value": ",", - "startPosition": "3555" + "startPosition": "4195" } ], - "startPosition": "3548" + "startPosition": "4188" }, - "endPosition": "3558", + "endPosition": "4198", "kind": "EXPRESSION_STATEMENT", - "startPosition": "3548" + "startPosition": "4188" } ], - "startPosition": "3426" + "startPosition": "4066" }, "strict": "false", - "startPosition": "3426", + "startPosition": "4066", "parameters": [ { - "endPosition": "3424", + "endPosition": "4064", "kind": "IDENTIFIER", "name": "diagnostic", - "startPosition": "3414" + "startPosition": "4054" } ] } ], - "startPosition": "3342" + "startPosition": "3982" } }, { "condition": { "leftOperand": { - "endPosition": "3601", + "endPosition": "4241", "kind": "IDENTIFIER", "name": "tree", - "startPosition": "3597" + "startPosition": "4237" }, - "endPosition": "3609", + "endPosition": "4249", "kind": "NOT_EQUAL_TO", "rightOperand": { - "endPosition": "3609", + "endPosition": "4249", "kind": "NULL_LITERAL", - "startPosition": "3605" + "startPosition": "4245" }, - "startPosition": "3597" + "startPosition": "4237" }, - "endPosition": "3708", + "endPosition": "4348", "kind": "IF", - "startPosition": "3593", + "startPosition": "4233", "thenStatement": { - "endPosition": "3708", + "endPosition": "4348", "kind": "BLOCK", "statements": [ { "expression": { - "endPosition": "3665", + "endPosition": "4305", "kind": "FUNCTION_INVOCATION", "functionSelect": { - "endPosition": "3634", + "endPosition": "4274", "kind": "IDENTIFIER", "name": "print", - "startPosition": "3629" + "startPosition": "4269" }, "arguments": [ { - "endPosition": "3664", + "endPosition": "4304", "kind": "FUNCTION_INVOCATION", "functionSelect": { "identifier": "stringify", "expression": { - "endPosition": "3639", + "endPosition": "4279", "kind": "IDENTIFIER", "name": "JSON", - "startPosition": "3635" + "startPosition": "4275" }, - "endPosition": "3649", + "endPosition": "4289", "kind": "MEMBER_SELECT", - "startPosition": "3635" + "startPosition": "4275" }, "arguments": [ { - "endPosition": "3654", + "endPosition": "4294", "kind": "IDENTIFIER", "name": "tree", - "startPosition": "3650" + "startPosition": "4290" }, { - "endPosition": "3660", + "endPosition": "4300", "kind": "NULL_LITERAL", - "startPosition": "3656" + "startPosition": "4296" }, { - "endPosition": "3663", + "endPosition": "4303", "kind": "NUMBER_LITERAL", "value": "2", - "startPosition": "3662" + "startPosition": "4302" } ], - "startPosition": "3635" + "startPosition": "4275" } ], - "startPosition": "3629" + "startPosition": "4269" }, - "endPosition": "3665", + "endPosition": "4305", "kind": "EXPRESSION_STATEMENT", - "startPosition": "3629" + "startPosition": "4269" }, { "expression": { - "endPosition": "3693", + "endPosition": "4333", "kind": "FUNCTION_INVOCATION", "functionSelect": { - "endPosition": "3688", + "endPosition": "4328", "kind": "IDENTIFIER", "name": "print", - "startPosition": "3683" + "startPosition": "4323" }, "arguments": [ { - "endPosition": "3691", + "endPosition": "4331", "kind": "STRING_LITERAL", "value": ",", - "startPosition": "3690" + "startPosition": "4330" } ], - "startPosition": "3683" + "startPosition": "4323" }, - "endPosition": "3693", + "endPosition": "4333", "kind": "EXPRESSION_STATEMENT", - "startPosition": "3683" + "startPosition": "4323" } ], - "startPosition": "3611" + "startPosition": "4251" } } ], - "startPosition": "3236" + "startPosition": "3876" } } ], - "startPosition": "3195" + "startPosition": "3835" }, - "startPosition": "3166" + "startPosition": "3806" } ], - "startPosition": "3028" + "startPosition": "3668" }, "strict": "false", - "startPosition": "2998", + "startPosition": "3638", "parameters": [ { - "endPosition": "3026", + "endPosition": "3666", "kind": "IDENTIFIER", "name": "subdir", - "startPosition": "3020" + "startPosition": "3660" } ] }, { - "endPosition": "4070", + "endPosition": "4710", "kind": "FUNCTION", - "name": "main", + "name": { + "endPosition": "4421", + "kind": "IDENTIFIER", + "name": "main", + "startPosition": "4417" + }, "body": { - "endPosition": "4068", + "endPosition": "4708", "kind": "BLOCK", "statements": [ { "expression": { - "endPosition": "3800", + "endPosition": "4440", "kind": "FUNCTION_INVOCATION", "functionSelect": { - "endPosition": "3795", + "endPosition": "4435", "kind": "IDENTIFIER", "name": "print", - "startPosition": "3790" + "startPosition": "4430" }, "arguments": [ { - "endPosition": "3798", + "endPosition": "4438", "kind": "STRING_LITERAL", "value": "[", - "startPosition": "3797" + "startPosition": "4437" } ], - "startPosition": "3790" + "startPosition": "4430" }, - "endPosition": "3800", + "endPosition": "4440", "kind": "EXPRESSION_STATEMENT", - "startPosition": "3790" + "startPosition": "4430" }, { "expression": { - "endPosition": "3834", + "endPosition": "4474", "kind": "FUNCTION_INVOCATION", "functionSelect": { - "endPosition": "3819", + "endPosition": "4459", "kind": "IDENTIFIER", "name": "processFiles", - "startPosition": "3807" + "startPosition": "4447" }, "arguments": [ { - "endPosition": "3832", + "endPosition": "4472", "kind": "STRING_LITERAL", "value": "parsertests", - "startPosition": "3821" + "startPosition": "4461" } ], - "startPosition": "3807" + "startPosition": "4447" }, - "endPosition": "3834", + "endPosition": "4474", "kind": "EXPRESSION_STATEMENT", - "startPosition": "3807" + "startPosition": "4447" }, { "expression": { - "endPosition": "3875", + "endPosition": "4515", "kind": "FUNCTION_INVOCATION", "functionSelect": { - "endPosition": "3852", + "endPosition": "4492", "kind": "IDENTIFIER", "name": "processFiles", - "startPosition": "3840" + "startPosition": "4480" }, "arguments": [ { - "endPosition": "3873", + "endPosition": "4513", "kind": "STRING_LITERAL", "value": "parsernegativetests", - "startPosition": "3854" + "startPosition": "4494" } ], - "startPosition": "3840" + "startPosition": "4480" }, - "endPosition": "3875", + "endPosition": "4515", "kind": "EXPRESSION_STATEMENT", - "startPosition": "3840" + "startPosition": "4480" }, { - "endPosition": "3944", + "endPosition": "4584", "kind": "VARIABLE", - "name": "script", - "startPosition": "3916", + "binding": { + "endPosition": "4562", + "kind": "IDENTIFIER", + "name": "script", + "startPosition": "4556" + }, + "startPosition": "4552", "initializer": { - "endPosition": "3944", + "endPosition": "4584", "kind": "FUNCTION_INVOCATION", "functionSelect": { - "endPosition": "3934", + "endPosition": "4574", "kind": "IDENTIFIER", "name": "readFully", - "startPosition": "3925" + "startPosition": "4565" }, "arguments": [ { - "endPosition": "3943", + "endPosition": "4583", "kind": "IDENTIFIER", "name": "__FILE__", - "startPosition": "3935" + "startPosition": "4575" } ], - "startPosition": "3925" + "startPosition": "4565" } }, { - "endPosition": "4009", + "endPosition": "4649", "kind": "VARIABLE", - "name": "tree", - "startPosition": "3954", + "binding": { + "endPosition": "4598", + "kind": "IDENTIFIER", + "name": "tree", + "startPosition": "4594" + }, + "startPosition": "4590", "initializer": { - "endPosition": "4009", + "endPosition": "4649", "kind": "FUNCTION_INVOCATION", "functionSelect": { "identifier": "parse", "expression": { "constructorExpression": { - "endPosition": "3973", + "endPosition": "4613", "kind": "FUNCTION_INVOCATION", "functionSelect": { - "endPosition": "3971", + "endPosition": "4611", "kind": "IDENTIFIER", "name": "Parser", - "startPosition": "3965" + "startPosition": "4605" }, "arguments": [], - "startPosition": "3965" + "startPosition": "4605" }, - "endPosition": "3973", + "endPosition": "4613", "kind": "NEW", - "startPosition": "3961" + "startPosition": "4601" }, - "endPosition": "3979", + "endPosition": "4619", "kind": "MEMBER_SELECT", - "startPosition": "3961" + "startPosition": "4601" }, "arguments": [ { - "endPosition": "3993", + "endPosition": "4633", "kind": "STRING_LITERAL", "value": "parserapi.js", - "startPosition": "3981" + "startPosition": "4621" }, { - "endPosition": "4002", + "endPosition": "4642", "kind": "IDENTIFIER", "name": "script", - "startPosition": "3996" + "startPosition": "4636" }, { - "endPosition": "4008", + "endPosition": "4648", "kind": "NULL_LITERAL", - "startPosition": "4004" + "startPosition": "4644" } ], - "startPosition": "3961" + "startPosition": "4601" } }, { "expression": { - "endPosition": "4051", + "endPosition": "4691", "kind": "FUNCTION_INVOCATION", "functionSelect": { - "endPosition": "4020", + "endPosition": "4660", "kind": "IDENTIFIER", "name": "print", - "startPosition": "4015" + "startPosition": "4655" }, "arguments": [ { - "endPosition": "4050", + "endPosition": "4690", "kind": "FUNCTION_INVOCATION", "functionSelect": { "identifier": "stringify", "expression": { - "endPosition": "4025", + "endPosition": "4665", "kind": "IDENTIFIER", "name": "JSON", - "startPosition": "4021" + "startPosition": "4661" }, - "endPosition": "4035", + "endPosition": "4675", "kind": "MEMBER_SELECT", - "startPosition": "4021" + "startPosition": "4661" }, "arguments": [ { - "endPosition": "4040", + "endPosition": "4680", "kind": "IDENTIFIER", "name": "tree", - "startPosition": "4036" + "startPosition": "4676" }, { - "endPosition": "4046", + "endPosition": "4686", "kind": "NULL_LITERAL", - "startPosition": "4042" + "startPosition": "4682" }, { - "endPosition": "4049", + "endPosition": "4689", "kind": "NUMBER_LITERAL", "value": "2", - "startPosition": "4048" + "startPosition": "4688" } ], - "startPosition": "4021" + "startPosition": "4661" } ], - "startPosition": "4015" + "startPosition": "4655" }, - "endPosition": "4051", + "endPosition": "4691", "kind": "EXPRESSION_STATEMENT", - "startPosition": "4015" + "startPosition": "4655" }, { "expression": { - "endPosition": "4067", + "endPosition": "4707", "kind": "FUNCTION_INVOCATION", "functionSelect": { - "endPosition": "4062", + "endPosition": "4702", "kind": "IDENTIFIER", "name": "print", - "startPosition": "4057" + "startPosition": "4697" }, "arguments": [ { - "endPosition": "4065", + "endPosition": "4705", "kind": "STRING_LITERAL", "value": "]", - "startPosition": "4064" + "startPosition": "4704" } ], - "startPosition": "4057" + "startPosition": "4697" }, - "endPosition": "4067", + "endPosition": "4707", "kind": "EXPRESSION_STATEMENT", - "startPosition": "4057" + "startPosition": "4697" } ], - "startPosition": "3784" + "startPosition": "4424" }, "strict": "false", - "startPosition": "3768", + "startPosition": "4408", "parameters": [] }, { "expression": { - "endPosition": "4078", + "endPosition": "4718", "kind": "FUNCTION_INVOCATION", "functionSelect": { - "endPosition": "4076", + "endPosition": "4716", "kind": "IDENTIFIER", "name": "main", - "startPosition": "4072" + "startPosition": "4712" }, "arguments": [], - "startPosition": "4072" - }, - "endPosition": "4078", + "startPosition": "4712" + }, + "endPosition": "4718", "kind": "EXPRESSION_STATEMENT", - "startPosition": "4072" + "startPosition": "4712" } ], "sourceName": "parserapi.js", "strict": "false", "startPosition": "1136" -} -] +} +] diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/test/script/nosecurity/parservisitor.js --- a/nashorn/test/script/nosecurity/parservisitor.js Wed Jul 05 21:57:12 2017 +0200 +++ b/nashorn/test/script/nosecurity/parservisitor.js Wed Jul 05 21:58:29 2017 +0200 @@ -202,7 +202,7 @@ parse("funcdecl.js", "function func() {}", new (Java.extend(SimpleTreeVisitor))() { visitFunctionDeclaration: function(fd) { - print("in visitFunctionDeclaration " + fd.name); + print("in visitFunctionDeclaration " + fd.name.name); } }); @@ -361,7 +361,7 @@ parse("var.js", "var x = 34;", new (Java.extend(SimpleTreeVisitor))() { visitVariable: function(vn) { - print("in visitVariable " + vn.name + " = " + vn.initializer.value); + print("in visitVariable " + vn.binding.name + " = " + vn.initializer.value); } }); diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/test/script/nosecurity/treeapi/arrow.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nashorn/test/script/nosecurity/treeapi/arrow.js Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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. + */ + +/** + * Tests to check representation of ES6 arrows. + * + * @test + * @option -scripting + * @run + */ + +load(__DIR__ + "utils.js") + +var code = <x*2; +[].map(v => v + 1); + +EOF + +parse("arrow.js", code, "--language=es6", new (Java.extend(visitor_es6, { + visitVariable : function (node, obj) { + obj.push(convert(node)) + }, + visitExpressionStatement : function (node, obj) { + obj.push(convert(node)) + } +}))) + diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/test/script/nosecurity/treeapi/arrow.js.EXPECTED --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nashorn/test/script/nosecurity/treeapi/arrow.js.EXPECTED Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,103 @@ +[ + { + "endPosition": "15", + "kind": "VARIABLE", + "binding": { + "endPosition": "6", + "kind": "IDENTIFIER", + "name": "f", + "startPosition": "5" + }, + "startPosition": "1", + "initializer": { + "endPosition": "12", + "arrow": "true", + "kind": "FUNCTION_EXPRESSION", + "name": "null", + "body": { + "leftOperand": { + "endPosition": "13", + "kind": "IDENTIFIER", + "name": "x", + "startPosition": "12" + }, + "endPosition": "15", + "kind": "MULTIPLY", + "rightOperand": { + "endPosition": "15", + "kind": "NUMBER_LITERAL", + "value": "2", + "startPosition": "14" + }, + "startPosition": "12" + }, + "strict": "false", + "startPosition": "12", + "parameters": [ + { + "endPosition": "10", + "kind": "IDENTIFIER", + "name": "x", + "startPosition": "9" + } + ] + } + }, + { + "expression": { + "endPosition": "35", + "kind": "FUNCTION_INVOCATION", + "functionSelect": { + "identifier": "map", + "expression": { + "endPosition": "19", + "kind": "ARRAY_LITERAL", + "elements": [], + "startPosition": "17" + }, + "endPosition": "23", + "kind": "MEMBER_SELECT", + "startPosition": "17" + }, + "arguments": [ + { + "endPosition": "29", + "arrow": "true", + "kind": "FUNCTION_EXPRESSION", + "name": "null", + "body": { + "leftOperand": { + "endPosition": "30", + "kind": "IDENTIFIER", + "name": "v", + "startPosition": "29" + }, + "endPosition": "34", + "kind": "PLUS", + "rightOperand": { + "endPosition": "34", + "kind": "NUMBER_LITERAL", + "value": "1", + "startPosition": "33" + }, + "startPosition": "29" + }, + "strict": "false", + "startPosition": "29", + "parameters": [ + { + "endPosition": "25", + "kind": "IDENTIFIER", + "name": "v", + "startPosition": "24" + } + ] + } + ], + "startPosition": "17" + }, + "endPosition": "35", + "kind": "EXPRESSION_STATEMENT", + "startPosition": "17" + } +] diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/test/script/nosecurity/treeapi/arrow_params.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nashorn/test/script/nosecurity/treeapi/arrow_params.js Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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. + */ + +/** + * Tests to check representation of ES6 arrow params. + * + * @test + * @option -scripting + * @run + */ + +load(__DIR__ + "utils.js") + +var code = <x*3; +var f2 = ({x, y})=>x*y; +var f3 = ([x, y])=>x+y; +var f4 = ({x, y}={y: 4, x: 5})=>x*y; +var f5 = ([x, y]=[3, 6])=>x+y; + +EOF + +parse("arrow_params.js", code, "--language=es6", new (Java.extend(visitor_es6, { + visitVariable : function (node, obj) { + obj.push(convert(node)) + } +}))) + diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/test/script/nosecurity/treeapi/arrow_params.js.EXPECTED --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nashorn/test/script/nosecurity/treeapi/arrow_params.js.EXPECTED Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,411 @@ +[ + { + "endPosition": "20", + "kind": "VARIABLE", + "binding": { + "endPosition": "7", + "kind": "IDENTIFIER", + "name": "f1", + "startPosition": "5" + }, + "startPosition": "1", + "initializer": { + "endPosition": "17", + "arrow": "true", + "kind": "FUNCTION_EXPRESSION", + "name": "null", + "body": { + "leftOperand": { + "endPosition": "18", + "kind": "IDENTIFIER", + "name": "x", + "startPosition": "17" + }, + "endPosition": "20", + "kind": "MULTIPLY", + "rightOperand": { + "endPosition": "20", + "kind": "NUMBER_LITERAL", + "value": "3", + "startPosition": "19" + }, + "startPosition": "17" + }, + "strict": "false", + "startPosition": "17", + "parameters": [ + { + "expression": { + "endPosition": "14", + "kind": "NUMBER_LITERAL", + "value": "2", + "startPosition": "13" + }, + "endPosition": "14", + "kind": "ASSIGNMENT", + "variable": { + "endPosition": "12", + "kind": "IDENTIFIER", + "name": "x", + "startPosition": "11" + }, + "startPosition": "11" + } + ] + } + }, + { + "endPosition": "44", + "kind": "VARIABLE", + "binding": { + "endPosition": "28", + "kind": "IDENTIFIER", + "name": "f2", + "startPosition": "26" + }, + "startPosition": "22", + "initializer": { + "endPosition": "41", + "arrow": "true", + "kind": "FUNCTION_EXPRESSION", + "name": "null", + "body": { + "leftOperand": { + "endPosition": "42", + "kind": "IDENTIFIER", + "name": "x", + "startPosition": "41" + }, + "endPosition": "44", + "kind": "MULTIPLY", + "rightOperand": { + "endPosition": "44", + "kind": "IDENTIFIER", + "name": "y", + "startPosition": "43" + }, + "startPosition": "41" + }, + "strict": "false", + "startPosition": "41", + "parameters": [ + { + "endPosition": "38", + "kind": "OBJECT_LITERAL", + "startPosition": "32", + "properties": [ + { + "getter": "null", + "endPosition": "34", + "kind": "PROPERTY", + "setter": "null", + "value": { + "endPosition": "34", + "kind": "IDENTIFIER", + "name": "x", + "startPosition": "33" + }, + "startPosition": "33", + "key": { + "endPosition": "34", + "kind": "IDENTIFIER", + "name": "x", + "startPosition": "33" + } + }, + { + "getter": "null", + "endPosition": "37", + "kind": "PROPERTY", + "setter": "null", + "value": { + "endPosition": "37", + "kind": "IDENTIFIER", + "name": "y", + "startPosition": "36" + }, + "startPosition": "36", + "key": { + "endPosition": "37", + "kind": "IDENTIFIER", + "name": "y", + "startPosition": "36" + } + } + ] + } + ] + } + }, + { + "endPosition": "68", + "kind": "VARIABLE", + "binding": { + "endPosition": "52", + "kind": "IDENTIFIER", + "name": "f3", + "startPosition": "50" + }, + "startPosition": "46", + "initializer": { + "endPosition": "65", + "arrow": "true", + "kind": "FUNCTION_EXPRESSION", + "name": "null", + "body": { + "leftOperand": { + "endPosition": "66", + "kind": "IDENTIFIER", + "name": "x", + "startPosition": "65" + }, + "endPosition": "68", + "kind": "PLUS", + "rightOperand": { + "endPosition": "68", + "kind": "IDENTIFIER", + "name": "y", + "startPosition": "67" + }, + "startPosition": "65" + }, + "strict": "false", + "startPosition": "65", + "parameters": [ + { + "endPosition": "62", + "kind": "ARRAY_LITERAL", + "elements": [ + { + "endPosition": "58", + "kind": "IDENTIFIER", + "name": "x", + "startPosition": "57" + }, + { + "endPosition": "61", + "kind": "IDENTIFIER", + "name": "y", + "startPosition": "60" + } + ], + "startPosition": "56" + } + ] + } + }, + { + "endPosition": "105", + "kind": "VARIABLE", + "binding": { + "endPosition": "76", + "kind": "IDENTIFIER", + "name": "f4", + "startPosition": "74" + }, + "startPosition": "70", + "initializer": { + "endPosition": "102", + "arrow": "true", + "kind": "FUNCTION_EXPRESSION", + "name": "null", + "body": { + "leftOperand": { + "endPosition": "103", + "kind": "IDENTIFIER", + "name": "x", + "startPosition": "102" + }, + "endPosition": "105", + "kind": "MULTIPLY", + "rightOperand": { + "endPosition": "105", + "kind": "IDENTIFIER", + "name": "y", + "startPosition": "104" + }, + "startPosition": "102" + }, + "strict": "false", + "startPosition": "102", + "parameters": [ + { + "expression": { + "endPosition": "99", + "kind": "OBJECT_LITERAL", + "startPosition": "87", + "properties": [ + { + "getter": "null", + "endPosition": "92", + "kind": "PROPERTY", + "setter": "null", + "value": { + "endPosition": "92", + "kind": "NUMBER_LITERAL", + "value": "4", + "startPosition": "91" + }, + "startPosition": "88", + "key": { + "endPosition": "89", + "kind": "IDENTIFIER", + "name": "y", + "startPosition": "88" + } + }, + { + "getter": "null", + "endPosition": "98", + "kind": "PROPERTY", + "setter": "null", + "value": { + "endPosition": "98", + "kind": "NUMBER_LITERAL", + "value": "5", + "startPosition": "97" + }, + "startPosition": "94", + "key": { + "endPosition": "95", + "kind": "IDENTIFIER", + "name": "x", + "startPosition": "94" + } + } + ] + }, + "endPosition": "99", + "kind": "ASSIGNMENT", + "variable": { + "endPosition": "86", + "kind": "OBJECT_LITERAL", + "startPosition": "80", + "properties": [ + { + "getter": "null", + "endPosition": "82", + "kind": "PROPERTY", + "setter": "null", + "value": { + "endPosition": "82", + "kind": "IDENTIFIER", + "name": "x", + "startPosition": "81" + }, + "startPosition": "81", + "key": { + "endPosition": "82", + "kind": "IDENTIFIER", + "name": "x", + "startPosition": "81" + } + }, + { + "getter": "null", + "endPosition": "85", + "kind": "PROPERTY", + "setter": "null", + "value": { + "endPosition": "85", + "kind": "IDENTIFIER", + "name": "y", + "startPosition": "84" + }, + "startPosition": "84", + "key": { + "endPosition": "85", + "kind": "IDENTIFIER", + "name": "y", + "startPosition": "84" + } + } + ] + }, + "startPosition": "80" + } + ] + } + }, + { + "endPosition": "136", + "kind": "VARIABLE", + "binding": { + "endPosition": "113", + "kind": "IDENTIFIER", + "name": "f5", + "startPosition": "111" + }, + "startPosition": "107", + "initializer": { + "endPosition": "133", + "arrow": "true", + "kind": "FUNCTION_EXPRESSION", + "name": "null", + "body": { + "leftOperand": { + "endPosition": "134", + "kind": "IDENTIFIER", + "name": "x", + "startPosition": "133" + }, + "endPosition": "136", + "kind": "PLUS", + "rightOperand": { + "endPosition": "136", + "kind": "IDENTIFIER", + "name": "y", + "startPosition": "135" + }, + "startPosition": "133" + }, + "strict": "false", + "startPosition": "133", + "parameters": [ + { + "expression": { + "endPosition": "130", + "kind": "ARRAY_LITERAL", + "elements": [ + { + "endPosition": "126", + "kind": "NUMBER_LITERAL", + "value": "3", + "startPosition": "125" + }, + { + "endPosition": "129", + "kind": "NUMBER_LITERAL", + "value": "6", + "startPosition": "128" + } + ], + "startPosition": "124" + }, + "endPosition": "130", + "kind": "ASSIGNMENT", + "variable": { + "endPosition": "123", + "kind": "ARRAY_LITERAL", + "elements": [ + { + "endPosition": "119", + "kind": "IDENTIFIER", + "name": "x", + "startPosition": "118" + }, + { + "endPosition": "122", + "kind": "IDENTIFIER", + "name": "y", + "startPosition": "121" + } + ], + "startPosition": "117" + }, + "startPosition": "117" + } + ] + } + } +] diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/test/script/nosecurity/treeapi/assignment.js.EXPECTED --- a/nashorn/test/script/nosecurity/treeapi/assignment.js.EXPECTED Wed Jul 05 21:57:12 2017 +0200 +++ b/nashorn/test/script/nosecurity/treeapi/assignment.js.EXPECTED Wed Jul 05 21:58:29 2017 +0200 @@ -146,4 +146,4 @@ }, "startPosition": "61" } -] +] diff -r 5a66e43d8cbd -r 5bf88dce615f nashorn/test/script/nosecurity/treeapi/class.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nashorn/test/script/nosecurity/treeapi/class.js Wed Jul 05 21:58:29 2017 +0200 @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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. + */ + +/** + * Tests to check representation of ES6 class. + * + * @test + * @option -scripting + * @run + */ + +load(__DIR__ + "utils.js") + +var code = <
        Description
        testpkgmdl1All Modules 
        module2\n" + + "
        This is a test description for the module2 module.
        \n" + + "
        testpkg2mdl2module1 
        java.base 
        TestClassInModule2 
        testpkg2mdl2.TestInterfaceInModule2
        (Implementation: " + + "TestClassInModule2)
         
        PackageModuleDescription
        Requires 
        ModuleDescription
        Uses 
        TypeDescription
        Provides 
        TypeDescription