ArrayClone.java revision 403:14735c7932d7
11573Srgrimes/* 21573Srgrimes * Copyright 2002-2009 Sun Microsystems, Inc. All Rights Reserved. 31573Srgrimes * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 41573Srgrimes * 51573Srgrimes * This code is free software; you can redistribute it and/or modify it 61573Srgrimes * under the terms of the GNU General Public License version 2 only, as 71573Srgrimes * published by the Free Software Foundation. 81573Srgrimes * 91573Srgrimes * This code is distributed in the hope that it will be useful, but WITHOUT 101573Srgrimes * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 111573Srgrimes * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 121573Srgrimes * version 2 for more details (a copy is included in the LICENSE file that 131573Srgrimes * accompanied this code). 141573Srgrimes * 151573Srgrimes * You should have received a copy of the GNU General Public License version 161573Srgrimes * 2 along with this work; if not, write to the Free Software Foundation, 171573Srgrimes * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 181573Srgrimes * 191573Srgrimes * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 201573Srgrimes * CA 95054 USA or visit www.sun.com if you need additional information or 211573Srgrimes * have any questions. 221573Srgrimes */ 231573Srgrimes 241573Srgrimes/* 251573Srgrimes * @test 261573Srgrimes * @bug 4329886 271573Srgrimes * @summary Clone() on arrays compiled incorrectly 281573Srgrimes * @author gafter jjg 291573Srgrimes */ 301573Srgrimes 311573Srgrimesimport java.io.*; 321573Srgrimes 3350476Speter/** The qualifying type in the code for array.clone() should be the array type. */ 341573Srgrimespublic class ArrayClone { 35200019Sbrueffer public static void main(String[] args) { 361573Srgrimes new ArrayClone().run(); 371573Srgrimes } 381573Srgrimes 39189356Sdas public void run() { 40189356Sdas String[] args = { "-classpath", System.getProperty("test.classes", "."), "-v", "Test" }; 411573Srgrimes StringWriter sw = new StringWriter(); 4259460Sphantom PrintWriter pw = new PrintWriter(sw); 4359460Sphantom int rc = com.sun.tools.javap.Main.run(args, pw); 441573Srgrimes if (rc != 0) 45189356Sdas throw new Error("javap failed; exit " + rc); 4684306Sru 471573Srgrimes String out = sw.toString(); 48103012Stjr System.out.println(out); 491573Srgrimes 50103012Stjr for (String line: out.split("(\\n|\\r\\n?)")) { 511573Srgrimes String match = "[ \t]+[0-9]+:[ \t]+invokevirtual[ \t]+#[0-9]+[ \t]+// Method \"\\[Ljava/lang/String;\".clone:\\(\\)Ljava/lang/Object;"; 52103012Stjr if (line.matches(match)) 531573Srgrimes return; 54103012Stjr } 5515931Speter throw new Error("expected string not found in javap output"); 5615931Speter } 57189356Sdas} 58200019Sbrueffer 5984306Sruclass Test { 601573Srgrimes public static void main(String[] args) { 61103012Stjr args.clone(); 621573Srgrimes } 63103012Stjr} 641573Srgrimes