23 |
23 |
24 /* |
24 /* |
25 * @test |
25 * @test |
26 * @bug 4329886 |
26 * @bug 4329886 |
27 * @summary Clone() on arrays compiled incorrectly |
27 * @summary Clone() on arrays compiled incorrectly |
28 * @author gafter |
28 * @author gafter jjg |
29 * |
|
30 * @ignore Waiting for javap bug 4650860 to be fixed. |
|
31 * |
|
32 * @run shell ArrayClone.sh |
|
33 */ |
29 */ |
34 |
30 |
|
31 import java.io.*; |
|
32 |
35 /** The qualifying type in the code for array.clone() should be the array type. */ |
33 /** The qualifying type in the code for array.clone() should be the array type. */ |
36 class ArrayClone { |
34 public class ArrayClone { |
|
35 public static void main(String[] args) { |
|
36 new ArrayClone().run(); |
|
37 } |
|
38 |
|
39 public void run() { |
|
40 String[] args = { "-classpath", System.getProperty("test.classes", "."), "-v", "Test" }; |
|
41 StringWriter sw = new StringWriter(); |
|
42 PrintWriter pw = new PrintWriter(sw); |
|
43 int rc = com.sun.tools.javap.Main.run(args, pw); |
|
44 if (rc != 0) |
|
45 throw new Error("javap failed; exit " + rc); |
|
46 |
|
47 String out = sw.toString(); |
|
48 System.out.println(out); |
|
49 |
|
50 for (String line: out.split("\n")) { |
|
51 String match = "[ \t]+[0-9]+:[ \t]+invokevirtual[ \t]+#[0-9]+; //Method \"\\[Ljava/lang/String;\".clone:\\(\\)Ljava/lang/Object;"; |
|
52 if (line.matches(match)) |
|
53 return; |
|
54 } |
|
55 throw new Error("expected string not found in javap output"); |
|
56 } |
|
57 } |
|
58 |
|
59 class Test { |
37 public static void main(String[] args) { |
60 public static void main(String[] args) { |
38 args.clone(); |
61 args.clone(); |
39 } |
62 } |
40 } |
63 } |