# HG changeset patch # User herrick # Date 1530883757 14400 # Node ID 49b4e7203b4b4867345a5adb475f1ea5443293fc # Parent 565d54ca1f4150f6ef5b3d28aba73e4e4a8e39c5# Parent 8cc36fac7f3d826e381c06f010d700abe81ae6fb Merge diff -r 565d54ca1f41 -r 49b4e7203b4b .hgtags --- a/.hgtags Fri Jul 06 09:27:32 2018 -0400 +++ b/.hgtags Fri Jul 06 09:29:17 2018 -0400 @@ -493,3 +493,4 @@ 36ca515343e00b021dcfc902e986d26ec994a2e5 jdk-11+19 95aad0c785e497f1bade3955c4e4a677b629fa9d jdk-12+0 9816d7cc655e53ba081f938b656e31971b8f097a jdk-11+20 +00b16d0457e43d23f6ca5ade6b243edce62750a0 jdk-12+1 diff -r 565d54ca1f41 -r 49b4e7203b4b make/scripts/compare.sh --- a/make/scripts/compare.sh Fri Jul 06 09:27:32 2018 -0400 +++ b/make/scripts/compare.sh Fri Jul 06 09:29:17 2018 -0400 @@ -1385,26 +1385,22 @@ echo " $OTHER_SPARKLE_DIR" fi - if [ -d "$OTHER/images" ]; then - OTHER_SEC_DIR="$OTHER/images" - else - OTHER_SEC_DIR="$OTHER/tmp" - fi - if [ -f "$THIS_SEC_DIR/sec-bin.zip" ]; then + THIS_SEC_DIR="$THIS/images" + OTHER_SEC_DIR="$OTHER/images" + if [ -f "$THIS_SEC_DIR/sec-bin.zip" ] && [ -f "$OTHER_SEC_DIR/sec-bin.zip" ]; then OTHER_SEC_BIN="$OTHER_SEC_DIR/sec-bin.zip" - THIS_SEC_DIR="$THIS/images" THIS_SEC_BIN="$THIS_SEC_DIR/sec-bin.zip" - fi - if [ "$OPENJDK_TARGET_OS" = "windows" ]; then - if [ "$OPENJDK_TARGET_CPU" = "x86_64" ]; then - JGSS_WINDOWS_BIN="jgss-windows-x64-bin.zip" - else - JGSS_WINDOWS_BIN="jgss-windows-i586-bin.zip" + if [ "$OPENJDK_TARGET_OS" = "windows" ]; then + if [ "$OPENJDK_TARGET_CPU" = "x86_64" ]; then + JGSS_WINDOWS_BIN="jgss-windows-x64-bin.zip" + else + JGSS_WINDOWS_BIN="jgss-windows-i586-bin.zip" + fi + OTHER_SEC_WINDOWS_BIN="$OTHER_SEC_DIR/sec-windows-bin.zip" + OTHER_JGSS_WINDOWS_BIN="$OTHER_SEC_DIR/$JGSS_WINDOWS_BIN" + THIS_SEC_WINDOWS_BIN="$THIS_SEC_DIR/sec-windows-bin.zip" + THIS_JGSS_WINDOWS_BIN="$THIS_SEC_DIR/$JGSS_WINDOWS_BIN" fi - OTHER_SEC_WINDOWS_BIN="$OTHER_SEC_DIR/sec-windows-bin.zip" - OTHER_JGSS_WINDOWS_BIN="$OTHER_SEC_DIR/$JGSS_WINDOWS_BIN" - THIS_SEC_WINDOWS_BIN="$THIS_SEC_DIR/sec-windows-bin.zip" - THIS_JGSS_WINDOWS_BIN="$THIS_SEC_DIR/$JGSS_WINDOWS_BIN" fi if [ -d "$THIS/images/docs" ] && [ -d "$OTHER/images/docs" ]; then diff -r 565d54ca1f41 -r 49b4e7203b4b src/hotspot/cpu/x86/methodHandles_x86.cpp --- a/src/hotspot/cpu/x86/methodHandles_x86.cpp Fri Jul 06 09:27:32 2018 -0400 +++ b/src/hotspot/cpu/x86/methodHandles_x86.cpp Fri Jul 06 09:29:17 2018 -0400 @@ -440,8 +440,6 @@ verify_ref_kind(_masm, JVM_REF_invokeInterface, member_reg, temp3); } - BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler(); - Register temp3_intf = temp3; __ load_heap_oop(temp3_intf, member_clazz); load_klass_from_Class(_masm, temp3_intf); diff -r 565d54ca1f41 -r 49b4e7203b4b src/hotspot/os/aix/os_aix.cpp --- a/src/hotspot/os/aix/os_aix.cpp Fri Jul 06 09:27:32 2018 -0400 +++ b/src/hotspot/os/aix/os_aix.cpp Fri Jul 06 09:29:17 2018 -0400 @@ -1208,22 +1208,6 @@ ::abort(); } -// This method is a copy of JDK's sysGetLastErrorString -// from src/solaris/hpi/src/system_md.c - -size_t os::lasterror(char *buf, size_t len) { - if (errno == 0) return 0; - - const char *s = os::strerror(errno); - size_t n = ::strlen(s); - if (n >= len) { - n = len - 1; - } - ::strncpy(buf, s, n); - buf[n] = '\0'; - return n; -} - intx os::current_thread_id() { return (intx)pthread_self(); } diff -r 565d54ca1f41 -r 49b4e7203b4b src/hotspot/os/bsd/os_bsd.cpp --- a/src/hotspot/os/bsd/os_bsd.cpp Fri Jul 06 09:27:32 2018 -0400 +++ b/src/hotspot/os/bsd/os_bsd.cpp Fri Jul 06 09:29:17 2018 -0400 @@ -1081,22 +1081,6 @@ ::abort(); } -// This method is a copy of JDK's sysGetLastErrorString -// from src/solaris/hpi/src/system_md.c - -size_t os::lasterror(char *buf, size_t len) { - if (errno == 0) return 0; - - const char *s = os::strerror(errno); - size_t n = ::strlen(s); - if (n >= len) { - n = len - 1; - } - ::strncpy(buf, s, n); - buf[n] = '\0'; - return n; -} - // Information of current thread in variety of formats pid_t os::Bsd::gettid() { int retval = -1; diff -r 565d54ca1f41 -r 49b4e7203b4b src/hotspot/os/linux/os_linux.cpp --- a/src/hotspot/os/linux/os_linux.cpp Fri Jul 06 09:27:32 2018 -0400 +++ b/src/hotspot/os/linux/os_linux.cpp Fri Jul 06 09:29:17 2018 -0400 @@ -1419,23 +1419,6 @@ ::abort(); } - -// This method is a copy of JDK's sysGetLastErrorString -// from src/solaris/hpi/src/system_md.c - -size_t os::lasterror(char *buf, size_t len) { - if (errno == 0) return 0; - - const char *s = os::strerror(errno); - size_t n = ::strlen(s); - if (n >= len) { - n = len - 1; - } - ::strncpy(buf, s, n); - buf[n] = '\0'; - return n; -} - // thread_id is kernel thread id (similar to Solaris LWP id) intx os::current_thread_id() { return os::Linux::gettid(); } int os::current_process_id() { diff -r 565d54ca1f41 -r 49b4e7203b4b src/hotspot/os/posix/os_posix.cpp --- a/src/hotspot/os/posix/os_posix.cpp Fri Jul 06 09:27:32 2018 -0400 +++ b/src/hotspot/os/posix/os_posix.cpp Fri Jul 06 09:29:17 2018 -0400 @@ -150,6 +150,19 @@ return errno; } +size_t os::lasterror(char *buf, size_t len) { + if (errno == 0) return 0; + + const char *s = os::strerror(errno); + size_t n = ::strlen(s); + if (n >= len) { + n = len - 1; + } + ::strncpy(buf, s, n); + buf[n] = '\0'; + return n; +} + bool os::is_debugger_attached() { // not implemented return false; diff -r 565d54ca1f41 -r 49b4e7203b4b src/hotspot/os/solaris/os_solaris.cpp --- a/src/hotspot/os/solaris/os_solaris.cpp Fri Jul 06 09:27:32 2018 -0400 +++ b/src/hotspot/os/solaris/os_solaris.cpp Fri Jul 06 09:29:17 2018 -0400 @@ -2010,23 +2010,6 @@ // no suffix required } -// This method is a copy of JDK's sysGetLastErrorString -// from src/solaris/hpi/src/system_md.c - -size_t os::lasterror(char *buf, size_t len) { - if (errno == 0) return 0; - - const char *s = os::strerror(errno); - size_t n = ::strlen(s); - if (n >= len) { - n = len - 1; - } - ::strncpy(buf, s, n); - buf[n] = '\0'; - return n; -} - - // sun.misc.Signal extern "C" { diff -r 565d54ca1f41 -r 49b4e7203b4b src/hotspot/share/classfile/classLoader.cpp --- a/src/hotspot/share/classfile/classLoader.cpp Fri Jul 06 09:27:32 2018 -0400 +++ b/src/hotspot/share/classfile/classLoader.cpp Fri Jul 06 09:29:17 2018 -0400 @@ -298,8 +298,6 @@ char *copy = NEW_C_HEAP_ARRAY(char, strlen(zip_name)+1, mtClass); strcpy(copy, zip_name); _zip_name = copy; - _is_boot_append = is_boot_append; - _multi_versioned = _unknown; } ClassPathZipEntry::~ClassPathZipEntry() { @@ -338,95 +336,11 @@ return buffer; } -#if INCLUDE_CDS -u1* ClassPathZipEntry::open_versioned_entry(const char* name, jint* filesize, TRAPS) { - u1* buffer = NULL; - if (DumpSharedSpaces && !_is_boot_append) { - // We presume default is multi-release enabled - const char* multi_ver = Arguments::get_property("jdk.util.jar.enableMultiRelease"); - const char* verstr = Arguments::get_property("jdk.util.jar.version"); - bool is_multi_ver = (multi_ver == NULL || - strcmp(multi_ver, "true") == 0 || - strcmp(multi_ver, "force") == 0) && - is_multiple_versioned(THREAD); - // command line version setting - int version = 0; - const int base_version = 8; // JDK8 - int cur_ver = JDK_Version::current().major_version(); - if (verstr != NULL) { - version = atoi(verstr); - if (version < base_version || version > cur_ver) { - // If the specified version is lower than the base version, the base - // entry will be used; if the version is higher than the current - // jdk version, the highest versioned entry will be used. - if (version < base_version) { - is_multi_ver = false; - } - // print out warning, do not use assertion here since it will continue to look - // for proper version. - warning("JDK%d is not supported in multiple version jars", version); - } - } - - if (is_multi_ver) { - int n; - const char* version_entry = "META-INF/versions/"; - // 10 is the max length of a decimal 32-bit non-negative number - // 2 includes the '/' and trailing zero - size_t entry_name_len = strlen(version_entry) + 10 + strlen(name) + 2; - char* entry_name = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, entry_name_len); - if (version > 0) { - n = jio_snprintf(entry_name, entry_name_len, "%s%d/%s", version_entry, version, name); - entry_name[n] = '\0'; - buffer = open_entry((const char*)entry_name, filesize, false, CHECK_NULL); - if (buffer == NULL) { - warning("Could not find %s in %s, try to find highest version instead", entry_name, _zip_name); - } - } - if (buffer == NULL) { - for (int i = cur_ver; i >= base_version; i--) { - n = jio_snprintf(entry_name, entry_name_len, "%s%d/%s", version_entry, i, name); - entry_name[n] = '\0'; - buffer = open_entry((const char*)entry_name, filesize, false, CHECK_NULL); - if (buffer != NULL) { - break; - } - } - } - FREE_RESOURCE_ARRAY(char, entry_name, entry_name_len); - } - } - return buffer; -} - -bool ClassPathZipEntry::is_multiple_versioned(TRAPS) { - assert(DumpSharedSpaces, "called only at dump time"); - if (_multi_versioned != _unknown) { - return (_multi_versioned == _yes) ? true : false; - } - jint size; - char* buffer = (char*)open_entry("META-INF/MANIFEST.MF", &size, true, CHECK_false); - if (buffer != NULL) { - char* p = buffer; - for ( ; *p; ++p) *p = tolower(*p); - if (strstr(buffer, "multi-release: true") != NULL) { - _multi_versioned = _yes; - return true; - } - } - _multi_versioned = _no; - return false; -} -#endif // INCLUDE_CDS - ClassFileStream* ClassPathZipEntry::open_stream(const char* name, TRAPS) { jint filesize; - u1* buffer = open_versioned_entry(name, &filesize, CHECK_NULL); + u1* buffer = open_entry(name, &filesize, false, CHECK_NULL); if (buffer == NULL) { - buffer = open_entry(name, &filesize, false, CHECK_NULL); - if (buffer == NULL) { - return NULL; - } + return NULL; } if (UsePerfData) { ClassLoader::perf_sys_classfile_bytes_read()->inc(filesize); diff -r 565d54ca1f41 -r 49b4e7203b4b src/hotspot/share/classfile/classLoader.hpp --- a/src/hotspot/share/classfile/classLoader.hpp Fri Jul 06 09:27:32 2018 -0400 +++ b/src/hotspot/share/classfile/classLoader.hpp Fri Jul 06 09:29:17 2018 -0400 @@ -94,17 +94,9 @@ } jzentry; class ClassPathZipEntry: public ClassPathEntry { - enum { - _unknown = 0, - _yes = 1, - _no = 2 - }; private: jzfile* _zip; // The zip archive const char* _zip_name; // Name of zip archive - bool _is_boot_append; // entry coming from -Xbootclasspath/a - u1 _multi_versioned; // indicates if the jar file has multi-versioned entries. - // It can have value of "_unknown", "_yes", or "_no" public: bool is_modules_image() const { return false; } bool is_jar_file() const { return true; } @@ -113,10 +105,8 @@ ClassPathZipEntry(jzfile* zip, const char* zip_name, bool is_boot_append); virtual ~ClassPathZipEntry(); u1* open_entry(const char* name, jint* filesize, bool nul_terminate, TRAPS); - u1* open_versioned_entry(const char* name, jint* filesize, TRAPS) NOT_CDS_RETURN_(NULL); ClassFileStream* open_stream(const char* name, TRAPS); void contents_do(void f(const char* name, void* context), void* context); - bool is_multiple_versioned(TRAPS) NOT_CDS_RETURN_(false); // Debugging NOT_PRODUCT(void compile_the_world(Handle loader, TRAPS);) }; diff -r 565d54ca1f41 -r 49b4e7203b4b src/hotspot/share/gc/shared/barrierSet.hpp --- a/src/hotspot/share/gc/shared/barrierSet.hpp Fri Jul 06 09:27:32 2018 -0400 +++ b/src/hotspot/share/gc/shared/barrierSet.hpp Fri Jul 06 09:29:17 2018 -0400 @@ -199,7 +199,7 @@ template static T atomic_cmpxchg_in_heap_at(T new_value, oop base, ptrdiff_t offset, T compare_value) { - return Raw::oop_atomic_cmpxchg_at(new_value, base, offset, compare_value); + return Raw::atomic_cmpxchg_at(new_value, base, offset, compare_value); } template diff -r 565d54ca1f41 -r 49b4e7203b4b src/hotspot/share/interpreter/linkResolver.cpp --- a/src/hotspot/share/interpreter/linkResolver.cpp Fri Jul 06 09:27:32 2018 -0400 +++ b/src/hotspot/share/interpreter/linkResolver.cpp Fri Jul 06 09:29:17 2018 -0400 @@ -1221,17 +1221,14 @@ // check if the method is not resolved_method->name() != vmSymbols::object_initializer_name()) { - // check if this is an old-style super call and do a new lookup if so - // a) check if ACC_SUPER flag is set for the current class Klass* current_klass = link_info.current_klass(); - if ((current_klass->is_super() || !AllowNonVirtualCalls) && - // b) check if the class of the resolved_klass is a superclass - // (not supertype in order to exclude interface classes) of the current class. - // This check is not performed for super.invoke for interface methods - // in super interfaces. - current_klass->is_subclass_of(resolved_klass) && - current_klass != resolved_klass - ) { + + // Check if the class of the resolved_klass is a superclass + // (not supertype in order to exclude interface classes) of the current class. + // This check is not performed for super.invoke for interface methods + // in super interfaces. + if (current_klass->is_subclass_of(resolved_klass) && + current_klass != resolved_klass) { // Lookup super method Klass* super_klass = current_klass->super(); sel_method = lookup_instance_method_in_klasses(super_klass, diff -r 565d54ca1f41 -r 49b4e7203b4b src/hotspot/share/runtime/arguments.cpp --- a/src/hotspot/share/runtime/arguments.cpp Fri Jul 06 09:27:32 2018 -0400 +++ b/src/hotspot/share/runtime/arguments.cpp Fri Jul 06 09:29:17 2018 -0400 @@ -539,7 +539,6 @@ { "PrintSafepointStatisticsTimeout", JDK_Version::jdk(11), JDK_Version::jdk(12), JDK_Version::jdk(13) }, { "PrintSafepointStatisticsCount",JDK_Version::jdk(11), JDK_Version::jdk(12), JDK_Version::jdk(13) }, { "AggressiveOpts", JDK_Version::jdk(11), JDK_Version::jdk(12), JDK_Version::jdk(13) }, - { "AllowNonVirtualCalls", JDK_Version::jdk(11), JDK_Version::jdk(12), JDK_Version::jdk(13) }, { "UnlinkSymbolsALot", JDK_Version::jdk(11), JDK_Version::jdk(12), JDK_Version::jdk(13) }, // --- Deprecated alias flags (see also aliased_jvm_flags) - sorted by obsolete_in then expired_in: @@ -573,6 +572,7 @@ { "NativeMonitorTimeout", JDK_Version::undefined(), JDK_Version::jdk(11), JDK_Version::jdk(12) }, { "NativeMonitorSpinLimit", JDK_Version::undefined(), JDK_Version::jdk(11), JDK_Version::jdk(12) }, { "NativeMonitorFlags", JDK_Version::undefined(), JDK_Version::jdk(11), JDK_Version::jdk(12) }, + { "AllowNonVirtualCalls", JDK_Version::jdk(11), JDK_Version::jdk(12), JDK_Version::jdk(13) }, #ifdef TEST_VERIFY_SPECIAL_JVM_FLAGS { "dep > obs", JDK_Version::jdk(9), JDK_Version::jdk(8), JDK_Version::undefined() }, diff -r 565d54ca1f41 -r 49b4e7203b4b src/hotspot/share/runtime/globals.hpp --- a/src/hotspot/share/runtime/globals.hpp Fri Jul 06 09:27:32 2018 -0400 +++ b/src/hotspot/share/runtime/globals.hpp Fri Jul 06 09:29:17 2018 -0400 @@ -2571,9 +2571,6 @@ "Default survivor space alignment in bytes") \ constraint(SurvivorAlignmentInBytesConstraintFunc,AfterErgo) \ \ - product(bool , AllowNonVirtualCalls, false, \ - "Obey the ACC_SUPER flag and allow invokenonvirtual calls") \ - \ product(ccstr, DumpLoadedClassList, NULL, \ "Dump the names all loaded classes, that could be stored into " \ "the CDS archive, in the specified file") \ diff -r 565d54ca1f41 -r 49b4e7203b4b src/java.base/share/classes/java/lang/invoke/MethodHandles.java --- a/src/java.base/share/classes/java/lang/invoke/MethodHandles.java Fri Jul 06 09:27:32 2018 -0400 +++ b/src/java.base/share/classes/java/lang/invoke/MethodHandles.java Fri Jul 06 09:29:17 2018 -0400 @@ -71,6 +71,9 @@ *
  • Combinator methods, which combine or transform pre-existing method handles into new ones. *
  • Other factory methods to create method handles that emulate other common JVM operations or control flow patterns. * + * A lookup, combinator, or factory method will fail and throw an + * {@code IllegalArgumentException} if the created method handle's type + * would have too many parameters. * * @author John Rose, JSR 292 EG * @since 1.7 @@ -386,8 +389,9 @@ * constant is not subject to security manager checks. *
  • If the looked-up method has a * very large arity, - * the method handle creation may fail, due to the method handle - * type having too many parameters. + * the method handle creation may fail with an + * {@code IllegalArgumentException}, due to the method handle type having + * too many parameters. * * *

    Access checking

    diff -r 565d54ca1f41 -r 49b4e7203b4b src/java.base/share/classes/sun/net/NetworkServer.java --- a/src/java.base/share/classes/sun/net/NetworkServer.java Fri Jul 06 09:27:32 2018 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,151 +0,0 @@ -/* - * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package sun.net; - -import java.io.*; -import java.net.Socket; -import java.net.ServerSocket; - -/** - * This is the base class for network servers. To define a new type - * of server define a new subclass of NetworkServer with a serviceRequest - * method that services one request. Start the server by executing: - *
    - *      new MyServerClass().startServer(port);
    - * 
    - */ -public class NetworkServer implements Runnable, Cloneable { - /** Socket for communicating with client. */ - public Socket clientSocket = null; - private Thread serverInstance; - private ServerSocket serverSocket; - - /** Stream for printing to the client. */ - public PrintStream clientOutput; - - /** Buffered stream for reading replies from client. */ - public InputStream clientInput; - - /** Close an open connection to the client. */ - public void close() throws IOException { - clientSocket.close(); - clientSocket = null; - clientInput = null; - clientOutput = null; - } - - /** Return client connection status */ - public boolean clientIsOpen() { - return clientSocket != null; - } - - public final void run() { - if (serverSocket != null) { - Thread.currentThread().setPriority(Thread.MAX_PRIORITY); - // System.out.print("Server starts " + serverSocket + "\n"); - while (true) { - try { - Socket ns = serverSocket.accept(); -// System.out.print("New connection " + ns + "\n"); - NetworkServer n = (NetworkServer)clone(); - n.serverSocket = null; - n.clientSocket = ns; - new Thread(null, n, "NetworkServer", 0, false).start(); - } catch(Exception e) { - System.out.print("Server failure\n"); - e.printStackTrace(); - try { - serverSocket.close(); - } catch(IOException e2) {} - System.out.print("cs="+serverSocket+"\n"); - break; - } - } -// close(); - } else { - try { - clientOutput = new PrintStream( - new BufferedOutputStream(clientSocket.getOutputStream()), - false, "ISO8859_1"); - clientInput = new BufferedInputStream(clientSocket.getInputStream()); - serviceRequest(); - // System.out.print("Service handler exits - // "+clientSocket+"\n"); - } catch(Exception e) { - // System.out.print("Service handler failure\n"); - // e.printStackTrace(); - } - try { - close(); - } catch(IOException e2) {} - } - } - - /** Start a server on port port. It will call serviceRequest() - for each new connection. */ - public final void startServer(int port) throws IOException { - serverSocket = new ServerSocket(port, 50); - serverInstance = new Thread(null, this, "NetworkServer", 0, false); - serverInstance.start(); - } - - /** Service one request. It is invoked with the clientInput and - clientOutput streams initialized. This method handles one client - connection. When it is done, it can simply exit. The default - server just echoes it's input. It is invoked in it's own private - thread. */ - public void serviceRequest() throws IOException { - byte buf[] = new byte[300]; - int n; - clientOutput.print("Echo server " + getClass().getName() + "\n"); - clientOutput.flush(); - while ((n = clientInput.read(buf, 0, buf.length)) >= 0) { - clientOutput.write(buf, 0, n); - } - } - - public static void main(String argv[]) { - try { - new NetworkServer ().startServer(8888); - } catch (IOException e) { - System.out.print("Server failed: "+e+"\n"); - } - } - - /** - * Clone this object; - */ - public Object clone() { - try { - return super.clone(); - } catch (CloneNotSupportedException e) { - // this shouldn't happen, since we are Cloneable - throw new InternalError(e); - } - } - - public NetworkServer () { - } -} diff -r 565d54ca1f41 -r 49b4e7203b4b src/java.base/share/classes/sun/net/URLCanonicalizer.java --- a/src/java.base/share/classes/sun/net/URLCanonicalizer.java Fri Jul 06 09:27:32 2018 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,129 +0,0 @@ -/* - * Copyright (c) 1996, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.net; - -/** - * Helper class to map URL "abbreviations" to real URLs. - * The default implementation supports the following mappings: - *
    {@code
    - *   ftp.mumble.bar/... => ftp://ftp.mumble.bar/...
    - *   gopher.mumble.bar/... => gopher://gopher.mumble.bar/...
    - *   other.name.dom/... => http://other.name.dom/...
    - *   /foo/... => file:/foo/...
    - * }
    - * - * Full URLs (those including a protocol name) are passed through unchanged. - * - * Subclassers can override or extend this behavior to support different - * or additional canonicalization policies. - * - * @author Steve Byrne - */ - -public class URLCanonicalizer { - /** - * Creates the default canonicalizer instance. - */ - public URLCanonicalizer() { } - - /** - * Given a possibly abbreviated URL (missing a protocol name, typically), - * this method's job is to transform that URL into a canonical form, - * by including a protocol name and additional syntax, if necessary. - * - * For a correctly formed URL, this method should just return its argument. - */ - public String canonicalize(String simpleURL) { - String resultURL = simpleURL; - if (simpleURL.startsWith("ftp.")) { - resultURL = "ftp://" + simpleURL; - } else if (simpleURL.startsWith("gopher.")) { - resultURL = "gopher://" + simpleURL; - } else if (simpleURL.startsWith("/")) { - resultURL = "file:" + simpleURL; - } else if (!hasProtocolName(simpleURL)) { - if (isSimpleHostName(simpleURL)) { - simpleURL = "www." + simpleURL + ".com"; - } - resultURL = "http://" + simpleURL; - } - - return resultURL; - } - - /** - * Given a possibly abbreviated URL, this predicate function returns - * true if it appears that the URL contains a protocol name - */ - public boolean hasProtocolName(String url) { - int index = url.indexOf(':'); - if (index <= 0) { // treat ":foo" as not having a protocol spec - return false; - } - - for (int i = 0; i < index; i++) { - char c = url.charAt(i); - - // REMIND: this is a guess at legal characters in a protocol -- - // need to be verified - if ((c >= 'A' && c <= 'Z') - || (c >= 'a' && c <= 'z') - || (c == '-')) { - continue; - } - - // found an illegal character - return false; - } - - return true; - } - - /** - * Returns true if the URL is just a single name, no periods or - * slashes, false otherwise - **/ - protected boolean isSimpleHostName(String url) { - - for (int i = 0; i < url.length(); i++) { - char c = url.charAt(i); - - // REMIND: this is a guess at legal characters in a protocol -- - // need to be verified - if ((c >= 'A' && c <= 'Z') - || (c >= 'a' && c <= 'z') - || (c >= '0' && c <= '9') - || (c == '-')) { - continue; - } - - // found an illegal character - return false; - } - - return true; - } -} diff -r 565d54ca1f41 -r 49b4e7203b4b src/java.base/unix/classes/sun/nio/ch/UnixAsynchronousSocketChannelImpl.java --- a/src/java.base/unix/classes/sun/nio/ch/UnixAsynchronousSocketChannelImpl.java Fri Jul 06 09:27:32 2018 -0400 +++ b/src/java.base/unix/classes/sun/nio/ch/UnixAsynchronousSocketChannelImpl.java Fri Jul 06 09:29:17 2018 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -273,6 +273,7 @@ // invoke handler and set result CompletionHandler handler = connectHandler; + connectHandler = null; Object att = connectAttachment; PendingFuture future = connectFuture; if (handler == null) { @@ -405,6 +406,7 @@ this.readBuffer = null; this.readBuffers = null; this.readAttachment = null; + this.readHandler = null; // allow another read to be initiated enableReading(); @@ -600,6 +602,7 @@ this.writeBuffer = null; this.writeBuffers = null; this.writeAttachment = null; + this.writeHandler = null; // allow another write to be initiated enableWriting(); diff -r 565d54ca1f41 -r 49b4e7203b4b src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/CommandProcessor.java --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/CommandProcessor.java Fri Jul 06 09:27:32 2018 -0400 +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/CommandProcessor.java Fri Jul 06 09:29:17 2018 -0400 @@ -50,7 +50,6 @@ import sun.jvm.hotspot.debugger.OopHandle; import sun.jvm.hotspot.classfile.ClassLoaderDataGraph; import sun.jvm.hotspot.memory.FileMapInfo; -import sun.jvm.hotspot.memory.SymbolTable; import sun.jvm.hotspot.memory.SystemDictionary; import sun.jvm.hotspot.memory.Universe; import sun.jvm.hotspot.gc.shared.CollectedHeap; @@ -628,35 +627,6 @@ } } }, - new Command("symboltable", "symboltable name", false) { - public void doit(Tokens t) { - if (t.countTokens() != 1) { - usage(); - } else { - out.println(SymbolTable.getTheTable().probe(t.nextToken())); - } - } - }, - new Command("symboldump", "symboldump", false) { - public void doit(Tokens t) { - SymbolTable theTable = SymbolTable.getTheTable(); - theTable.symbolsDo(new SymbolTable.SymbolVisitor() { - public void visit(Symbol sym) { - sym.printValueOn(out); - out.println(); - } - }); - CompactHashTable sharedTable = theTable.getSharedTable(); - if (sharedTable != null) { - sharedTable.symbolsDo(new CompactHashTable.SymbolVisitor() { - public void visit(Symbol sym) { - sym.printValueOn(out); - out.println(); - } - }); - } - } - }, new Command("flags", "flags [ flag | -nd ]", false) { public void doit(Tokens t) { int tokens = t.countTokens(); diff -r 565d54ca1f41 -r 49b4e7203b4b src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/classfile/ClassLoaderData.java --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/classfile/ClassLoaderData.java Fri Jul 06 09:27:32 2018 -0400 +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/classfile/ClassLoaderData.java Fri Jul 06 09:29:17 2018 -0400 @@ -92,9 +92,9 @@ public Klass getKlasses() { return (Klass)klassesField.getValue(this); } /** Lookup an already loaded class. If not found null is returned. */ - public Klass find(Symbol className) { + public Klass find(String className) { for (Klass l = getKlasses(); l != null; l = l.getNextLinkKlass()) { - if (className.equals(l.getName())) { + if (l.getName().equals(className)) { return l; } } diff -r 565d54ca1f41 -r 49b4e7203b4b src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/classfile/ClassLoaderDataGraph.java --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/classfile/ClassLoaderDataGraph.java Fri Jul 06 09:27:32 2018 -0400 +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/classfile/ClassLoaderDataGraph.java Fri Jul 06 09:29:17 2018 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -55,10 +55,8 @@ /** Lookup an already loaded class in any class loader. */ public Klass find(String className) { - Symbol sym = VM.getVM().getSymbolTable().probe(className); - if (sym == null) return null; for (ClassLoaderData cld = getClassLoaderGraphHead(); cld != null; cld = cld.next()) { - Klass k = cld.find(sym); + Klass k = cld.find(className); if (k != null) { return k; } diff -r 565d54ca1f41 -r 49b4e7203b4b src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/AltHashing.java --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/AltHashing.java Fri Jul 06 09:27:32 2018 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.memory; - -public class AltHashing { - public static long murmur3_32(long seed, byte[] data) { - long h1 = seed; - int len = data.length; - int count = len; - - int offset = 0; - - // body - while (count >= 4) { - long k1 = (data[offset] & 0x0FF) - | (data[offset + 1] & 0x0FF) << 8 - | (data[offset + 2] & 0x0FF) << 16 - | data[offset + 3] << 24; - - count -= 4; - offset += 4; - - k1 *= 0xcc9e2d51; - k1 = Integer.rotateLeft((int)k1, 15); - k1 *= 0x1b873593; - k1 &= 0xFFFFFFFFL; - - h1 ^= k1; - h1 = Integer.rotateLeft((int)h1, 13); - h1 = h1 * 5 + 0xe6546b64; - h1 &= 0xFFFFFFFFL; - } - - //tail - if (count > 0) { - long k1 = 0; - - switch (count) { - case 3: - k1 ^= (data[offset + 2] & 0xff) << 16; - // fall through - case 2: - k1 ^= (data[offset + 1] & 0xff) << 8; - // fall through - case 1: - k1 ^= (data[offset] & 0xff); - // fall through - default: - k1 *= 0xcc9e2d51; - k1 = Integer.rotateLeft((int)k1, 15); - k1 *= 0x1b873593; - k1 &= 0xFFFFFFFFL; - h1 ^= k1; - h1 &= 0xFFFFFFFFL; - } - } - - // finalization - h1 ^= len; - - // finalization mix force all bits of a hash block to avalanche - h1 ^= h1 >> 16; - h1 *= 0x85ebca6b; - h1 &= 0xFFFFFFFFL; - h1 ^= h1 >> 13; - h1 *= 0xc2b2ae35; - h1 &= 0xFFFFFFFFL; - h1 ^= h1 >> 16; - - return h1 & 0xFFFFFFFFL; - } -} diff -r 565d54ca1f41 -r 49b4e7203b4b src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/SymbolTable.java --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/SymbolTable.java Fri Jul 06 09:27:32 2018 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,155 +0,0 @@ -/* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.memory; - -import java.io.*; -import java.util.*; -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.oops.*; -import sun.jvm.hotspot.types.*; -import sun.jvm.hotspot.runtime.*; -import sun.jvm.hotspot.utilities.*; - -public class SymbolTable extends sun.jvm.hotspot.utilities.Hashtable { - static { - VM.registerVMInitializedObserver(new Observer() { - public void update(Observable o, Object data) { - initialize(VM.getVM().getTypeDataBase()); - } - }); - } - - private static synchronized void initialize(TypeDataBase db) { - Type type = db.lookupType("SymbolTable"); - theTableField = type.getAddressField("_the_table"); - sharedTableField = type.getAddressField("_shared_table"); - type = db.lookupType("RehashableSymbolHashtable"); - seedField = type.getCIntegerField("_seed"); - } - - // Fields - private static AddressField theTableField; - private static AddressField sharedTableField; - private static CIntegerField seedField; - - private CompactHashTable sharedTable; - - // Accessors - public static SymbolTable getTheTable() { - Address tmp = theTableField.getValue(); - SymbolTable table = (SymbolTable) VMObjectFactory.newObject(SymbolTable.class, tmp); - Address shared = sharedTableField.getStaticFieldAddress(); - table.sharedTable = (CompactHashTable)VMObjectFactory.newObject(CompactHashTable.class, shared); - return table; - } - - public CompactHashTable getSharedTable() { - return sharedTable; - } - - public static long getSeed() { - return (long) seedField.getValue(); - } - - public static boolean useAlternateHashcode() { - if (getSeed() != 0) { - return true; - } - return false; - } - - public SymbolTable(Address addr) { - super(addr); - } - - /** Clone of VM's "temporary" probe routine, as the SA currently - does not support mutation so lookup() would have no effect - anyway. Returns null if the given string is not in the symbol - table. */ - public Symbol probe(String name) { - try { - return probe(toModifiedUTF8Bytes(name)); - } catch (IOException e) { - return null; - } - } - - /** Clone of VM's "temporary" probe routine, as the SA currently - does not support mutation so lookup() would have no effect - anyway. Searches the regular symbol table and the shared symbol - table. Null is returned if the given name is not found in both - tables. */ - public Symbol probe(byte[] name) { - long hashValue = hashSymbol(name); - - // shared table does not use alternate hashing algorithm, - // it always uses the same original hash code. - Symbol s = sharedTable.probe(name, hashValue); - if (s != null) { - return s; - } - - if (useAlternateHashcode()) { - hashValue = AltHashing.murmur3_32(getSeed(), name); - } - - for (HashtableEntry e = (HashtableEntry) bucket(hashToIndex(hashValue)); e != null; e = (HashtableEntry) e.next()) { - if (e.hash() == hashValue) { - Symbol sym = Symbol.create(e.literalValue()); - if (sym.equals(name)) { - return sym; - } - } - } - - return null; - } - - public interface SymbolVisitor { - public void visit(Symbol sym); - } - - public void symbolsDo(SymbolVisitor visitor) { - int numBuckets = tableSize(); - for (int i = 0; i < numBuckets; i++) { - for (HashtableEntry e = (HashtableEntry) bucket(i); e != null; - e = (HashtableEntry) e.next()) { - visitor.visit(Symbol.create(e.literalValue())); - } - } - } - - private static byte[] toModifiedUTF8Bytes(String name) throws IOException { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - DataOutputStream dos = new DataOutputStream(baos); - dos.writeUTF(name); - dos.flush(); - byte[] buf = baos.toByteArray(); - byte[] res = new byte[buf.length - 2]; - // skip the length part - System.arraycopy(buf, 2, res, 0, res.length); - return res; - } -} diff -r 565d54ca1f41 -r 49b4e7203b4b src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ArrayKlass.java --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ArrayKlass.java Fri Jul 06 09:27:32 2018 -0400 +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ArrayKlass.java Fri Jul 06 09:29:17 2018 -0400 @@ -72,27 +72,27 @@ public Klass getLowerDimension() { return (Klass) lowerDimension.getValue(this); } // constant class names - javaLangCloneable, javaIoSerializable, javaLangObject - // Initialized lazily to avoid initialization ordering dependencies between ArrayKlass and SymbolTable - private static Symbol javaLangCloneableName; - private static Symbol javaLangObjectName; - private static Symbol javaIoSerializableName; - private static Symbol javaLangCloneableName() { + // Initialized lazily to avoid initialization ordering dependencies between ArrayKlass and String + private static String javaLangCloneableName; + private static String javaLangObjectName; + private static String javaIoSerializableName; + private static String javaLangCloneableName() { if (javaLangCloneableName == null) { - javaLangCloneableName = VM.getVM().getSymbolTable().probe("java/lang/Cloneable"); + javaLangCloneableName = "java/lang/Cloneable"; } return javaLangCloneableName; } - private static Symbol javaLangObjectName() { + private static String javaLangObjectName() { if (javaLangObjectName == null) { - javaLangObjectName = VM.getVM().getSymbolTable().probe("java/lang/Object"); + javaLangObjectName = "java/lang/Object"; } return javaLangObjectName; } - private static Symbol javaIoSerializableName() { + private static String javaIoSerializableName() { if (javaIoSerializableName == null) { - javaIoSerializableName = VM.getVM().getSymbolTable().probe("java/io/Serializable"); + javaIoSerializableName = "java/io/Serializable"; } return javaIoSerializableName; } diff -r 565d54ca1f41 -r 49b4e7203b4b src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ConstantPool.java --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ConstantPool.java Fri Jul 06 09:27:32 2018 -0400 +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ConstantPool.java Fri Jul 06 09:29:17 2018 -0400 @@ -355,7 +355,7 @@ if (klass.isArrayKlass()) { klass = klass.getJavaSuper(); } - return ((InstanceKlass)klass).findMethod(name, sig); + return ((InstanceKlass)klass).findMethod(name.asString(), sig.asString()); } // returns null, if not resolved. @@ -364,7 +364,7 @@ if (klass == null) return null; Symbol name = getNameRefAt(which); Symbol sig = getSignatureRefAt(which); - return klass.findField(name, sig); + return klass.findField(name.asString(), sig.asString()); } public int getNameAndTypeRefIndexAt(int index) { diff -r 565d54ca1f41 -r 49b4e7203b4b src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Field.java --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Field.java Fri Jul 06 09:27:32 2018 -0400 +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Field.java Fri Jul 06 09:29:17 2018 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,7 +47,7 @@ offset = holder.getFieldOffset(fieldIndex); genericSignature = holder.getFieldGenericSignature(fieldIndex); - Symbol name = holder.getFieldName(fieldIndex); + name = holder.getFieldName(fieldIndex); id = new NamedFieldIdentifier(name.asString()); signature = holder.getFieldSignature(fieldIndex); @@ -57,6 +57,7 @@ accessFlags = new AccessFlags(access); } + private Symbol name; private long offset; private FieldIdentifier id; private boolean isVMField; @@ -74,6 +75,8 @@ /** Returns the identifier of the field */ public FieldIdentifier getID() { return id; } + public Symbol getName() { return name; } + /** Indicates whether this is a VM field */ public boolean isVMField() { return isVMField; } diff -r 565d54ca1f41 -r 49b4e7203b4b src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java Fri Jul 06 09:27:32 2018 -0400 +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java Fri Jul 06 09:29:17 2018 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -729,12 +729,12 @@ } /** Field access by name. */ - public Field findLocalField(Symbol name, Symbol sig) { + public Field findLocalField(String name, String sig) { int length = getJavaFieldsCount(); for (int i = 0; i < length; i++) { Symbol f_name = getFieldName(i); Symbol f_sig = getFieldSignature(i); - if (name.equals(f_name) && sig.equals(f_sig)) { + if (f_name.equals(name) && f_sig.equals(sig)) { return newField(i); } } @@ -743,14 +743,14 @@ } /** Find field in direct superinterfaces. */ - public Field findInterfaceField(Symbol name, Symbol sig) { + public Field findInterfaceField(String name, String sig) { KlassArray interfaces = getLocalInterfaces(); int n = interfaces.length(); for (int i = 0; i < n; i++) { InstanceKlass intf1 = (InstanceKlass) interfaces.getAt(i); if (Assert.ASSERTS_ENABLED) { Assert.that(intf1.isInterface(), "just checking type"); - } + } // search for field in current interface Field f = intf1.findLocalField(name, sig); if (f != null) { @@ -769,7 +769,7 @@ /** Find field according to JVM spec 5.4.3.2, returns the klass in which the field is defined. */ - public Field findField(Symbol name, Symbol sig) { + public Field findField(String name, String sig) { // search order according to newest JVM spec (5.4.3.2, p.167). // 1) search for field in current klass Field f = findLocalField(name, sig); @@ -788,18 +788,6 @@ } /** Find field according to JVM spec 5.4.3.2, returns the klass in - which the field is defined (convenience routine) */ - public Field findField(String name, String sig) { - SymbolTable symbols = VM.getVM().getSymbolTable(); - Symbol nameSym = symbols.probe(name); - Symbol sigSym = symbols.probe(sig); - if (nameSym == null || sigSym == null) { - return null; - } - return findField(nameSym, sigSym); - } - - /** Find field according to JVM spec 5.4.3.2, returns the klass in which the field is defined (retained only for backward compatibility with jdbx) */ public Field findFieldDbg(String name, String sig) { @@ -932,20 +920,8 @@ return "L" + super.signature() + ";"; } - /** Convenience routine taking Strings; lookup is done in - SymbolTable. */ + /** Find method in vtable. */ public Method findMethod(String name, String sig) { - SymbolTable syms = VM.getVM().getSymbolTable(); - Symbol nameSym = syms.probe(name); - Symbol sigSym = syms.probe(sig); - if (nameSym == null || sigSym == null) { - return null; - } - return findMethod(nameSym, sigSym); - } - - /** Find method in vtable. */ - public Method findMethod(Symbol name, Symbol sig) { return findMethod(getMethods(), name, sig); } @@ -1055,56 +1031,16 @@ throw new RuntimeException("Illegal field type at index " + index); } - private static Method findMethod(MethodArray methods, Symbol name, Symbol signature) { - int len = methods.length(); - // methods are sorted, so do binary search - int l = 0; - int h = len - 1; - while (l <= h) { - int mid = (l + h) >> 1; - Method m = methods.at(mid); - long res = m.getName().fastCompare(name); - if (res == 0) { - // found matching name; do linear search to find matching signature - // first, quick check for common case - if (m.getSignature().equals(signature)) return m; - // search downwards through overloaded methods - int i; - for (i = mid - 1; i >= l; i--) { - Method m1 = methods.at(i); - if (!m1.getName().equals(name)) break; - if (m1.getSignature().equals(signature)) return m1; - } - // search upwards - for (i = mid + 1; i <= h; i++) { - Method m1 = methods.at(i); - if (!m1.getName().equals(name)) break; - if (m1.getSignature().equals(signature)) return m1; - } - // not found - if (Assert.ASSERTS_ENABLED) { - int index = linearSearch(methods, name, signature); - if (index != -1) { - throw new DebuggerException("binary search bug: should have found entry " + index); - } - } - return null; - } else if (res < 0) { - l = mid + 1; - } else { - h = mid - 1; - } + private static Method findMethod(MethodArray methods, String name, String signature) { + int index = linearSearch(methods, name, signature); + if (index != -1) { + return methods.at(index); + } else { + return null; } - if (Assert.ASSERTS_ENABLED) { - int index = linearSearch(methods, name, signature); - if (index != -1) { - throw new DebuggerException("binary search bug: should have found entry " + index); - } - } - return null; } - private static int linearSearch(MethodArray methods, Symbol name, Symbol signature) { + private static int linearSearch(MethodArray methods, String name, String signature) { int len = (int) methods.length(); for (int index = 0; index < len; index++) { Method m = methods.at(index); diff -r 565d54ca1f41 -r 49b4e7203b4b src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Method.java --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Method.java Fri Jul 06 09:27:32 2018 -0400 +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Method.java Fri Jul 06 09:29:17 2018 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -93,18 +93,18 @@ // constant method names - , - // Initialized lazily to avoid initialization ordering dependencies between Method and SymbolTable - private static Symbol objectInitializerName; - private static Symbol classInitializerName; - private static Symbol objectInitializerName() { + // Initialized lazily to avoid initialization ordering dependencies between ArrayKlass and String + private static String objectInitializerName; + private static String classInitializerName; + private static String objectInitializerName() { if (objectInitializerName == null) { - objectInitializerName = VM.getVM().getSymbolTable().probe(""); + objectInitializerName = ""; } return objectInitializerName; } - private static Symbol classInitializerName() { + private static String classInitializerName() { if (classInitializerName == null) { - classInitializerName = VM.getVM().getSymbolTable().probe(""); + classInitializerName = ""; } return classInitializerName; } diff -r 565d54ca1f41 -r 49b4e7203b4b src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Symbol.java --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Symbol.java Fri Jul 06 09:27:32 2018 -0400 +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Symbol.java Fri Jul 06 09:29:17 2018 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -106,6 +106,10 @@ return true; } + public boolean equals(String string) { + return asString().equals(string); + } + public byte[] asByteArray() { int length = (int) getLength(); byte [] result = new byte [length]; diff -r 565d54ca1f41 -r 49b4e7203b4b src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/VM.java --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/VM.java Fri Jul 06 09:27:32 2018 -0400 +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/VM.java Fri Jul 06 09:29:17 2018 -0400 @@ -78,7 +78,6 @@ private long logAddressSize; private Universe universe; private ObjectHeap heap; - private SymbolTable symbols; private SystemDictionary dict; private ClassLoaderDataGraph cldGraph; private Threads threads; @@ -647,13 +646,6 @@ return heap; } - public SymbolTable getSymbolTable() { - if (symbols == null) { - symbols = SymbolTable.getTheTable(); - } - return symbols; - } - public SystemDictionary getSystemDictionary() { if (dict == null) { dict = new SystemDictionary(); diff -r 565d54ca1f41 -r 49b4e7203b4b src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/AbstractHeapGraphWriter.java --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/AbstractHeapGraphWriter.java Fri Jul 06 09:27:32 2018 -0400 +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/AbstractHeapGraphWriter.java Fri Jul 06 09:29:17 2018 -0400 @@ -43,10 +43,9 @@ public abstract class AbstractHeapGraphWriter implements HeapGraphWriter { // the function iterates heap and calls Oop type specific writers protected void write() throws IOException { - SymbolTable symTbl = VM.getVM().getSymbolTable(); - javaLangClass = symTbl.probe("java/lang/Class"); - javaLangString = symTbl.probe("java/lang/String"); - javaLangThread = symTbl.probe("java/lang/Thread"); + javaLangClass = "java/lang/Class"; + javaLangString = "java/lang/String"; + javaLangThread = "java/lang/Thread"; ObjectHeap heap = VM.getVM().getObjectHeap(); try { heap.iterate(new DefaultHeapVisitor() { @@ -458,7 +457,7 @@ } } - protected Symbol javaLangClass; - protected Symbol javaLangString; - protected Symbol javaLangThread; + protected String javaLangClass; + protected String javaLangString; + protected String javaLangThread; } diff -r 565d54ca1f41 -r 49b4e7203b4b src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java Fri Jul 06 09:27:32 2018 -0400 +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java Fri Jul 06 09:29:17 2018 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -309,6 +309,9 @@ public class HeapHprofBinWriter extends AbstractHeapGraphWriter { + // Record which Symbol names have been dumped already. + private HashSet names; + private static final long HPROF_SEGMENTED_HEAP_DUMP_THRESHOLD = 2L * 0x40000000; // The approximate size of a heap segment. Used to calculate when to create @@ -381,6 +384,7 @@ public HeapHprofBinWriter() { this.KlassMap = new ArrayList(); + this.names = new HashSet(); } public synchronized void write(String fileName) throws IOException { @@ -391,7 +395,6 @@ VM vm = VM.getVM(); dbg = vm.getDebugger(); objectHeap = vm.getObjectHeap(); - symTbl = vm.getSymbolTable(); OBJ_ID_SIZE = (int) vm.getOopSize(); @@ -745,6 +748,11 @@ } else { lineNumber = m.getLineNumberFromBCI(bci); } + // First dump UTF8 if needed + writeSymbol(m.getName()); // method's name + writeSymbol(m.getSignature()); // method's signature + writeSymbol(m.getMethodHolder().getSourceFileName()); // source file name + // Then write FRAME descriptor writeHeader(HPROF_FRAME, 4 * (int)VM.getVM().getOopSize() + 2 * (int)INT_SIZE); writeObjectID(frameSN); // frame serial number writeSymbolID(m.getName()); // method's name @@ -955,7 +963,7 @@ out.writeShort((short) fields.size()); for (Iterator itr = fields.iterator(); itr.hasNext();) { Field field = (Field) itr.next(); - Symbol name = symTbl.probe(field.getID().getName()); + Symbol name = field.getName(); writeSymbolID(name); char typeCode = (char) field.getSignature().getByteAt(0); int kind = signatureToHprofKind(typeCode); @@ -1049,27 +1057,44 @@ out.writeInt(0); } + private void writeClassSymbols(Klass k) throws IOException { + writeSymbol(k.getName()); + if (k instanceof InstanceKlass) { + InstanceKlass ik = (InstanceKlass) k; + List declaredFields = ik.getImmediateFields(); + for (Iterator itr = declaredFields.iterator(); itr.hasNext();) { + Field field = (Field) itr.next(); + writeSymbol(field.getName()); + } + } + } + private void writeSymbols() throws IOException { + // Write all the symbols that are used by the classes + ClassLoaderDataGraph cldGraph = VM.getVM().getClassLoaderDataGraph(); try { - symTbl.symbolsDo(new SymbolTable.SymbolVisitor() { - public void visit(Symbol sym) { - try { - writeSymbol(sym); - } catch (IOException exp) { - throw new RuntimeException(exp); - } - } - }); + cldGraph.classesDo(new ClassLoaderDataGraph.ClassVisitor() { + public void visit(Klass k) { + try { + writeClassSymbols(k); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + }); } catch (RuntimeException re) { handleRuntimeException(re); } } private void writeSymbol(Symbol sym) throws IOException { - byte[] buf = sym.asString().getBytes("UTF-8"); - writeHeader(HPROF_UTF8, buf.length + OBJ_ID_SIZE); - writeSymbolID(sym); - out.write(buf); + // If name is already written don't write it again. + if (names.add(sym)) { + byte[] buf = sym.asString().getBytes("UTF-8"); + writeHeader(HPROF_UTF8, buf.length + OBJ_ID_SIZE); + writeSymbolID(sym); + out.write(buf); + } } private void writeClasses() throws IOException { @@ -1118,6 +1143,7 @@ } private void writeSymbolID(Symbol sym) throws IOException { + assert names.contains(sym); writeObjectID(getAddressValue(sym.getAddress())); } @@ -1195,7 +1221,6 @@ private FileOutputStream fos; private Debugger dbg; private ObjectHeap objectHeap; - private SymbolTable symTbl; private ArrayList KlassMap; // oopSize of the debuggee diff -r 565d54ca1f41 -r 49b4e7203b4b src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/ObjectReader.java --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/ObjectReader.java Fri Jul 06 09:27:32 2018 -0400 +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/ObjectReader.java Fri Jul 06 09:29:17 2018 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -135,39 +135,35 @@ } } - protected Symbol javaLangString; - protected Symbol javaUtilHashtableEntry; - protected Symbol javaUtilHashtable; - protected Symbol javaUtilProperties; + protected String javaLangString; + protected String javaUtilHashtableEntry; + protected String javaUtilHashtable; + protected String javaUtilProperties; - protected Symbol getVMSymbol(String name) { - return VM.getVM().getSymbolTable().probe(name); - } - - protected Symbol javaLangString() { + protected String javaLangString() { if (javaLangString == null) { - javaLangString = getVMSymbol("java/lang/String"); + javaLangString = "java/lang/String"; } return javaLangString; } - protected Symbol javaUtilHashtableEntry() { + protected String javaUtilHashtableEntry() { if (javaUtilHashtableEntry == null) { - javaUtilHashtableEntry = getVMSymbol("java/util/Hashtable$Entry"); + javaUtilHashtableEntry = "java/util/Hashtable$Entry"; } return javaUtilHashtableEntry; } - protected Symbol javaUtilHashtable() { + protected String javaUtilHashtable() { if (javaUtilHashtable == null) { - javaUtilHashtable = getVMSymbol("java/util/Hashtable"); + javaUtilHashtable = "java/util/Hashtable"; } return javaUtilHashtable; } - protected Symbol javaUtilProperties() { + protected String javaUtilProperties() { if (javaUtilProperties == null) { - javaUtilProperties = getVMSymbol("java/util/Properties"); + javaUtilProperties = "java/util/Properties"; } return javaUtilProperties; } diff -r 565d54ca1f41 -r 49b4e7203b4b src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaFactoryImpl.java --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaFactoryImpl.java Fri Jul 06 09:27:32 2018 -0400 +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaFactoryImpl.java Fri Jul 06 09:29:17 2018 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -127,31 +127,27 @@ } // -- Internals only below this point - private Symbol javaLangString() { + private String javaLangString() { if (javaLangString == null) { - javaLangString = getSymbol("java/lang/String"); + javaLangString = "java/lang/String"; } return javaLangString; } - private Symbol javaLangThread() { + private String javaLangThread() { if (javaLangThread == null) { - javaLangThread = getSymbol("java/lang/Thread"); + javaLangThread = "java/lang/Thread"; } return javaLangThread; } - private Symbol javaLangClass() { + private String javaLangClass() { if (javaLangClass == null) { - javaLangClass = getSymbol("java/lang/Class"); + javaLangClass = "java/lang/Class"; } return javaLangClass; } - private Symbol getSymbol(String str) { - return VM.getVM().getSymbolTable().probe(str); - } - private JSJavaObject newJavaInstance(Instance instance) { // look for well-known classes Symbol className = instance.getKlass().getName(); @@ -196,7 +192,7 @@ // Map> private Map om = new HashMap(); - private Symbol javaLangString; - private Symbol javaLangThread; - private Symbol javaLangClass; + private String javaLangString; + private String javaLangThread; + private String javaLangClass; } diff -r 565d54ca1f41 -r 49b4e7203b4b src/jdk.javadoc/share/classes/jdk/javadoc/internal/api/package-info.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/api/package-info.java Fri Jul 06 09:29:17 2018 -0400 @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * This package provides the javadoc implementation of relevant + * public API defined in {@link javax.tools}, which provides an + * API alternative to invoking javadoc via the command line. + * + *

    This is NOT part of any supported API. + * If you write code that depends on this, you do so at your own risk. + * This code and its internal interfaces are subject to change or + * deletion without notice. + */ +package jdk.javadoc.internal.api; diff -r 565d54ca1f41 -r 49b4e7203b4b src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/package-info.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/package-info.java Fri Jul 06 09:27:32 2018 -0400 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/package-info.java Fri Jul 06 09:29:17 2018 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. * 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,17 +24,18 @@ */ /** - * This package contains classes that create and write HTML markup tags. + * This package contains classes that create and write HTML markup tags. * - * The primary low level classes are {@link HtmlTree} and subtypes - * of {@code Content}. In addition, there are mid-level builders - * like {@link TableHeader} and {@link Table} to help build more - * complex HTML trees. + *

    The primary low level classes are + * {@link jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree HtmlTree} + * and other subtypes of {@code Content}. In addition, there are mid-level builders + * like {@link jdk.javadoc.internal.doclets.formats.html.markup.TableHeader TableHeader} + * and {@link jdk.javadoc.internal.doclets.formats.html.markup.Table Table} + * to help build more complex HTML trees. * *

    This is NOT part of any supported API. * If you write code that depends on this, you do so at your own risk. * This code and its internal interfaces are subject to change or * deletion without notice. */ - package jdk.javadoc.internal.doclets.formats.html.markup; diff -r 565d54ca1f41 -r 49b4e7203b4b src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/package-info.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/package-info.java Fri Jul 06 09:29:17 2018 -0400 @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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. + */ + + +/** + * The set of low-level file-formats, to be used in conjunction with + * the {@link jdk.javadoc.internal.doclets.toolkit doclets.toolkit} API. + * + *

    Currently, only {@link jdk.javadoc.internal.doclets.formats.html HTML} + * format is supported. + * + *

    This is NOT part of any supported API. + * If you write code that depends on this, you do so at your own risk. + * This code and its internal interfaces are subject to change or + * deletion without notice. + */ +package jdk.javadoc.internal.doclets.formats; diff -r 565d54ca1f41 -r 49b4e7203b4b src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/package-info.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/package-info.java Fri Jul 06 09:27:32 2018 -0400 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/package-info.java Fri Jul 06 09:29:17 2018 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,10 +24,25 @@ */ /** -

    This is NOT part of any supported API. - If you write code that depends on this, you do so at your own risk. - This code and its internal interfaces are subject to change or - deletion without notice. + * Doclets provide the user-selectable backends for processing the + * documentation comnments in Java source code. + * + *

    Doclets are implementations of the {@link jdk.javadoc.doclet Doclet API}.

    + * + *

    Currently, there is only one supported doclet, the + * {@link jdk.javadoc.internal.doclets.formats.html.HtmlDoclet HtmlDoclet}, + * for writing API documentation in HTML. Nevertheless, in order to + * separate the high-level code for the general content of each page + * from the low-level details of how to write such content, the code is + * organized in two sections: a format-neutral + * {@link jdk.javadoc.internal.doclets.toolkit toolkit API}, + * and a specific {@link jdk.javadoc.internal.doclets.formats format}, + * such as {@link jdk.javadoc.internal.doclets.formats.html HTML format}. + * + *

    This is NOT part of any supported API. + * If you write code that depends on this, you do so at your own risk. + * This code and its internal interfaces are subject to change or + * deletion without notice. */ package jdk.javadoc.internal.doclets; diff -r 565d54ca1f41 -r 49b4e7203b4b src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/package-info.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/package-info.java Fri Jul 06 09:27:32 2018 -0400 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/package-info.java Fri Jul 06 09:29:17 2018 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. * 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,17 +24,17 @@ */ /** - This doclet-independent package has a set of classes and - interfaces that are the building blocks for doclets. They - define the basic structure of doclets and make doclet - writing much easier because they provide the content generation - code to be shared among different doclets. Builders only provide - the structure and content of API documentation. - They will not provide any style markup. - -

    This is NOT part of any supported API. - If you write code that depends on this, you do so at your own risk. - This code and its internal interfaces are subject to change or - deletion without notice. -*/ + * This doclet-independent package has a set of classes and + * interfaces that are the building blocks for doclets. They + * define the basic structure of doclets and make doclet + * writing much easier because they provide the content generation + * code to be shared among different doclets. Builders only provide + * the structure and content of API documentation. + * They do not directly provide any style markup. + * + *

    This is NOT part of any supported API. + * If you write code that depends on this, you do so at your own risk. + * This code and its internal interfaces are subject to change or + * deletion without notice. + */ package jdk.javadoc.internal.doclets.toolkit.builders; diff -r 565d54ca1f41 -r 49b4e7203b4b src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/package-info.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/package-info.java Fri Jul 06 09:27:32 2018 -0400 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/package-info.java Fri Jul 06 09:29:17 2018 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. * 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,29 +24,28 @@ */ /** - This package has classes used to generate Javadoc tag documentation. - Doclets no longer have to implement its own version of standard tags - such as @param and @throws. This is the single, doclet - implementation of each standard tag that is shared by all - doclets. Each doclet must have a taglet writer that takes a taglet - as input and writes doclet-dependent output. The taglet itself will - do the tag processing. For example, suppose we are outputing - @throws tags. The taglet would: -

      -
    • Retrieve the list of throws tags to be documented. -
    • Replace {@inheritDoc} with the appropriate documentation. -
    • Add throws documentation for exceptions that are declared in - the signature of the method but - not documented with the throws tags. -
    - After doing the steps above, the taglet would pass the information to - the taglet writer for writing. The taglets are essentially builders for - tags. - -

    This is NOT part of any supported API. - If you write code that depends on this, you do so at your own risk. - This code and its internal interfaces are subject to change or - deletion without notice. -*/ - + * This package has classes used to generate output for Javadoc tags. + * + *

    Doclets no longer have to implement their own version of standard tags + * such as @param and @throws. Individual taglets provide + * common processing, independent of the output format. + * Each doclet must have a taglet writer that takes a taglet + * as input and writes doclet-dependent output. The taglet itself will + * do the tag processing. For example, suppose we are outputing + * @throws tags. The taglet would: + *

      + *
    • Retrieve the list of throws tags to be documented. + *
    • Replace {@inheritDoc} with the appropriate documentation. + *
    • Add throws documentation for exceptions that are declared in + * the signature of the method but not documented with the throws tags. + *
    + * After doing the steps above, the taglet would pass the information to + * the taglet writer for writing. The taglets are essentially builders for + * tags. + * + *

    This is NOT part of any supported API. + * If you write code that depends on this, you do so at your own risk. + * This code and its internal interfaces are subject to change or + * deletion without notice. + */ package jdk.javadoc.internal.doclets.toolkit.taglets; diff -r 565d54ca1f41 -r 49b4e7203b4b src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/links/LinkInfo.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/links/LinkInfo.java Fri Jul 06 09:27:32 2018 -0400 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/links/LinkInfo.java Fri Jul 06 09:29:17 2018 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,14 +33,14 @@ import jdk.javadoc.internal.doclets.toolkit.Content; /** - * Encapsulates information about a link. + * Encapsulates information about a link. * *

    This is NOT part of any supported API. * If you write code that depends on this, you do so at your own risk. * This code and its internal interfaces are subject to change or * deletion without notice. * - * @author Jamie Ho + * @author Jamie Ho */ public abstract class LinkInfo { diff -r 565d54ca1f41 -r 49b4e7203b4b src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/links/LinkOutput.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/links/LinkOutput.java Fri Jul 06 09:27:32 2018 -0400 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/links/LinkOutput.java Fri Jul 06 09:29:17 2018 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ package jdk.javadoc.internal.doclets.toolkit.util.links; /** - * Stores output of a link. + * Stores output of a link. * *

    This is NOT part of any supported API. * If you write code that depends on this, you do so at your own risk. diff -r 565d54ca1f41 -r 49b4e7203b4b src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/links/package-info.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/links/package-info.java Fri Jul 06 09:27:32 2018 -0400 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/links/package-info.java Fri Jul 06 09:29:17 2018 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. * 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,12 +24,11 @@ */ /** - Provides a factory for constructing links. - -

    This is NOT part of any supported API. - If you write code that depends on this, you do so at your own risk. - This code and its internal interfaces are subject to change or - deletion without notice. -*/ - + * Provides a factory for constructing links. + * + *

    This is NOT part of any supported API. + * If you write code that depends on this, you do so at your own risk. + * This code and its internal interfaces are subject to change or + * deletion without notice. + */ package jdk.javadoc.internal.doclets.toolkit.util.links; diff -r 565d54ca1f41 -r 49b4e7203b4b src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/package-info.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/package-info.java Fri Jul 06 09:27:32 2018 -0400 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/package-info.java Fri Jul 06 09:29:17 2018 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. * 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,13 +24,12 @@ */ /** - This package has utility classes that perform common services required - for API documentation generation. - -

    This is NOT part of any supported API. - If you write code that depends on this, you do so at your own risk. - This code and its internal interfaces are subject to change or - deletion without notice. -*/ - + * This package has utility classes that perform common services required + * for API documentation generation. + * + *

    This is NOT part of any supported API. + * If you write code that depends on this, you do so at your own risk. + * This code and its internal interfaces are subject to change or + * deletion without notice. + */ package jdk.javadoc.internal.doclets.toolkit.util; diff -r 565d54ca1f41 -r 49b4e7203b4b src/jdk.javadoc/share/classes/jdk/javadoc/internal/package-info.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/package-info.java Fri Jul 06 09:29:17 2018 -0400 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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. + */ + +/** + * The implementation of the javadoc tool, and associated doclets. + * + *

    Internally, javadoc is composed of two primary parts: + * the {@link jdk.javadoc.internal.tool tool}, and a series of + * {@link jdk.javadoc.internal.doclets doclets}. + * + * The tool provides a common infrastructure for command-line processing, + * and for reading the documentation comments in Java source files, + * while doclets provide a user-selectable backend for determining + * how to process the documentation comments. + * + *

    Historical Note: Prior to the introduction of the + * {@link javax.lang.model Language Model API} in JDK 6, it was + * not unusual to use the {@link com.sun.javadoc} API as a + * modeling API. But the Language Model API, and associated + * {@link javax.annotation.processing Annotation Processing API} + * provided a better way to model programs, and in JDK 9, + * javadoc itself was converted to using the Language Model API, + * with the {@code com.sun.javadoc API} being deprecated for + * eventual removal. + *

    + * + *

    This is NOT part of any supported API. + * If you write code that depends on this, you do so at your own risk. + * This code and its internal interfaces are subject to change or + * deletion without notice. + */ +package jdk.javadoc.internal; diff -r 565d54ca1f41 -r 49b4e7203b4b src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/package-info.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/package-info.java Fri Jul 06 09:29:17 2018 -0400 @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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. + */ + +/** + * Provides the front end for the javadoc tool. + * + *

    The main entry points are in {@link jdk.javadoc.internal.tool.Main} + * which calls the (poorly-named) {@link jdk.javadoc.internal.tool.Start} + * which provides the overall functionality of the tool. + * + *

    The classes provide a framework for processing command-line options + * and determining the set of elements (modules, packages, types and members) + * to be documented. + * + *

    The classes also provide the means to use the javac front end to read + * source files, including the documentation comments. + * + *

    Finally, once the appropriate files have been read, the classes invoke + * the selected doclet to process those files, typically to generate API + * documentation. + * + *

    This is NOT part of any supported API. + * If you write code that depends on this, you do so at your own risk. + * This code and its internal interfaces are subject to change or + * deletion without notice. + */ +package jdk.javadoc.internal.tool; diff -r 565d54ca1f41 -r 49b4e7203b4b test/hotspot/jtreg/runtime/SharedArchiveFile/SASymbolTableTest.java --- a/test/hotspot/jtreg/runtime/SharedArchiveFile/SASymbolTableTest.java Fri Jul 06 09:27:32 2018 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 SASymbolTableTest - * @summary Walk symbol table using SA, with and without CDS. - * @requires vm.cds & vm.hasSAandCanAttach - * @library /test/lib - * @modules java.base/jdk.internal.misc - * jdk.hotspot.agent/sun.jvm.hotspot.oops - * jdk.hotspot.agent/sun.jvm.hotspot.memory - * jdk.hotspot.agent/sun.jvm.hotspot.runtime - * jdk.hotspot.agent/sun.jvm.hotspot.tools - * java.management - * @build SASymbolTableTestAgent - * @run main SASymbolTableTest - */ - -import java.util.Arrays; -import java.util.List; -import jdk.test.lib.cds.CDSTestUtils; -import jdk.test.lib.process.ProcessTools; -import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.JDKToolFinder; -import jdk.test.lib.Platform; -import jdk.test.lib.apps.LingeredApp; - -/* - * The purpose of this test is to validate that we can use SA to - * attach a process and walk its SymbolTable, regardless whether - * the attachee process runs in CDS mode or not. - * - * SASymbolTableTest Just sets up the agent and attachee processes. - * The SymbolTable walking is done in the SASymbolTableTestAgent class. - */ -public class SASymbolTableTest { - static String jsaName = "./SASymbolTableTest.jsa"; - private static LingeredApp theApp = null; - - - public static void main(String[] args) throws Exception { - CDSTestUtils.createArchiveAndCheck(); - run(true); - run(false); - } - - - private static void run(boolean useArchive) throws Exception { - String flag = useArchive ? "auto" : "off"; - - try { - // (1) Launch the attachee process - System.out.println("Starting LingeredApp"); - List vmOpts = Arrays.asList( - "-XX:SharedArchiveFile=" + jsaName, - "-Xshare:" + flag, - "-showversion"); // so we can see "sharing" in the output - - theApp = LingeredApp.startApp(vmOpts); - - // (2) Launch the agent process - long pid = theApp.getPid(); - System.out.println("Attaching agent to " + pid ); - ProcessBuilder tool = ProcessTools.createJavaProcessBuilder( - "--add-modules=jdk.hotspot.agent", - "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED", - "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.memory=ALL-UNNAMED", - "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.runtime=ALL-UNNAMED", - "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.tools=ALL-UNNAMED", - "SASymbolTableTestAgent", - Long.toString(pid)); - OutputAnalyzer output = CDSTestUtils.executeAndLog(tool, "tool"); - if (output.getStdout().contains("connected too early")) { - System.out.println("SymbolTable not created by VM - test skipped"); - return; - } - output.shouldHaveExitValue(0); - } catch (Exception ex) { - throw new RuntimeException("Test ERROR " + ex, ex); - } finally { - LingeredApp.stopApp(theApp); - } - } -} diff -r 565d54ca1f41 -r 49b4e7203b4b test/hotspot/jtreg/runtime/SharedArchiveFile/SASymbolTableTestAgent.java --- a/test/hotspot/jtreg/runtime/SharedArchiveFile/SASymbolTableTestAgent.java Fri Jul 06 09:27:32 2018 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,146 +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. - */ - -import sun.jvm.hotspot.memory.SymbolTable; -import sun.jvm.hotspot.oops.Symbol; -import sun.jvm.hotspot.runtime.VM; -import sun.jvm.hotspot.tools.Tool; - -/** - * This class is launched in a sub-process by the main test, - * SASymbolTableTest.java. - * - * It uses SA to connect to another JVM process, whose PID is specified in args[]. - * The purpose of the test is to validate that we can walk the SymbolTable - * and CompactHashTable of the other process. Everything should work regardless - * of whether the other process runs in CDS mode or not. - * - * Note: CompactHashTable is used only when CDS is enabled. - */ -public class SASymbolTableTestAgent extends Tool { - public SASymbolTableTestAgent() { - super(); - } - public static void main(String args[]) { - SASymbolTableTestAgent tool = new SASymbolTableTestAgent(); - tool.execute(args); - } - - static String[] commonNames = { - "java/lang/Object", - "java/lang/String", - "java/lang/Class", - "java/lang/Cloneable", - "java/lang/ClassLoader", - "java/io/Serializable", - "java/lang/System", - "java/lang/Throwable", - "java/lang/Error", - "java/lang/ThreadDeath", - "java/lang/Exception", - "java/lang/RuntimeException", - "java/lang/SecurityManager", - "java/security/ProtectionDomain", - "java/security/AccessControlContext", - "java/security/SecureClassLoader", - "java/lang/ClassNotFoundException", - "java/lang/NoClassDefFoundError", - "java/lang/LinkageError", - "java/lang/ClassCastException", - "java/lang/ArrayStoreException", - "java/lang/VirtualMachineError", - "java/lang/OutOfMemoryError", - "java/lang/StackOverflowError", - "java/lang/IllegalMonitorStateException", - "java/lang/ref/Reference", - "java/lang/ref/SoftReference", - "java/lang/ref/WeakReference", - "java/lang/ref/FinalReference", - "java/lang/ref/PhantomReference", - "java/lang/ref/Finalizer", - "java/lang/Thread", - "java/lang/ThreadGroup", - "java/util/Properties", - "java/lang/reflect/AccessibleObject", - "java/lang/reflect/Field", - "java/lang/reflect/Method", - "java/lang/reflect/Constructor", - "java/lang/invoke/MethodHandle", - "java/lang/invoke/MemberName", - "java/lang/invoke/MethodHandleNatives", - "java/lang/invoke/MethodType", - "java/lang/BootstrapMethodError", - "java/lang/invoke/CallSite", - "java/lang/invoke/ConstantCallSite", - "java/lang/invoke/MutableCallSite", - "java/lang/invoke/VolatileCallSite", - "java/lang/StringBuffer", - "java/lang/StringBuilder", - "java/io/ByteArrayInputStream", - "java/io/File", - "java/net/URLClassLoader", - "java/net/URL", - "java/util/jar/Manifest", - "java/security/CodeSource", - }; - - static String[] badNames = { - "java/lang/badbadbad", - "java/io/badbadbadbad", - "this*symbol*must*not*exist" - }; - - public void run() { - System.out.println("SASymbolTableTestAgent: starting"); - try { - VM vm = VM.getVM(); - SymbolTable table = vm.getSymbolTable(); - - // (a) These are names that are likely to exist in the symbol table - // of a JVM after start-up. They were taken from vmSymbols.hpp - // during the middle of JDK9 development. - // - // The purpose is not to check that each name must exist (a future - // version of JDK may not preload some of the classes). - // - // The purpose of this loops is to ensure that we check a lot of symbols, - // so we will (most likely) hit on both VALUE_ONLY_BUCKET_TYPE and normal bucket type - // in CompactHashTable.probe(). - for (String n : commonNames) { - Symbol s = table.probe(n); - System.out.format("%-40s = %s\n", n, s); - } - - System.out.println("======================================================================"); - - // (b) Also test a few strings that are known to not exist in the table. This will - // both the compact table (if it exists) and the regular table to be walked. - for (String n : badNames) { - Symbol s = table.probe(n); - System.out.format("%-40s = %s\n", n, s); - } - } catch (NullPointerException e) { - System.out.println("connected too early -- please try again"); - } - } -} diff -r 565d54ca1f41 -r 49b4e7203b4b test/hotspot/jtreg/serviceability/sa/ClhsdbPrintStatics.java --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbPrintStatics.java Fri Jul 06 09:27:32 2018 -0400 +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbPrintStatics.java Fri Jul 06 09:29:17 2018 -0400 @@ -57,7 +57,7 @@ expStrMap.put("printstatics", List.of( "All known static fields", "Abstract_VM_Version::_vm_major_version", - "ClassLoaderDataGraph::_head", "SymbolTable::_the_table", + "ClassLoaderDataGraph::_head", "JNIHandles::_weak_global_handles", "PerfMemory::_top", "ObjectSynchronizer::gBlockList", "java_lang_Class::_oop_size_offset", diff -r 565d54ca1f41 -r 49b4e7203b4b test/hotspot/jtreg/serviceability/sa/ClhsdbSource.java --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbSource.java Fri Jul 06 09:27:32 2018 -0400 +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbSource.java Fri Jul 06 09:29:17 2018 -0400 @@ -66,8 +66,7 @@ "Available commands:", "attach pid | exec core", "intConstant [ name [ value ] ]", - "type [ type [ name super isOop isInteger isUnsigned size ] ]", - "symboltable name")); + "type [ type [ name super isOop isInteger isUnsigned size ] ]")); Map> unExpStrMap = new HashMap<>(); unExpStrMap.put("source clhsdb_cmd_file", List.of( diff -r 565d54ca1f41 -r 49b4e7203b4b test/hotspot/jtreg/serviceability/sa/ClhsdbSymbol.java --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbSymbol.java Fri Jul 06 09:27:32 2018 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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.util.HashMap; -import java.util.List; -import java.util.Map; - -import jdk.test.lib.apps.LingeredApp; -import jdk.test.lib.Platform; - -/** - * @test - * @bug 8190198 - * @summary Test clhsdb symboldump command - * @requires vm.hasSA - * @library /test/lib - * @run main/othervm ClhsdbSymbol - */ - -public class ClhsdbSymbol { - - public static void main(String[] args) throws Exception { - System.out.println("Starting ClhsdbSymbol test"); - - LingeredApp theApp = null; - try { - ClhsdbLauncher test = new ClhsdbLauncher(); - theApp = LingeredApp.startApp(); - System.out.println("Started LingeredApp with pid " + theApp.getPid()); - - List cmds = List.of("symboldump"); - - Map> expStrMap = new HashMap<>(); - expStrMap.put("symboldump", List.of( - "java/lang/String", "java/util/HashMap", - "Ljava/io/InputStream", "LambdaMetafactory", "PerfCounter", - "isAnonymousClass", "JVMTI_THREAD_STATE_TERMINATED", "jdi", - "checkGetClassLoaderPermission", "lockCreationTime", - "stderrBuffer", "stdoutBuffer", "getProcess", - "LingeredApp")); - - test.run(theApp.getPid(), cmds, expStrMap, null); - } catch (Exception ex) { - throw new RuntimeException("Test ERROR " + ex, ex); - } finally { - LingeredApp.stopApp(theApp); - } - System.out.println("Test PASSED"); - } -} diff -r 565d54ca1f41 -r 49b4e7203b4b test/hotspot/jtreg/serviceability/sa/ClhsdbSymbolTable.java --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbSymbolTable.java Fri Jul 06 09:27:32 2018 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.ArrayList; -import jdk.test.lib.apps.LingeredApp; - -/** - * @test - * @bug 8191538 - * @summary Test the clhsdb 'symboltable' and 'symbol' commands - * @requires vm.hasSA - * @library /test/lib - * @run main/othervm ClhsdbSymbolTable - */ - -public class ClhsdbSymbolTable { - - public static void main(String[] args) throws Exception { - System.out.println("Starting the ClhsdbSymbolTable test"); - - LingeredApp theApp = null; - try { - ClhsdbLauncher test = new ClhsdbLauncher(); - - theApp = LingeredApp.startApp(); - System.out.println("Started LingeredApp with pid " + theApp.getPid()); - - // Test the symboltable command - List cmds = List.of( - "symboltable main", - "symboltable java/lang/Class", - "symboltable java/lang/Object", - "symboltable java/lang/String", - "symboltable java/util/List", - "symboltable jdk/test/lib/apps/LingeredApp"); - - Map> expStrMap = new HashMap<>(); - expStrMap.put("symboltable main", List.of( - "sun.jvm.hotspot.oops.Symbol@")); - expStrMap.put("symboltable java/lang/Class", List.of( - "sun.jvm.hotspot.oops.Symbol@")); - expStrMap.put("symboltable java/lang/Object", List.of( - "sun.jvm.hotspot.oops.Symbol@")); - expStrMap.put("symboltable java/lang/String", List.of( - "sun.jvm.hotspot.oops.Symbol@")); - expStrMap.put("symboltable java/util/List", List.of( - "sun.jvm.hotspot.oops.Symbol@")); - expStrMap.put("symboltable jdk/test/lib/apps/LingeredApp", List.of( - "sun.jvm.hotspot.oops.Symbol@")); - String consolidatedOutput = - test.run(theApp.getPid(), cmds, expStrMap, null); - - // Test the 'symbol' command passing in the address obtained from - // the 'symboltable' command - expStrMap = new HashMap<>(); - cmds = new ArrayList(); - int expectedStringsIdx = 0; - String expectedStrings[] = {"#main", - "#java/lang/Class", "#java/lang/Object", - "#java/lang/String", "#java/util/List", - "#jdk/test/lib/apps/LingeredApp"}; - if (consolidatedOutput != null) { - // Output could be null due to attach permission issues - // and if we are skipping this. - String[] singleCommandOutputs = consolidatedOutput.split("hsdb>"); - - for (String singleCommandOutput : singleCommandOutputs) { - if (singleCommandOutput.contains("@")) { - String[] tokens = singleCommandOutput.split("@"); - String addressString = tokens[1].replace("\n",""); - - // tokens[1] represents the address of the symbol - String cmd = "symbol " + addressString; - cmds.add(cmd); - expStrMap.put(cmd, List.of - (expectedStrings[expectedStringsIdx++])); - } - } - test.run(theApp.getPid(), cmds, expStrMap, null); - } - } catch (Exception ex) { - throw new RuntimeException("Test ERROR " + ex, ex); - } finally { - LingeredApp.stopApp(theApp); - } - System.out.println("Test PASSED"); - } -} diff -r 565d54ca1f41 -r 49b4e7203b4b test/jdk/ProblemList.txt --- a/test/jdk/ProblemList.txt Fri Jul 06 09:27:32 2018 -0400 +++ b/test/jdk/ProblemList.txt Fri Jul 06 09:29:17 2018 -0400 @@ -540,9 +540,6 @@ com/sun/management/OperatingSystemMXBean/GetProcessCpuLoad.java 8030957 aix-all com/sun/management/OperatingSystemMXBean/GetSystemCpuLoad.java 8030957 aix-all -sun/management/jmxremote/bootstrap/RmiSslBootstrapTest.sh 8205653 generic-all -sun/management/jmxremote/bootstrap/RmiRegistrySslTest.java 8205653 generic-all - ############################################################################ # jdk_jmx diff -r 565d54ca1f41 -r 49b4e7203b4b test/jdk/java/lang/invoke/MethodHandlesArityLimitsTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/java/lang/invoke/MethodHandlesArityLimitsTest.java Fri Jul 06 09:29:17 2018 -0400 @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 + * @summary unit tests for arity limits of methods in java.lang.invoke.MethodHandles + * @run junit/othervm test.java.lang.invoke.MethodHandlesArityLimitsTest + **/ + +package test.java.lang.invoke; + +import org.junit.*; + +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodHandle; +import java.lang.invoke.WrongMethodTypeException; +import java.lang.invoke.MethodType; +import java.lang.invoke.VarHandle; +import java.util.List; + +import java.util.stream.IntStream; + +import static org.junit.Assert.*; + +public class MethodHandlesArityLimitsTest { + + private static MethodType mt254 = null; + private static MethodType mt255 = null; + + static { + Class[] classes254 = IntStream.range(0, 254) + .mapToObj(i -> int.class) + .toArray(Class[]::new); + mt254 = MethodType.methodType(void.class, classes254); + mt255 = mt254.appendParameterTypes(int.class); + } + + @Test(expected = IllegalArgumentException.class) + public void testDropArgumentsToMatch() { + MethodHandles.dropArgumentsToMatch(MethodHandles.empty(mt254), 0, mt255.parameterList(), 0); + } + + @Test(expected = IllegalArgumentException.class) + public void testEmpty() { + MethodHandles.empty(mt255); + } + + @Test(expected = IllegalArgumentException.class) + public void testExplicitCastArguments() { + MethodHandles.explicitCastArguments( + MethodHandles.empty(mt254), + mt254.dropParameterTypes(0, 1).insertParameterTypes(0, long.class) ); + } + + @Test(expected = IllegalArgumentException.class) + public void testPermuteArguments() { + MethodHandles.permuteArguments( + MethodHandles.empty(MethodType.methodType(void.class)), + mt255); + } + + @Test(expected = IllegalArgumentException.class) + public void testVarHandleInvoker() { + MethodHandles.varHandleInvoker(VarHandle.AccessMode.GET, mt254); + } + + @Test(expected = IllegalArgumentException.class) + public void testVarHandleExactInvoker() { + MethodHandles.varHandleExactInvoker(VarHandle.AccessMode.GET, mt254); + } + + @Test(expected = IllegalArgumentException.class) + public void testMHExactInvoker() { + MethodHandles.exactInvoker(mt255); + } + + @Test(expected = IllegalArgumentException.class) + public void testMHInvoker() { + MethodHandles.invoker(mt255); + } + + @Test(expected = IllegalArgumentException.class) + public void testMHSpreadInvoker() { + MethodHandles.spreadInvoker(mt255, 255); + } + + @Test(expected = WrongMethodTypeException.class) + public void testAsType() throws ReflectiveOperationException { + MethodHandle asList = MethodHandles.lookup().findStatic( + java.util.Arrays.class, + "asList", + MethodType.methodType(List.class, Object[].class)); + try { + asList.asType(MethodType.genericMethodType(254));//does not throw IAE or WMTE + } + catch(WrongMethodTypeException wmte) { + Assert.fail("Unexpected WrongMethodTypeException thrown"); + } + asList.asType(MethodType.genericMethodType(255));//throws WMTE + } +} diff -r 565d54ca1f41 -r 49b4e7203b4b test/jdk/java/nio/channels/AsynchronousSocketChannel/CompletionHandlerRelease.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/java/nio/channels/AsynchronousSocketChannel/CompletionHandlerRelease.java Fri Jul 06 09:29:17 2018 -0400 @@ -0,0 +1,211 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 8202252 + * @run testng CompletionHandlerRelease + * @summary Verify that reference to CompletionHandler is cleared after use + */ + +import java.io.Closeable; +import java.io.IOException; +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.WeakReference; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import static java.net.StandardSocketOptions.*; +import java.nio.ByteBuffer; +import java.nio.channels.AsynchronousChannelGroup; +import java.nio.channels.AsynchronousServerSocketChannel; +import java.nio.channels.AsynchronousSocketChannel; +import java.nio.channels.CompletionHandler; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + +import org.testng.annotations.AfterTest; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +public class CompletionHandlerRelease { + @Test + public void testConnect() throws Exception { + try (Server server = new Server()) { + try (AsynchronousSocketChannel ch = + AsynchronousSocketChannel.open(GROUP)) { + CountDownLatch latch = new CountDownLatch(1); + Handler handler = + new Handler("connect", latch); + ReferenceQueue queue = new ReferenceQueue(); + WeakReference ref = + new WeakReference(handler, queue); + + ch.connect(server.address(), null, handler); + + try { latch.await(); } catch (InterruptedException ignore) { } + + handler = null; + waitForRefToClear(ref, queue); + + server.accept().get().close(); + } + } + } + + @Test + public void testWrite() throws Exception { + try (Server server = new Server(); + AsynchronousSocketChannel ch = + AsynchronousSocketChannel.open(GROUP)) { + ch.connect(server.address()).get(); + + try (AsynchronousSocketChannel sc = server.accept().get()) { + ByteBuffer src = ByteBuffer.wrap("hello".getBytes("UTF-8")); + sc.setOption(SO_SNDBUF, src.remaining()); + + CountDownLatch latch = new CountDownLatch(1); + Handler handler = + new Handler("write", latch); + ReferenceQueue queue = new ReferenceQueue(); + WeakReference ref = + new WeakReference(handler, queue); + + sc.write(src, null, handler); + + try { latch.await(); } catch (InterruptedException ignore) { } + + handler = null; + waitForRefToClear(ref, queue); + } + } + } + + @Test + public void testRead() throws Exception { + try (Server server = new Server(); + AsynchronousSocketChannel ch = + AsynchronousSocketChannel.open(GROUP)) { + ch.connect(server.address()).get(); + + try (AsynchronousSocketChannel sc = server.accept().get()) { + ByteBuffer src = ByteBuffer.wrap("hello".getBytes("UTF-8")); + sc.setOption(SO_SNDBUF, src.remaining()); + sc.write(src).get(); + + CountDownLatch latch = new CountDownLatch(1); + Handler handler = + new Handler("read", latch); + ReferenceQueue queue = new ReferenceQueue(); + WeakReference ref = + new WeakReference(handler, queue); + + ByteBuffer dst = ByteBuffer.allocate(64); + ch.read(dst, null, handler); + + try { latch.await(); } catch (InterruptedException ignore) { } + + handler = null; + waitForRefToClear(ref, queue); + } + } + } + + private AsynchronousChannelGroup GROUP; + + @BeforeTest + void setup() throws IOException { + GROUP = AsynchronousChannelGroup.withFixedThreadPool(2, + Executors.defaultThreadFactory()); + } + + @AfterTest + void cleanup() throws IOException { + GROUP.shutdownNow(); + } + + class Server implements Closeable { + private final AsynchronousServerSocketChannel ssc; + private final InetSocketAddress address; + + Server() throws IOException { + this(0); + } + + Server(int recvBufSize) throws IOException { + ssc = AsynchronousServerSocketChannel.open(GROUP); + if (recvBufSize > 0) { + ssc.setOption(SO_RCVBUF, recvBufSize); + } + ssc.bind(new InetSocketAddress(InetAddress.getLoopbackAddress(), + 0)); + address = (InetSocketAddress)ssc.getLocalAddress(); + } + + InetSocketAddress address() { + return address; + } + + Future accept() throws IOException { + return ssc.accept(); + } + + public void close() throws IOException { + ssc.close(); + } + } + + static class Handler implements CompletionHandler { + private final String name; + private final CountDownLatch latch; + + Handler(String name, CountDownLatch latch) { + this.name = name; + this.latch = latch; + } + + public void completed(V result, A attachment) { + System.out.format("%s completed(%s, %s)%n", + name, result, attachment); + latch.countDown(); + } + + public void failed(Throwable exc, A attachment) { + System.out.format("%s failed(%s, %s)%n", + name, exc, attachment); + exc.printStackTrace(); + latch.countDown(); + } + } + + private void waitForRefToClear(Reference ref, ReferenceQueue queue) + throws InterruptedException { + Reference r; + while ((r = queue.remove(20)) == null) { + System.gc(); + } + assertEquals(r, ref); + assertNull(r.get()); + } +} diff -r 565d54ca1f41 -r 49b4e7203b4b test/jdk/java/time/test/java/time/format/TestNonIsoFormatter.java --- a/test/jdk/java/time/test/java/time/format/TestNonIsoFormatter.java Fri Jul 06 09:27:32 2018 -0400 +++ b/test/jdk/java/time/test/java/time/format/TestNonIsoFormatter.java Fri Jul 06 09:29:17 2018 -0400 @@ -24,6 +24,7 @@ /* * * @test + * @bug 8206120 * @modules jdk.localedata */ @@ -44,6 +45,7 @@ import java.time.format.DateTimeFormatterBuilder; import java.time.format.DateTimeParseException; import java.time.format.FormatStyle; +import java.time.format.ResolverStyle; import java.time.format.TextStyle; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalQueries; @@ -135,6 +137,16 @@ }; } + @DataProvider(name="lenient_eraYear") + Object[][] lenientEraYear() { + return new Object[][] { + // Chronology, lenient era/year, strict era/year + { JAPANESE, "Meiji 123", "Heisei 2" }, + { JAPANESE, "Showa 65", "Heisei 2" }, + { JAPANESE, "Heisei 32", "NewEra 2" }, // NewEra + }; + } + @Test(dataProvider="format_data") public void test_formatLocalizedDate(Chronology chrono, Locale formatLocale, Locale numberingLocale, ChronoLocalDate date, String expected) { @@ -173,4 +185,15 @@ Chronology cal = ta.query(TemporalQueries.chronology()); assertEquals(cal, chrono); } + + @Test(dataProvider="lenient_eraYear") + public void test_lenientEraYear(Chronology chrono, String lenient, String strict) { + String mdStr = "-01-01"; + DateTimeFormatter dtf = new DateTimeFormatterBuilder() + .appendPattern("GGGG y-M-d") + .toFormatter() + .withChronology(chrono); + DateTimeFormatter dtfLenient = dtf.withResolverStyle(ResolverStyle.LENIENT); + assertEquals(LocalDate.parse(lenient+mdStr, dtfLenient), LocalDate.parse(strict+mdStr, dtf)); + } } diff -r 565d54ca1f41 -r 49b4e7203b4b test/jdk/java/util/Calendar/JapaneseLenientEraTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/java/util/Calendar/JapaneseLenientEraTest.java Fri Jul 06 09:29:17 2018 -0400 @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 8206120 + * @summary Test whether lenient era is accepted in JapaneseImperialCalendar + * @run testng/othervm JapaneseLenientEraTest + */ + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.Locale; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; +import static org.testng.Assert.assertEquals; + +@Test +public class JapaneseLenientEraTest { + + @DataProvider(name="lenientEra") + Object[][] names() { + return new Object[][] { + // lenient era/year, strict era/year + { "Meiji 123", "Heisei 2" }, + { "Sh\u014dwa 65", "Heisei 2" }, + { "Heisei 32", "NewEra 2" }, // NewEra + }; + } + + @Test(dataProvider="lenientEra") + public void testLenientEra(String lenient, String strict) throws Exception { + Calendar c = new Calendar.Builder() + .setCalendarType("japanese") + .build(); + DateFormat df = new SimpleDateFormat("GGGG y-M-d", Locale.ROOT); + df.setCalendar(c); + Date lenDate = df.parse(lenient + "-01-01"); + df.setLenient(false); + Date strDate = df.parse(strict + "-01-01"); + assertEquals(lenDate, strDate); + } +} diff -r 565d54ca1f41 -r 49b4e7203b4b test/jdk/java/util/Locale/bcp47u/SystemPropertyTests.java --- a/test/jdk/java/util/Locale/bcp47u/SystemPropertyTests.java Fri Jul 06 09:27:32 2018 -0400 +++ b/test/jdk/java/util/Locale/bcp47u/SystemPropertyTests.java Fri Jul 06 09:29:17 2018 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,6 +47,7 @@ public class SystemPropertyTests { private static String LANGPROP = "-Duser.language=en"; + private static String SCPTPROP = "-Duser.script="; private static String CTRYPROP = "-Duser.country=US"; @DataProvider(name="data") @@ -88,7 +89,7 @@ @Test(dataProvider="data") public void runTest(String extprop, String defLoc, String defFmtLoc, String defDspLoc) throws Exception { - int exitValue = executeTestJava(LANGPROP, CTRYPROP, + int exitValue = executeTestJava(LANGPROP, SCPTPROP, CTRYPROP, extprop, "DefaultLocaleTest", defLoc, defFmtLoc, defDspLoc) .outputTo(System.out) .errorTo(System.out) diff -r 565d54ca1f41 -r 49b4e7203b4b test/jdk/sun/management/jmxremote/bootstrap/management_ssltest11_ok.properties.in --- a/test/jdk/sun/management/jmxremote/bootstrap/management_ssltest11_ok.properties.in Fri Jul 06 09:27:32 2018 -0400 +++ b/test/jdk/sun/management/jmxremote/bootstrap/management_ssltest11_ok.properties.in Fri Jul 06 09:29:17 2018 -0400 @@ -1,6 +1,6 @@ -com.sun.management.jmxremote.ssl.enabled.cipher.suites=SSL_RSA_WITH_RC4_128_SHA,SSL_RSA_WITH_RC4_128_MD5 -com.sun.management.jmxremote.ssl.enabled.protocols=SSLv2Hello,SSLv3,TLSv1 +com.sun.management.jmxremote.ssl.enabled.cipher.suites=TLS_AES_128_GCM_SHA256,TLS_AES_256_GCM_SHA384 +com.sun.management.jmxremote.ssl.enabled.protocols=SSLv2Hello,SSLv3,TLSv1,TLSv1.1,TLSv1.2,TLSv1.3 com.sun.management.jmxremote.ssl.need.client.auth=true com.sun.management.jmxremote.ssl.config.file=@TEST-SRC@/jmxremote_ssltest11_ok.ssl com.sun.management.jmxremote.authenticate=false -javax.rmi.ssl.client.enabledCipherSuites=SSL_RSA_WITH_RC4_128_SHA,SSL_RSA_WITH_RC4_128_MD5 +javax.rmi.ssl.client.enabledCipherSuites=TLS_AES_128_GCM_SHA256,TLS_AES_256_GCM_SHA384 diff -r 565d54ca1f41 -r 49b4e7203b4b test/jdk/sun/management/jmxremote/bootstrap/management_ssltest15_ok.properties.in --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/sun/management/jmxremote/bootstrap/management_ssltest15_ok.properties.in Fri Jul 06 09:29:17 2018 -0400 @@ -0,0 +1,6 @@ +com.sun.management.jmxremote.ssl.enabled.cipher.suites=TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA +com.sun.management.jmxremote.ssl.enabled.protocols=SSLv2Hello,SSLv3,TLSv1 +com.sun.management.jmxremote.ssl.need.client.auth=true +com.sun.management.jmxremote.ssl.config.file=@TEST-SRC@/jmxremote_ssltest11_ok.ssl +com.sun.management.jmxremote.authenticate=false +javax.rmi.ssl.client.enabledCipherSuites=TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA diff -r 565d54ca1f41 -r 49b4e7203b4b test/jdk/sun/management/jmxremote/bootstrap/ssl/Readme.txt --- a/test/jdk/sun/management/jmxremote/bootstrap/ssl/Readme.txt Fri Jul 06 09:27:32 2018 -0400 +++ b/test/jdk/sun/management/jmxremote/bootstrap/ssl/Readme.txt Fri Jul 06 09:29:17 2018 -0400 @@ -1,11 +1,10 @@ The trustore and keystore are to be generated as follows: -1. keytool -genkey -alias duke -keystore keystore -validity 36500 +1. keytool -genkey -alias duke -keyalg RSA -keysize 2048 -validity 36500 -keystore keystore -storepass password - use password 'password' for the keystore and key passwords - leave all values at default - the certificate validity will be 100 years (should be enough for now) 2. keytool -export -keystore keystore -alias duke -file duke.crt -3. keytool -import -keystore truststore -alias duke -file duke.crt +3. keytool -import -alias duke -file duke.crt -keystore truststore -storepass trustword - use password 'trustword' for the keystore and key passwords - leave all values at default - diff -r 565d54ca1f41 -r 49b4e7203b4b test/jdk/sun/management/jmxremote/bootstrap/ssl/keystore Binary file test/jdk/sun/management/jmxremote/bootstrap/ssl/keystore has changed diff -r 565d54ca1f41 -r 49b4e7203b4b test/jdk/sun/management/jmxremote/bootstrap/ssl/truststore Binary file test/jdk/sun/management/jmxremote/bootstrap/ssl/truststore has changed diff -r 565d54ca1f41 -r 49b4e7203b4b test/jdk/sun/tools/jhsdb/AlternateHashingTest.java --- a/test/jdk/sun/tools/jhsdb/AlternateHashingTest.java Fri Jul 06 09:27:32 2018 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 8030750 - * @summary Test alternate hashing of strings in Serviceability Agent. - * @requires vm.hasSAandCanAttach - * @library /test/lib - * @library /lib/testlibrary - * @compile AlternateHashingTest.java - * @run main/timeout=240 AlternateHashingTest - */ - -import java.io.BufferedReader; -import java.io.OutputStream; -import java.io.InputStreamReader; -import java.io.IOException; -import java.util.Arrays; -import jdk.testlibrary.JDKToolLauncher; -import jdk.test.lib.apps.LingeredApp; -import jdk.test.lib.Platform; - -public class AlternateHashingTest { - - private static LingeredAppWithAltHashing theApp = null; - - /** - * - * @param vmArgs - tool arguments to launch jhsdb - * @return exit code of tool - */ - public static void launch(String expectedMessage, String cmd) throws IOException { - - System.out.println("Starting LingeredApp"); - try { - theApp = new LingeredAppWithAltHashing(); - LingeredApp.startApp(Arrays.asList("-Xmx256m"), theApp); - - System.out.println("Starting clhsdb against " + theApp.getPid()); - JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jhsdb"); - launcher.addToolArg("clhsdb"); - launcher.addToolArg("--pid=" + Long.toString(theApp.getPid())); - - ProcessBuilder processBuilder = new ProcessBuilder(launcher.getCommand()); - processBuilder.redirectError(ProcessBuilder.Redirect.INHERIT); - Process toolProcess = processBuilder.start(); - - try (OutputStream out = toolProcess.getOutputStream()) { - out.write(cmd.getBytes()); - out.write("quit\n".getBytes()); - } - - boolean result = false; - try (BufferedReader reader = - new BufferedReader(new InputStreamReader(toolProcess.getInputStream()))) { - String line; - - while ((line = reader.readLine()) != null) { - line = line.trim(); - System.out.println(line); - - if (line.contains(expectedMessage)) { - result = true; - break; - } - } - } - - toolProcess.waitFor(); - - if (toolProcess.exitValue() != 0) { - throw new RuntimeException("FAILED CLHSDB terminated with non-zero exit code " + toolProcess.exitValue()); - } - - if (!result) { - throw new RuntimeException(cmd + " command output is missing the message " + expectedMessage); - } - - } catch (Exception ex) { - throw new RuntimeException("Test ERROR " + ex, ex); - } finally { - LingeredApp.stopApp(theApp); - } - } - - - public static void testAltHashing() throws IOException { - - launch("Stack in use by Java", "threads\n"); - } - - public static void main(String[] args) throws Exception { - - testAltHashing(); - - // The test throws RuntimeException on error. - // IOException is thrown if LingeredApp can't start because of some bad - // environment condition - System.out.println("Test PASSED"); - } -} diff -r 565d54ca1f41 -r 49b4e7203b4b test/jdk/sun/tools/jhsdb/LingeredAppWithAltHashing.java --- a/test/jdk/sun/tools/jhsdb/LingeredAppWithAltHashing.java Fri Jul 06 09:27:32 2018 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,161 +0,0 @@ -/* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 jdk.test.lib.apps.LingeredApp; - -public class LingeredAppWithAltHashing extends LingeredApp { - - public static void main(String args[]) { - LingeredApp.main(args); - } - - // Following strings generate the same hashcode - - static final String str1 = "AaAaAaAaAaAaAa"; - static final String str2 = "AaAaAaAaAaAaBB"; - static final String str3 = "AaAaAaAaAaBBAa"; - static final String str4 = "AaAaAaAaAaBBBB"; - static final String str5 = "AaAaAaAaBBAaAa"; - static final String str6 = "AaAaAaAaBBAaBB"; - static final String str7 = "AaAaAaAaBBBBAa"; - static final String str8 = "AaAaAaAaBBBBBB"; - static final String str9 = "AaAaAaBBAaAaAa"; - static final String str10 = "AaAaAaBBAaAaBB"; - static final String str11 = "AaAaAaBBAaBBAa"; - static final String str12 = "AaAaAaBBAaBBBB"; - static final String str13 = "AaAaAaBBBBAaAa"; - static final String str14 = "AaAaAaBBBBAaBB"; - static final String str15 = "AaAaAaBBBBBBAa"; - static final String str16 = "AaAaAaBBBBBBBB"; - static final String str17 = "AaAaBBAaAaAaAa"; - static final String str18 = "AaAaBBAaAaAaBB"; - static final String str19 = "AaAaBBAaAaBBAa"; - static final String str20 = "AaAaBBAaAaBBBB"; - static final String str21 = "AaAaBBAaBBAaAa"; - static final String str22 = "AaAaBBAaBBAaBB"; - static final String str23 = "AaAaBBAaBBBBAa"; - static final String str24 = "AaAaBBAaBBBBBB"; - static final String str25 = "AaAaBBBBAaAaAa"; - static final String str26 = "AaAaBBBBAaAaBB"; - static final String str27 = "AaAaBBBBAaBBAa"; - static final String str28 = "AaAaBBBBAaBBBB"; - static final String str29 = "AaAaBBBBBBAaAa"; - static final String str30 = "AaAaBBBBBBAaBB"; - static final String str31 = "AaAaBBBBBBBBAa"; - static final String str32 = "AaAaBBBBBBBBBB"; - static final String str33 = "AaBBAaAaAaAaAa"; - static final String str34 = "AaBBAaAaAaAaBB"; - static final String str35 = "AaBBAaAaAaBBAa"; - static final String str36 = "AaBBAaAaAaBBBB"; - static final String str37 = "AaBBAaAaBBAaAa"; - static final String str38 = "AaBBAaAaBBAaBB"; - static final String str39 = "AaBBAaAaBBBBAa"; - static final String str40 = "AaBBAaAaBBBBBB"; - static final String str41 = "AaBBAaBBAaAaAa"; - static final String str42 = "AaBBAaBBAaAaBB"; - static final String str43 = "AaBBAaBBAaBBAa"; - static final String str44 = "AaBBAaBBAaBBBB"; - static final String str45 = "AaBBAaBBBBAaAa"; - static final String str46 = "AaBBAaBBBBAaBB"; - static final String str47 = "AaBBAaBBBBBBAa"; - static final String str48 = "AaBBAaBBBBBBBB"; - static final String str49 = "AaBBBBAaAaAaAa"; - static final String str50 = "AaBBBBAaAaAaBB"; - static final String str51 = "AaBBBBAaAaBBAa"; - static final String str52 = "AaBBBBAaAaBBBB"; - static final String str53 = "AaBBBBAaBBAaAa"; - static final String str54 = "AaBBBBAaBBAaBB"; - static final String str55 = "AaBBBBAaBBBBAa"; - static final String str56 = "AaBBBBAaBBBBBB"; - static final String str57 = "AaBBBBBBAaAaAa"; - static final String str58 = "AaBBBBBBAaAaBB"; - static final String str59 = "AaBBBBBBAaBBAa"; - static final String str60 = "AaBBBBBBAaBBBB"; - static final String str61 = "AaBBBBBBBBAaAa"; - static final String str62 = "AaBBBBBBBBAaBB"; - static final String str63 = "AaBBBBBBBBBBAa"; - static final String str64 = "AaBBBBBBBBBBBB"; - static final String str65 = "BBAaAaAaAaAaAa"; - static final String str66 = "BBAaAaAaAaAaBB"; - static final String str67 = "BBAaAaAaAaBBAa"; - static final String str68 = "BBAaAaAaAaBBBB"; - static final String str69 = "BBAaAaAaBBAaAa"; - static final String str70 = "BBAaAaAaBBAaBB"; - static final String str71 = "BBAaAaAaBBBBAa"; - static final String str72 = "BBAaAaAaBBBBBB"; - static final String str73 = "BBAaAaBBAaAaAa"; - static final String str74 = "BBAaAaBBAaAaBB"; - static final String str75 = "BBAaAaBBAaBBAa"; - static final String str76 = "BBAaAaBBAaBBBB"; - static final String str77 = "BBAaAaBBBBAaAa"; - static final String str78 = "BBAaAaBBBBAaBB"; - static final String str79 = "BBAaAaBBBBBBAa"; - static final String str80 = "BBAaAaBBBBBBBB"; - static final String str81 = "BBAaBBAaAaAaAa"; - static final String str82 = "BBAaBBAaAaAaBB"; - static final String str83 = "BBAaBBAaAaBBAa"; - static final String str84 = "BBAaBBAaAaBBBB"; - static final String str85 = "BBAaBBAaBBAaAa"; - static final String str86 = "BBAaBBAaBBAaBB"; - static final String str87 = "BBAaBBAaBBBBAa"; - static final String str88 = "BBAaBBAaBBBBBB"; - static final String str89 = "BBAaBBBBAaAaAa"; - static final String str90 = "BBAaBBBBAaAaBB"; - static final String str91 = "BBAaBBBBAaBBAa"; - static final String str92 = "BBAaBBBBAaBBBB"; - static final String str93 = "BBAaBBBBBBAaAa"; - static final String str94 = "BBAaBBBBBBAaBB"; - static final String str95 = "BBAaBBBBBBBBAa"; - static final String str96 = "BBAaBBBBBBBBBB"; - static final String str97 = "BBBBAaAaAaAaAa"; - static final String str98 = "BBBBAaAaAaAaBB"; - static final String str99 = "BBBBAaAaAaBBAa"; - static final String str100 = "BBBBAaAaAaBBBB"; - static final String str101 = "BBBBAaAaBBAaAa"; - static final String str102 = "BBBBAaAaBBAaBB"; - static final String str103 = "BBBBAaAaBBBBAa"; - static final String str104 = "BBBBAaAaBBBBBB"; - static final String str105 = "BBBBAaBBAaAaAa"; - static final String str106 = "BBBBAaBBAaAaBB"; - static final String str107 = "BBBBAaBBAaBBAa"; - static final String str108 = "BBBBAaBBAaBBBB"; - static final String str109 = "BBBBAaBBBBAaAa"; - static final String str110 = "BBBBAaBBBBAaBB"; - static final String str111 = "BBBBAaBBBBBBAa"; - static final String str112 = "BBBBAaBBBBBBBB"; - static final String str113 = "BBBBBBAaAaAaAa"; - static final String str114 = "BBBBBBAaAaAaBB"; - static final String str115 = "BBBBBBAaAaBBAa"; - static final String str116 = "BBBBBBAaAaBBBB"; - static final String str117 = "BBBBBBAaBBAaAa"; - static final String str118 = "BBBBBBAaBBAaBB"; - static final String str119 = "BBBBBBAaBBBBAa"; - static final String str120 = "BBBBBBAaBBBBBB"; - static final String str121 = "BBBBBBBBAaAaAa"; - static final String str122 = "BBBBBBBBAaAaBB"; - static final String str123 = "BBBBBBBBAaBBAa"; - static final String str124 = "BBBBBBBBAaBBBB"; - static final String str125 = "BBBBBBBBBBAaAa"; - static final String str126 = "BBBBBBBBBBAaBB"; - static final String str127 = "BBBBBBBBBBBBAa"; - static final String str128 = "BBBBBBBBBBBBBB"; - } diff -r 565d54ca1f41 -r 49b4e7203b4b test/langtools/tools/javac/classfiles/ClassVersionChecker.java --- a/test/langtools/tools/javac/classfiles/ClassVersionChecker.java Fri Jul 06 09:27:32 2018 -0400 +++ b/test/langtools/tools/javac/classfiles/ClassVersionChecker.java Fri Jul 06 09:29:17 2018 -0400 @@ -35,10 +35,41 @@ import java.util.*; import java.util.regex.*; +/* + * If not explicitly specified the latest source and latest target + * values are the defaults. If explicitly specified, the target value + * has to be greater than or equal to the source value. + */ public class ClassVersionChecker { + private static enum Version { + SIX("6", 50), + SEVEN("7", 51), + EIGHT("8", 52), + NINE("9", 53), + TEN("10", 54), + ELEVEN("11", 55), + TWELVE("12", 56); + + private Version(String release, int classFileVer) { + this.release = release; + this.classFileVer = classFileVer; + } + private final String release; + private final int classFileVer; + + String release() {return release;} + int classFileVer() {return classFileVer;} + } + + static final Version CURRENT; + static { + Version[] versions = Version.values(); + int index = versions.length; + CURRENT = versions[index - 1]; + } int errors; - String[] jdk = {"", "1.6", "1.7", "1.8", "1.9", "1.10", "11", "12"}; + File javaFile = null; public static void main(String[] args) throws Throwable { @@ -47,31 +78,23 @@ void run() throws Exception { writeTestFile(); - /* Rules applicable for -source and -target combinations + /* + * Rules applicable for -source and -target combinations: * 1. If both empty, version num is for the current release - * 2. If source is not empty and target is empty, version is based on source + * 2. If source is not empty and target is empty, version is + * based on the current release * 3. If both non-empty, version is based on target */ - - /* -source (0=>empty,1=>1.2,...) X -target (0=>empty,1=>1.2,...) - * ver[0][0] => no -source or -target was given - * -1 => invalid combinations - */ - int[][] ver = - {{56, -1, -1, -1, -1, -1, -1, -1}, - {56, 50, 51, 52, 53, 54, 55, 56}, - {56, -1, 51, 52, 53, 54, 55, 56}, - {56, -1, -1, 52, 53, 54, 55, 56}, - {56, -1, -1, -1, 53, 54, 55, 56}, - {56, -1, -1, -1, -1, 54, 55, 56}}; - - // Loop to run all possible combinations of source/target values - for (int i = 0; i< ver.length; i++) { - for (int j = 0 ; j< ver[i].length; j++) { - if(ver[i][j] != -1) { - logMsg("Index values for i = " + i + " j = " + j); - logMsg("Running for src = " + jdk[i] + " target = "+jdk[j] +" expected = " + ver[i][j]); - test(i,j, ver[i][j]); + test("", "", CURRENT.classFileVer()); + for (Version source : Version.values()) { + test(source.release(), "", CURRENT.classFileVer()); // no target + for (Version target : Version.values()) { + if (target.compareTo(source) < 0) + continue; // Target < source not a valid set of arguments + else { + logMsg("Running for src = " + source + " target = "+ target + + " expected = " + target.classFileVer()); + test(source.release(), target.release(), target.classFileVer()); } } } @@ -80,7 +103,7 @@ throw new Exception(errors + " errors found"); } - void test (int i, int j, int expected) { + void test(String i, String j, int expected) { File classFile = compileTestFile(i, j, javaFile); short majorVer = getMajorVersion(classFile); checkVersion(majorVer, expected); @@ -97,15 +120,15 @@ } } - File compileTestFile(int i , int j, File f) { + File compileTestFile(String i, String j, File f) { int rc = -1; // Src and target are empty - if (i == 0 && j == 0 ) { + if (i.isEmpty() && j.isEmpty() ) { rc = compile("-g", f.getPath()); - } else if( j == 0 ) { // target is empty - rc = compile("-source", jdk[i], "-g", f.getPath()); + } else if( j.isEmpty()) { // target is empty + rc = compile("-source", i, "-g", f.getPath()); } else { - rc = compile("-source", jdk[i], "-target", jdk[j], "-g", f.getPath()); + rc = compile("-source", i, "-target", j, "-g", f.getPath()); } if (rc != 0) throw new Error("compilation failed. rc=" + rc); diff -r 565d54ca1f41 -r 49b4e7203b4b test/langtools/tools/javac/versions/Versions.java --- a/test/langtools/tools/javac/versions/Versions.java Fri Jul 06 09:27:32 2018 -0400 +++ b/test/langtools/tools/javac/versions/Versions.java Fri Jul 06 09:29:17 2018 -0400 @@ -41,8 +41,14 @@ import java.util.List; import java.util.ArrayList; import java.util.Arrays; +import java.util.Set; +import java.util.function.BiConsumer; - +/* + * If not explicitly specified the latest source and latest target + * values are the defaults. If explicitly specified, the target value + * has to be greater than or equal to the source value. + */ public class Versions { protected JavaCompiler javacompiler; @@ -59,87 +65,116 @@ versions.run(); } + public static final Set RETIRED_SOURCES = + Set.of("1.2", "1.3", "1.4", "1.5"); + + public static final Set VALID_SOURCES = + Set.of("1.6", "1.7", "1.8", "1.9", "1.10", "11", "12"); + + public static final String LATEST_MAJOR_VERSION = "56.0"; + + static enum SourceTarget { + SIX(true, "50.0", "6", Versions::checksrc16), + SEVEN(true, "51.0", "7", Versions::checksrc17), + EIGHT(true, "52.0", "8", Versions::checksrc18), + NINE(true, "53.0", "9", Versions::checksrc19), + TEN(true, "54.0", "10", Versions::checksrc110), + ELEVEN(false, "55.0", "11", Versions::checksrc111), + TWELVE(false, "56.0", "12", Versions::checksrc112); + + private final boolean dotOne; + private final String classFileVer; + private final String target; + private final BiConsumer checker; + + private SourceTarget(boolean dotOne, String classFileVer, String target, + BiConsumer checker) { + this.dotOne = dotOne; + this.classFileVer = classFileVer; + this.target = target; + this.checker = checker; + } + + public void checksrc(Versions version, String... args) { + checker.accept(version, args); + } + + public boolean dotOne() { + return dotOne; + } + + public String classFileVer() { + return classFileVer; + } + + public String target() { + return target; + } + } + void run() { - String TC = ""; System.out.println("Version.java: Starting"); - String LATEST_MAJOR_VERSION = "56.0"; check(LATEST_MAJOR_VERSION); - check(LATEST_MAJOR_VERSION, "-source 1.6"); - check(LATEST_MAJOR_VERSION, "-source 1.7"); - check(LATEST_MAJOR_VERSION, "-source 1.8"); - check(LATEST_MAJOR_VERSION, "-source 1.9"); - check(LATEST_MAJOR_VERSION, "-source 1.10"); - check(LATEST_MAJOR_VERSION, "-source 11"); - check(LATEST_MAJOR_VERSION, "-source 12"); + for (String source : VALID_SOURCES) { + check(LATEST_MAJOR_VERSION, "-source " + source); + } - check_source_target(true, "50.0", "6", "6"); - check_source_target(true, "51.0", "6", "7"); - check_source_target(true, "51.0", "7", "7"); - check_source_target(true, "52.0", "6", "8"); - check_source_target(true, "52.0", "7", "8"); - check_source_target(true, "52.0", "8", "8"); - check_source_target(true, "53.0", "6", "9"); - check_source_target(true, "53.0", "7", "9"); - check_source_target(true, "53.0", "8", "9"); - check_source_target(true, "53.0", "9", "9"); - check_source_target(true, "54.0", "6", "10"); - check_source_target(true, "54.0", "7", "10"); - check_source_target(true, "54.0", "8", "10"); - check_source_target(true, "54.0", "9", "10"); - check_source_target(true, "54.0", "10", "10"); - check_source_target(false, "55.0", "6", "11"); - check_source_target(false, "55.0", "7", "11"); - check_source_target(false, "55.0", "8", "11"); - check_source_target(false, "55.0", "9", "11"); - check_source_target(false, "55.0", "10", "11"); - check_source_target(false, "55.0", "11", "11"); - check_source_target(false, "56.0", "12", "12"); + // Verify that a -source value less than a -target value is + // accepted and that the resulting class files are dependent + // on the target setting alone. + SourceTarget[] sourceTargets = SourceTarget.values(); + for (int i = 0; i < sourceTargets.length; i++) { + SourceTarget st = sourceTargets[i]; + String classFileVer = st.classFileVer(); + String target = st.target(); + boolean dotOne = st.dotOne(); + check_source_target(dotOne, classFileVer, target, target); + for (int j = i; j > 0; j--) { + String source = sourceTargets[j].target(); + check_source_target(dotOne, classFileVer, source, target); + } + } + + // Verify acceptance of different combinations of -source N, + // -target M; N <= M + for (int i = 0; i < sourceTargets.length; i++) { + SourceTarget st = sourceTargets[i]; + + st.checksrc(this, "-source " + st.target()); + st.checksrc(this, "-source " + st.target(), "-target " + st.target()); - checksrc16("-source 1.6"); - checksrc16("-source 6"); - checksrc16("-source 1.6", "-target 1.6"); - checksrc16("-source 6", "-target 6"); - checksrc17("-source 1.7"); - checksrc17("-source 7"); - checksrc17("-source 1.7", "-target 1.7"); - checksrc17("-source 7", "-target 7"); - checksrc18("-source 1.8"); - checksrc18("-source 8"); - checksrc18("-source 1.8", "-target 1.8"); - checksrc18("-source 8", "-target 8"); - checksrc19("-source 1.9"); - checksrc19("-source 9"); - checksrc19("-source 1.9", "-target 1.9"); - checksrc19("-source 9", "-target 9"); - checksrc110(); - checksrc110("-source 1.10"); - checksrc110("-source 10"); - checksrc110("-source 1.10", "-target 1.10"); - checksrc110("-source 10", "-target 10"); - checksrc111("-source 11"); - checksrc111("-source 11", "-target 11"); - checksrc112("-source 12"); - checksrc112("-source 12", "-target 12"); - checksrc112("-target 12"); + if (st.dotOne()) { + st.checksrc(this, "-source 1." + st.target()); + st.checksrc(this, "-source 1." + st.target(), "-target 1." + st.target()); + } + + if (i == sourceTargets.length) { + // Can use -target without -source setting only for + // most recent target since the most recent source is + // the default. + st.checksrc(this, "-target " + st.target()); - fail("-source 7", "-target 1.6", "Base.java"); - fail("-source 8", "-target 1.6", "Base.java"); - fail("-source 8", "-target 1.7", "Base.java"); - fail("-source 9", "-target 1.7", "Base.java"); - fail("-source 9", "-target 1.8", "Base.java"); - fail("-source 10", "-target 1.7", "Base.java"); - fail("-source 10", "-target 1.8", "Base.java"); - fail("-source 11", "-target 1.9", "Base.java"); - fail("-source 11", "-target 1.10", "Base.java"); - fail("-source 12", "-target 1.10", "Base.java"); - fail("-source 12", "-target 11", "Base.java"); + if (!st.classFileVer().equals(LATEST_MAJOR_VERSION)) { + throw new RuntimeException(st + + "does not have class file version" + + LATEST_MAJOR_VERSION); + } + } + } - fail("-source 1.5", "-target 1.5", "Base.java"); - fail("-source 1.4", "-target 1.4", "Base.java"); - fail("-source 1.3", "-target 1.3", "Base.java"); - fail("-source 1.2", "-target 1.2", "Base.java"); + // Verify that -source N -target (N-1) is rejected + for (int i = 1 /* Skip zeroth value */; i < sourceTargets.length; i++) { + fail("-source " + sourceTargets[i].target(), + "-target " + sourceTargets[i-1].target(), + "Base.java"); + } + + // Previously supported source/target values + for (String source : RETIRED_SOURCES) { + fail("-source " + source, "-target " + source, "Base.java"); + } if (failedCases > 0) { System.err.println("failedCases = " + String.valueOf(failedCases)); @@ -252,7 +287,17 @@ protected void checksrc111(String... args) { printargs("checksrc111", args); - checksrc110(args); + int asize = args.length; + String[] newargs = new String[asize+1]; + System.arraycopy(args, 0, newargs,0 , asize); + newargs[asize] = "New17.java"; + pass(newargs); + newargs[asize] = "New18.java"; + pass(newargs); + newargs[asize] = "New110.java"; + pass(newargs); + newargs[asize] = "New111.java"; + pass(newargs); } protected void checksrc112(String... args) { @@ -399,6 +444,17 @@ "} \n" ); + /* + * Create a file with a new feature in 11, not in 10 : var for lambda parameters + */ + writeSourceFile("New111.java", + "public class New111 { \n" + + " static java.util.function.Function f = (var x) -> x.substring(0);\n" + + " void m(String name) { \n" + + " var tmp = new Thread(() -> { }, f.apply(name)); \n" + + " } \n" + + "} \n" + ); } protected boolean checkClassFileVersion