--- old/src/hotspot/share/classfile/sharedClassUtil.cpp 2017-12-01 10:45:37.311921249 -0800 +++ new/src/hotspot/share/classfile/sharedClassUtil.cpp 2017-12-01 10:45:36.903905626 -0800 @@ -141,23 +141,26 @@ ResourceMark rm(THREAD); jint manifest_size; bool isSigned; - char* manifest = ClassLoaderExt::read_manifest(cpe, &manifest_size, CHECK); - if (manifest != NULL) { - ManifestStream* stream = new ManifestStream((u1*)manifest, - manifest_size); - isSigned = stream->check_is_signed(); - if (isSigned) { - ent->_is_signed = true; - } else { - // Copy the manifest into the shared archive - manifest = ClassLoaderExt::read_raw_manifest(cpe, &manifest_size, CHECK); - Array* buf = MetadataFactory::new_array(loader_data, - manifest_size, - THREAD); - char* p = (char*)(buf->data()); - memcpy(p, manifest, manifest_size); - ent->set_manifest(buf); - ent->_is_signed = false; + + if (cpe->is_jar_file()) { + char* manifest = ClassLoaderExt::read_manifest(cpe, &manifest_size, CHECK); + if (manifest != NULL) { + ManifestStream* stream = new ManifestStream((u1*)manifest, + manifest_size); + isSigned = stream->check_is_signed(); + if (isSigned) { + ent->_is_signed = true; + } else { + // Copy the manifest into the shared archive + manifest = ClassLoaderExt::read_raw_manifest(cpe, &manifest_size, CHECK); + Array* buf = MetadataFactory::new_array(loader_data, + manifest_size, + THREAD); + char* p = (char*)(buf->data()); + memcpy(p, manifest, manifest_size); + ent->set_manifest(buf); + ent->_is_signed = false; + } } } } --- /dev/null 2017-05-05 06:40:48.273288351 -0700 +++ new/test/hotspot/jtreg/runtime/appcds/DirClasspathTest.java 2017-12-01 10:45:37.751938098 -0800 @@ -0,0 +1,54 @@ +/* + * 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. + * + */ + +/* + * @test + * @summary AppCDS handling of directories in -cp + * AppCDS does not support uncompressed oops + * @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true) + * @library /test/lib + * @run main DirClasspathTest + */ + +import jdk.test.lib.process.OutputAnalyzer; +import java.io.File; + +public class DirClasspathTest { + public static void main(String[] args) throws Exception { + File dir = new File(System.getProperty("test.classes", ".")); + File emptydir = new File(dir, "emptydir"); + emptydir.mkdir(); + + // Empty dir in -cp: should be OK + OutputAnalyzer output; + output = TestCommon.dump(emptydir.getPath(), TestCommon.list("DoesntMatter")); + TestCommon.checkDump(output); + + // Non-empty dir in -cp: should fail + // is not empty because it has at least one subdirectory, i.e., + output = TestCommon.dump(dir.getPath(), TestCommon.list("DoesntMatter")); + output.shouldNotHaveExitValue(0); + output.shouldContain("CDS allows only empty directories in archived classpaths"); + } +}