--- old/src/share/vm/classfile/sharedPathsMiscInfo.cpp 2016-02-17 17:04:44.790324343 -0500 +++ new/src/share/vm/classfile/sharedPathsMiscInfo.cpp 2016-02-17 17:04:44.614327704 -0500 @@ -26,14 +26,18 @@ #include "classfile/classLoader.hpp" #include "classfile/classLoaderData.inline.hpp" #include "classfile/sharedPathsMiscInfo.hpp" +#include "logging/log.hpp" #include "memory/allocation.inline.hpp" #include "memory/metaspaceShared.hpp" #include "runtime/arguments.hpp" +#include "utilities/ostream.hpp" void SharedPathsMiscInfo::add_path(const char* path, int type) { - if (TraceClassPaths) { - tty->print("[type=%s] ", type_name(type)); - trace_class_path("[Add misc shared path ", path); + if (log_is_enabled(Info, classpath)) { + ResourceMark rm; + outputStream* log = LogHandle(classpath)::info_stream(); + log->print("type=%s ", type_name(type)); + ClassLoader::trace_class_path(log, "add misc shared path ", path); } write(path, strlen(path) + 1); write_jint(jint(type)); @@ -90,17 +94,18 @@ if (!read_jint(&type)) { return fail("Corrupted archive file header"); } - if (TraceClassPaths) { - tty->print("[type=%s ", type_name(type)); - print_path(tty, type, path); - tty->print_cr("]"); + if (log_is_enabled(Info, classpath)) { + ResourceMark rm; + outputStream* log = LogHandle(classpath)::info_stream(); + log->print("type=%s ", type_name(type)); + print_path(log, type, path); } if (!check(type, path)) { if (!PrintSharedArchiveAndExit) { return false; } } else { - trace_class_path("[ok"); + trace_class_path("[ok]"); } } --- /dev/null 2015-11-21 16:36:38.509275105 -0500 +++ new/test/runtime/logging/ClassPathTest.java 2016-02-17 17:04:44.584002703 -0500 @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + +/* + * @test ClassPathTest + * @bug 8142976 + * @library /testlibrary + * @build jdk.test.lib.OutputAnalyzer jdk.test.lib.Platform jdk.test.lib.ProcessTools + * @run driver ClassPathTest + */ + +import jdk.test.lib.OutputAnalyzer; +import jdk.test.lib.Platform; +import jdk.test.lib.ProcessTools; + +public class ClassPathTest { + + public static void main(String... args) throws Exception { + + // Test for classpath tag. + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:classpath=info", + "-Xmx64m", + InnerClass.class.getName()); + OutputAnalyzer out = new OutputAnalyzer(pb.start()); + out.getOutput(); + out.shouldContain("[classpath]"); + + // Make sure TraceClassPaths is properly aliased. + pb = ProcessTools.createJavaProcessBuilder("-XX:+TraceClassPaths", + "-Xmx64m", + InnerClass.class.getName()); + out = new OutputAnalyzer(pb.start()); + out.shouldContain("[classpath]"); + } + public static class InnerClass { + public static void main(String[] args) throws Exception { + System.out.println("Inner Class"); + } + } +} --- old/src/share/vm/memory/filemap.cpp 2016-02-17 17:04:44.762885217 -0500 +++ new/src/share/vm/memory/filemap.cpp 2016-02-17 17:04:44.614332741 -0500 @@ -208,9 +208,7 @@ count ++; bytes += (int)entry_size; bytes += name_bytes; - if (TraceClassPaths) { - tty->print_cr("[Add main shared path (%s) %s]", (cpe->is_jar_file() ? "jar" : "dir"), name); - } + log_info(classpath)("add main shared path (%s) %s", (cpe->is_jar_file() ? "jar" : "dir"), name); } else { SharedClassPathEntry* ent = shared_classpath(cur_entry); if (cpe->is_jar_file()) { @@ -275,9 +273,7 @@ struct stat st; const char* name = ent->_name; bool ok = true; - if (TraceClassPaths) { - tty->print_cr("[Checking shared classpath entry: %s]", name); - } + log_info(classpath)("checking shared classpath entry: %s", name); if (os::stat(name, &st) != 0) { fail_continue("Required classpath entry does not exist: %s", name); ok = false; @@ -301,9 +297,7 @@ } } if (ok) { - if (TraceClassPaths) { - tty->print_cr("[ok]"); - } + log_info(classpath)("ok"); } else if (!PrintSharedArchiveAndExit) { _validating_classpath_entry_table = false; return false; @@ -888,10 +882,8 @@ char header_version[JVM_IDENT_MAX]; get_header_version(header_version); if (strncmp(_jvm_ident, header_version, JVM_IDENT_MAX-1) != 0) { - if (TraceClassPaths) { - tty->print_cr("Expected: %s", header_version); - tty->print_cr("Actual: %s", _jvm_ident); - } + log_info(classpath)("expected: %s", header_version); + log_info(classpath)("actual: %s", _jvm_ident); FileMapInfo::fail_continue("The shared archive file was created by a different" " version or build of HotSpot"); return false; @@ -919,7 +911,7 @@ if (status) { if (!ClassLoader::check_shared_paths_misc_info(_paths_misc_info, _header->_paths_misc_info_size)) { if (!PrintSharedArchiveAndExit) { - fail_continue("shared class paths mismatch (hint: enable -XX:+TraceClassPaths to diagnose the failure)"); + fail_continue("shared class paths mismatch (hint: enable -Xlog:classpath=info to diagnose the failure)"); status = false; } } --- old/src/share/vm/classfile/classLoader.cpp 2016-02-17 17:04:44.809662695 -0500 +++ new/src/share/vm/classfile/classLoader.cpp 2016-02-17 17:04:44.610070922 -0500 @@ -37,6 +37,7 @@ #include "gc/shared/generation.hpp" #include "interpreter/bytecodeStream.hpp" #include "interpreter/oopMapCache.hpp" +#include "logging/logTag.hpp" #include "memory/allocation.inline.hpp" #include "memory/filemap.hpp" #include "memory/oopFactory.hpp" @@ -417,16 +418,15 @@ #if INCLUDE_CDS void ClassLoader::exit_with_path_failure(const char* error, const char* message) { assert(DumpSharedSpaces, "only called at dump time"); - tty->print_cr("Hint: enable -XX:+TraceClassPaths to diagnose the failure"); + tty->print_cr("Hint: enable -Xlog:classpath=info to diagnose the failure"); vm_exit_during_initialization(error, message); } #endif void ClassLoader::trace_class_path(outputStream* out, const char* msg, const char* name) { - if (!TraceClassPaths) { + if (!log_is_enabled(Info, classpath)) { return; } - if (msg) { out->print("%s", msg); } @@ -578,9 +578,7 @@ } } } - if (TraceClassPaths) { - tty->print_cr("[Opened %s]", path); - } + log_info(classpath)("opened: %s", path); log_info(classload)("opened: %s", path); } else { // Directory --- old/src/share/vm/logging/logTag.hpp 2016-02-17 17:04:44.826548420 -0500 +++ new/src/share/vm/logging/logTag.hpp 2016-02-17 17:04:44.626951251 -0500 @@ -42,6 +42,7 @@ LOG_TAG(classload) /* Trace all classes loaded */ \ LOG_TAG(classloaderdata) /* class loader loader_data lifetime */ \ LOG_TAG(classunload) /* Trace unloading of classes */ \ + LOG_TAG(classpath) \ LOG_TAG(compaction) \ LOG_TAG(cpu) \ LOG_TAG(cset) \ --- old/src/share/vm/runtime/arguments.cpp 2016-02-17 17:04:44.826803022 -0500 +++ new/src/share/vm/runtime/arguments.cpp 2016-02-17 17:04:44.683206892 -0500 @@ -405,8 +405,9 @@ static AliasedLoggingFlag const aliased_logging_flags[] = { { "TraceClassLoading", LogLevel::Info, true, LogTag::_classload }, - { "TraceClassUnloading", LogLevel::Info, true, LogTag::_classunload }, + { "TraceClassPaths", LogLevel::Info, true, LogTag::_classpath }, { "TraceClassResolution", LogLevel::Info, true, LogTag::_classresolve }, + { "TraceClassUnloading", LogLevel::Info, true, LogTag::_classunload }, { "TraceExceptions", LogLevel::Info, true, LogTag::_exceptions }, { "TraceMonitorInflation", LogLevel::Debug, true, LogTag::_monitorinflation }, { NULL, LogLevel::Off, false, LogTag::__NO_TAG } @@ -3254,7 +3255,7 @@ // PrintSharedArchiveAndExit will turn on // -Xshare:on - // -XX:+TraceClassPaths + // -Xlog:classpath=info if (PrintSharedArchiveAndExit) { if (FLAG_SET_CMDLINE(bool, UseSharedSpaces, true) != Flag::SUCCESS) { return JNI_EINVAL; @@ -3262,9 +3263,7 @@ if (FLAG_SET_CMDLINE(bool, RequireSharedSpaces, true) != Flag::SUCCESS) { return JNI_EINVAL; } - if (FLAG_SET_CMDLINE(bool, TraceClassPaths, true) != Flag::SUCCESS) { - return JNI_EINVAL; - } + LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(classpath)); } // Change the default value for flags which have different default values --- old/src/share/vm/runtime/globals.hpp 2016-02-17 17:04:44.910043376 -0500 +++ new/src/share/vm/runtime/globals.hpp 2016-02-17 17:04:44.676679247 -0500 @@ -2409,9 +2409,6 @@ product(bool, IgnoreEmptyClassPaths, false, \ "Ignore empty path elements in -classpath") \ \ - product(bool, TraceClassPaths, false, \ - "Trace processing of class paths") \ - \ product(bool, TraceClassLoadingPreorder, false, \ "Trace all classes loaded in order referenced (not loaded)") \ \