test/runtime/LoadClass/LoadClassNegative.java

Mon, 26 Aug 2013 14:11:26 -0700

author
ccheung
date
Mon, 26 Aug 2013 14:11:26 -0700
changeset 5603
7e7dd25666da
child 6133
e567d5afd4dd
permissions
-rw-r--r--

8020675: invalid jar file in the bootclasspath could lead to jvm fatal error
Summary: removed offending EXCEPTION_MARK calls and code cleanup
Reviewed-by: dholmes, iklam, coleenp, mseledtsov

ccheung@5603 1 /*
ccheung@5603 2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
ccheung@5603 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ccheung@5603 4 *
ccheung@5603 5 * This code is free software; you can redistribute it and/or modify it
ccheung@5603 6 * under the terms of the GNU General Public License version 2 only, as
ccheung@5603 7 * published by the Free Software Foundation.
ccheung@5603 8 *
ccheung@5603 9 * This code is distributed in the hope that it will be useful, but WITHOUT
ccheung@5603 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ccheung@5603 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ccheung@5603 12 * version 2 for more details (a copy is included in the LICENSE file that
ccheung@5603 13 * accompanied this code).
ccheung@5603 14 *
ccheung@5603 15 * You should have received a copy of the GNU General Public License version
ccheung@5603 16 * 2 along with this work; if not, write to the Free Software Foundation,
ccheung@5603 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ccheung@5603 18 *
ccheung@5603 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ccheung@5603 20 * or visit www.oracle.com if you need additional information or have any
ccheung@5603 21 * questions.
ccheung@5603 22 */
ccheung@5603 23
ccheung@5603 24 /*
ccheung@5603 25 * @test
ccheung@5603 26 * @key regression
ccheung@5603 27 * @bug 8020675
ccheung@5603 28 * @summary make sure there is no fatal error if a class is loaded from an invalid jar file which is in the bootclasspath
ccheung@5603 29 * @library /testlibrary
ccheung@5603 30 * @build TestForName
ccheung@5603 31 * @build LoadClassNegative
ccheung@5603 32 * @run main LoadClassNegative
ccheung@5603 33 */
ccheung@5603 34
ccheung@5603 35 import java.io.File;
ccheung@5603 36 import com.oracle.java.testlibrary.*;
ccheung@5603 37
ccheung@5603 38 public class LoadClassNegative {
ccheung@5603 39
ccheung@5603 40 public static void main(String args[]) throws Exception {
ccheung@5603 41 String bootCP = "-Xbootclasspath/a:" + System.getProperty("test.src")
ccheung@5603 42 + File.separator + "dummy.jar";
ccheung@5603 43 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
ccheung@5603 44 bootCP,
ccheung@5603 45 "TestForName");
ccheung@5603 46
ccheung@5603 47 OutputAnalyzer output = new OutputAnalyzer(pb.start());
ccheung@5603 48 output.shouldContain("ClassNotFoundException");
ccheung@5603 49 output.shouldHaveExitValue(0);
ccheung@5603 50 }
ccheung@5603 51 }

mercurial