SharedStringsWb.java revision 8944:f35456fc82ae
197403Sobrien/* 297403Sobrien * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. 397403Sobrien * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 497403Sobrien * 597403Sobrien * This code is free software; you can redistribute it and/or modify it 697403Sobrien * under the terms of the GNU General Public License version 2 only, as 797403Sobrien * published by the Free Software Foundation. 897403Sobrien * 997403Sobrien * This code is distributed in the hope that it will be useful, but WITHOUT 1097403Sobrien * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1197403Sobrien * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1297403Sobrien * version 2 for more details (a copy is included in the LICENSE file that 1397403Sobrien * accompanied this code). 1497403Sobrien * 1597403Sobrien * You should have received a copy of the GNU General Public License version 1697403Sobrien * 2 along with this work; if not, write to the Free Software Foundation, 1797403Sobrien * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18169691Skan * 1997403Sobrien * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2097403Sobrien * or visit www.oracle.com if you need additional information or have any 2197403Sobrien * questions. 2297403Sobrien */ 2397403Sobrien 2497403Sobrienimport sun.hotspot.WhiteBox; 2597403Sobrien 2697403Sobrien// This class is used by the test SharedStrings.java 2797403Sobrien// It should be launched in CDS mode 2897403Sobrienpublic class SharedStringsWb { 2997403Sobrien public static void main(String[] args) throws Exception { 3097403Sobrien WhiteBox wb = WhiteBox.getWhiteBox(); 3197403Sobrien 3297403Sobrien if (wb.areSharedStringsIgnored()) { 3397403Sobrien System.out.println("Shared strings are ignored, assuming PASS"); 3497403Sobrien return; 3597403Sobrien } 3697403Sobrien 3797403Sobrien // The string below is known to be added to CDS archive 38 String s = "<init>"; 39 String internedS = s.intern(); 40 41 if (wb.isShared(internedS)) { 42 System.out.println("Found shared string, result: PASS"); 43 } else { 44 throw new RuntimeException("String is not shared, result: FAIL"); 45 } 46 } 47} 48 49 50