1 /* 2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* @test 25 * @bug 8061651 26 * @summary -Dsun.cds.enableSharedLookupCache specified on the command-line 27 * should have no effect. 28 * @run main/othervm -Dsun.cds.enableSharedLookupCache=true -Xshare:off -Dfoo.foo.bar=xyz EnableLookupCache 29 */ 30 31 import java.io.*; 32 import java.net.*; 33 import java.util.zip.*; 34 35 public class EnableLookupCache { 36 public static void main(String[] args) throws Exception { 37 // If JVM is started with -Xshare:off, the sun.cds.enableSharedLookupCache 38 // should never be true, even if it has been explicitly set in the 39 // command-line. 40 String prop = "sun.cds.enableSharedLookupCache"; 41 String value = System.getProperty(prop); 42 System.out.println("System.getProperty(\"" + prop + "\") = \"" + value+ "\""); 43 44 if ("true".equals(value)) { 45 System.out.println("Test FAILED: system property " + prop + 46 " is \"true\" (unexpected)"); 47 throw new RuntimeException(prop + " should not be " + value); 48 } 49 50 // Make sure the -D... arguments in the @run tag are indeed used. 51 prop = "foo.foo.bar"; 52 value = System.getProperty(prop); 53 System.out.println("System.getProperty(\"" + prop + "\") = \"" + value+ "\""); 54 if (!"xyz".equals(value)) { 55 System.out.println("Test FAILED: system property " + prop + 56 " should be \"xyz\""); 57 throw new RuntimeException(prop + " should not be " + value); 58 } 59 60 61 // We should be able to load the other classes without issue. 62 A.test(); 63 B.test(); 64 System.out.println("Test PASSED"); 65 } 66 67 static class A {static void test() {}} 68 static class B {static void test() {}} 69 } 70