author | twisti |
Tue, 28 Aug 2012 14:57:43 -0700 | |
changeset 13613 | 4009af23799c |
parent 13610 | 28122b96858e |
child 19388 | 188246066dbb |
permissions | -rw-r--r-- |
9859
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
1 |
/* |
13613
4009af23799c
7194662: JSR 292: PermuteArgsTest times out in nightly test runs
twisti
parents:
13610
diff
changeset
|
2 |
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. |
9859
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
4 |
* |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
10 |
* |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
15 |
* accompanied this code). |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
16 |
* |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
20 |
* |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
23 |
* questions. |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
24 |
*/ |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
25 |
|
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
26 |
/* @test |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
27 |
* @summary unit tests for method handles which permute their arguments |
13613
4009af23799c
7194662: JSR 292: PermuteArgsTest times out in nightly test runs
twisti
parents:
13610
diff
changeset
|
28 |
* @run junit/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies -ea -esa -DPermuteArgsTest.MAX_ARITY=8 test.java.lang.invoke.PermuteArgsTest |
9859
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
29 |
*/ |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
30 |
/* Examples of manual runs: |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
31 |
* java -DPermuteArgsTest.{DRY_RUN=true,MAX_ARITY=253} test.java.lang.invoke.PermuteArgsTest |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
32 |
* java -DPermuteArgsTest.{VERBOSE=true,MAX_ARITY=5} test.java.lang.invoke.PermuteArgsTest |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
33 |
* java test.java.lang.invoke.PermuteArgsTest list3I[2,0,1] listJLJ[2,0,1] |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
34 |
*/ |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
35 |
|
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
36 |
package test.java.lang.invoke; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
37 |
|
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
38 |
import org.junit.*; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
39 |
|
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
40 |
import java.util.*; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
41 |
import java.lang.reflect.*; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
42 |
|
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
43 |
import java.lang.invoke.*; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
44 |
import static java.lang.invoke.MethodHandles.*; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
45 |
import static java.lang.invoke.MethodType.*; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
46 |
|
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
47 |
public class PermuteArgsTest { |
11534
9949ffb8eb3a
7117167: Misc warnings in java.lang.invoke and sun.invoke.*
jrose
parents:
9859
diff
changeset
|
48 |
private static final Class<?> CLASS = PermuteArgsTest.class; |
9859
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
49 |
private static final int MAX_ARITY = Integer.getInteger(CLASS.getSimpleName()+".MAX_ARITY", 8); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
50 |
private static final boolean DRY_RUN = Boolean.getBoolean(CLASS.getSimpleName()+".DRY_RUN"); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
51 |
private static final boolean VERBOSE = Boolean.getBoolean(CLASS.getSimpleName()+".VERBOSE") || DRY_RUN; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
52 |
|
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
53 |
static Object list2I(int x, int y) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
54 |
return Arrays.asList(x, y); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
55 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
56 |
static Object list3I(int x, int y, int z) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
57 |
return Arrays.asList(x, y, z); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
58 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
59 |
static Object list4I(int w, int x, int y, int z) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
60 |
return Arrays.asList(w, x, y, z); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
61 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
62 |
static Object list2J(long x, long y) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
63 |
return Arrays.asList(x, y); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
64 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
65 |
static Object list3J(long x, long y, long z) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
66 |
return Arrays.asList(x, y, z); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
67 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
68 |
static Object list4J(long w, long x, long y, long z) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
69 |
return Arrays.asList(w, x, y, z); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
70 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
71 |
static Object list2I2J(int w, int x, long y, long z) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
72 |
return Arrays.asList(w, x, y, z); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
73 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
74 |
static Object list2J2I(long w, long x, int y, int z) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
75 |
return Arrays.asList(w, x, y, z); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
76 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
77 |
static Object listLJJ(Object x, long y, long z) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
78 |
return Arrays.asList(x, y, z); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
79 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
80 |
static Object listJLJ(long x, Object y, long z) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
81 |
return Arrays.asList(x, y, z); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
82 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
83 |
static Object listJJL(long x, long y, Object z) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
84 |
return Arrays.asList(x, y, z); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
85 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
86 |
static Object listJLL(long x, Object y, Object z) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
87 |
return Arrays.asList(x, y, z); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
88 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
89 |
static Object listLJL(Object x, long y, Object z) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
90 |
return Arrays.asList(x, y, z); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
91 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
92 |
static Object listLLJ(Object x, Object y, long z) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
93 |
return Arrays.asList(x, y, z); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
94 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
95 |
static Object listJLLJ(long w, Object x, Object y, long z) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
96 |
return Arrays.asList(w, x, y, z); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
97 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
98 |
static Object listLJJL(Object w, long x, long y, Object z) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
99 |
return Arrays.asList(w, x, y, z); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
100 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
101 |
static Object listI_etc(int... va) { |
11534
9949ffb8eb3a
7117167: Misc warnings in java.lang.invoke and sun.invoke.*
jrose
parents:
9859
diff
changeset
|
102 |
ArrayList<Object> res = new ArrayList<>(); |
9859
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
103 |
for (int x : va) res.add(x); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
104 |
return res; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
105 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
106 |
static Object listIJL_etc(int x, long y, Object z, Object... va) { |
11534
9949ffb8eb3a
7117167: Misc warnings in java.lang.invoke and sun.invoke.*
jrose
parents:
9859
diff
changeset
|
107 |
ArrayList<Object> res = new ArrayList<>(); |
9859
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
108 |
res.addAll(Arrays.asList(x, y, z)); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
109 |
res.addAll(Arrays.asList(va)); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
110 |
return res; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
111 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
112 |
|
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
113 |
public static void main(String argv[]) throws Throwable { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
114 |
if (argv.length > 0) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
115 |
for (String arg : argv) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
116 |
// arg ::= name[n,...] |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
117 |
int k = arg.indexOf('['); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
118 |
String mhName = arg.substring(0, k).trim(); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
119 |
String permString = arg.substring(k); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
120 |
testOnePermutation(mhName, permString); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
121 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
122 |
return; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
123 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
124 |
new PermuteArgsTest().test(); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
125 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
126 |
static int testCases; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
127 |
@Test |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
128 |
public void test() throws Throwable { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
129 |
testCases = 0; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
130 |
Lookup lookup = lookup(); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
131 |
for (Method m : lookup.lookupClass().getDeclaredMethods()) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
132 |
if (m.getName().startsWith("list") && |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
133 |
Modifier.isStatic(m.getModifiers())) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
134 |
test(m.getName(), lookup.unreflect(m)); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
135 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
136 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
137 |
System.out.println("ran a total of "+testCases+" test cases"); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
138 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
139 |
|
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
140 |
static int jump(int i, int min, int max) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
141 |
if (i >= min && i <= max-1) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
142 |
// jump faster |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
143 |
int len = max-min; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
144 |
if (i < min + len/2) |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
145 |
i = min + len/2; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
146 |
else |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
147 |
i = max-1; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
148 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
149 |
return i; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
150 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
151 |
|
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
152 |
static void test(String name, MethodHandle mh) throws Throwable { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
153 |
if (VERBOSE) |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
154 |
System.out.println("mh = "+name+" : "+mh+" { " |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
155 |
+Arrays.toString(junkArgs(mh.type().parameterArray()))); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
156 |
int testCases0 = testCases; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
157 |
if (!mh.isVarargsCollector()) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
158 |
// normal case |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
159 |
testPermutations(mh); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
160 |
} else { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
161 |
// varargs case; add params up to MAX_ARITY |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
162 |
MethodType mt = mh.type(); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
163 |
int posArgs = mt.parameterCount() - 1; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
164 |
int arity0 = Math.max(3, posArgs); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
165 |
for (int arity = arity0; arity <= MAX_ARITY; arity++) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
166 |
MethodHandle mh1; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
167 |
try { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
168 |
mh1 = adjustArity(mh, arity); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
169 |
} catch (IllegalArgumentException ex) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
170 |
System.out.println("*** mh = "+name+" : "+mh+"; arity = "+arity+" => "+ex); |
11534
9949ffb8eb3a
7117167: Misc warnings in java.lang.invoke and sun.invoke.*
jrose
parents:
9859
diff
changeset
|
171 |
ex.printStackTrace(System.out); |
9859
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
172 |
break; // cannot get this arity for this type |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
173 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
174 |
test("("+arity+")"+name, mh1); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
175 |
arity = jump(arity, arity0*2, MAX_ARITY); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
176 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
177 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
178 |
if (VERBOSE) |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
179 |
System.out.println("ran "+(testCases - testCases0)+" test cases for "+name+" }"); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
180 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
181 |
|
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
182 |
static MethodHandle adjustArity(MethodHandle mh, int arity) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
183 |
MethodType mt = mh.type(); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
184 |
int posArgs = mt.parameterCount() - 1; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
185 |
Class<?> reptype = mt.parameterType(posArgs).getComponentType(); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
186 |
MethodType mt1 = mt.dropParameterTypes(posArgs, posArgs+1); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
187 |
while (mt1.parameterCount() < arity) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
188 |
Class<?> pt = reptype; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
189 |
if (pt == Object.class && posArgs > 0) |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
190 |
// repeat types cyclically if possible: |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
191 |
pt = mt1.parameterType(mt1.parameterCount() - posArgs); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
192 |
mt1 = mt1.appendParameterTypes(pt); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
193 |
} |
13610
28122b96858e
7191102: nightly failures after JSR 292 lazy method handle update (round 3)
jrose
parents:
11534
diff
changeset
|
194 |
try { |
28122b96858e
7191102: nightly failures after JSR 292 lazy method handle update (round 3)
jrose
parents:
11534
diff
changeset
|
195 |
return mh.asType(mt1); |
28122b96858e
7191102: nightly failures after JSR 292 lazy method handle update (round 3)
jrose
parents:
11534
diff
changeset
|
196 |
} catch (WrongMethodTypeException | IllegalArgumentException ex) { |
28122b96858e
7191102: nightly failures after JSR 292 lazy method handle update (round 3)
jrose
parents:
11534
diff
changeset
|
197 |
throw new IllegalArgumentException("cannot convert to type "+mt1+" from "+mh, ex); |
28122b96858e
7191102: nightly failures after JSR 292 lazy method handle update (round 3)
jrose
parents:
11534
diff
changeset
|
198 |
} |
9859
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
199 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
200 |
static MethodHandle findTestMH(String name, int[] perm) throws ReflectiveOperationException { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
201 |
int arity = perm.length; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
202 |
Lookup lookup = lookup(); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
203 |
for (Method m : lookup.lookupClass().getDeclaredMethods()) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
204 |
if (m.getName().equals(name) && |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
205 |
Modifier.isStatic(m.getModifiers())) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
206 |
MethodHandle mh = lookup.unreflect(m); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
207 |
int mhArity = mh.type().parameterCount(); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
208 |
if (mh.isVarargsCollector()) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
209 |
if (mhArity-1 <= arity) |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
210 |
return adjustArity(mh, arity); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
211 |
} else if (mhArity == arity) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
212 |
return mh; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
213 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
214 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
215 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
216 |
throw new RuntimeException("no such method for arity "+arity+": "+name); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
217 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
218 |
|
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
219 |
static void testPermutations(MethodHandle mh) throws Throwable { |
11534
9949ffb8eb3a
7117167: Misc warnings in java.lang.invoke and sun.invoke.*
jrose
parents:
9859
diff
changeset
|
220 |
HashSet<String> done = new HashSet<>(); |
9859
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
221 |
MethodType mt = mh.type(); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
222 |
int[] perm = nullPerm(mt.parameterCount()); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
223 |
final int MARGIN = (perm.length <= 10 ? 2 : 0); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
224 |
int testCases0 = testCases; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
225 |
for (int j = 0; j <= 1; j++) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
226 |
int maxStart = perm.length-1; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
227 |
if (j != 0) maxStart /= 2; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
228 |
for (int start = 0; start <= maxStart; start++) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
229 |
int maxOmit = (maxStart - start) / 2; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
230 |
if (start != 0) maxOmit = 2; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
231 |
if (j != 0) maxOmit = 1; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
232 |
for (int omit = 0; omit <= maxOmit; omit++) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
233 |
int end = perm.length - omit; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
234 |
if (end - start >= 2) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
235 |
//System.out.println("testPermutations"+Arrays.asList(start, end)+(j == 0 ? "" : " (reverse)")); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
236 |
testPermutations(mh, perm, start, end, done); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
237 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
238 |
omit = jump(omit, (start == 0 && j == 0 ? MARGIN : 0), maxOmit); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
239 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
240 |
start = jump(start, (j == 0 ? MARGIN : 0), maxStart); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
241 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
242 |
// do everything in reverse: |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
243 |
reverse(perm, 0, perm.length); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
244 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
245 |
switch (perm.length) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
246 |
case 2: assert(testCases - testCases0 == 2); break; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
247 |
case 3: assert(testCases - testCases0 == 6); break; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
248 |
case 4: assert(testCases - testCases0 == 24); break; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
249 |
case 5: assert(testCases - testCases0 == 120); break; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
250 |
case 6: assert(testCases - testCases0 > 720/3); break; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
251 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
252 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
253 |
|
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
254 |
static void testPermutations(MethodHandle mh, int[] perm, int start, int end, Set<String> done) throws Throwable { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
255 |
if (end - start <= 1) return; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
256 |
for (int j = 0; j <= 1; j++) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
257 |
testRotations(mh, perm, start, end, done); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
258 |
if (end - start <= 2) return; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
259 |
reverse(perm, start, end); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
260 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
261 |
if (end - start <= 3) return; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
262 |
int excess4 = (end - start) - 4; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
263 |
// composed rotations: |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
264 |
int start2 = start + 1 + excess4/3; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
265 |
int end2 = end - excess4/3; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
266 |
end2 = start2 + Math.min(start == 0 ? 4 : 3, end2 - start2); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
267 |
int skips = (perm.length+3)/5; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
268 |
for (int i = start; i < end; i++) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
269 |
rotate(perm, start, end); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
270 |
if (skips > 1 && ((i-start) + (i-start)/7) % skips != 0) continue; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
271 |
for (int j = 0; j <= 1; j++) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
272 |
testPermutations(mh, perm, start2, end2, done); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
273 |
reverse(perm, start, end); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
274 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
275 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
276 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
277 |
|
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
278 |
static void testRotations(MethodHandle mh, int[] perm, int start, int end, Set<String> done) throws Throwable { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
279 |
Object[] args = junkArgs(mh.type().parameterArray()); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
280 |
for (int i = start; i < end; i++) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
281 |
if (done.add(Arrays.toString(perm))) |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
282 |
testOnePermutation(mh, perm, args); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
283 |
rotate(perm, start, end); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
284 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
285 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
286 |
|
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
287 |
static void testOnePermutation(MethodHandle mh, int[] perm, Object[] args) throws Throwable { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
288 |
MethodType mt = mh.type(); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
289 |
MethodType pmt = methodType(mt.returnType(), unpermuteArgs(perm, mt.parameterArray(), Class[].class)); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
290 |
if (VERBOSE) |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
291 |
System.out.println(Arrays.toString(perm)); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
292 |
testCases += 1; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
293 |
if (DRY_RUN) |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
294 |
return; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
295 |
Object res = permuteArguments(mh, pmt, perm).invokeWithArguments(unpermuteArgs(perm, args)); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
296 |
String str = String.valueOf(res); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
297 |
if (!Arrays.toString(args).equals(str)) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
298 |
System.out.println(Arrays.toString(perm)+" "+str+" *** WRONG ***"); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
299 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
300 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
301 |
|
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
302 |
// For reproducing failures: |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
303 |
static void testOnePermutation(String mhName, String permString) throws Throwable { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
304 |
String s = permString; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
305 |
s = s.replace('[', ' ').replace(']', ' ').replace(',', ' '); // easier to trim spaces |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
306 |
s = s.trim(); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
307 |
int[] perm = new int[s.length()]; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
308 |
int arity = 0; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
309 |
while (!s.isEmpty()) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
310 |
int k = s.indexOf(' '); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
311 |
if (k < 0) k = s.length(); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
312 |
perm[arity++] = Integer.parseInt(s.substring(0, k)); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
313 |
s = s.substring(k).trim(); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
314 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
315 |
perm = Arrays.copyOf(perm, arity); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
316 |
testOnePermutation(mhName, perm); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
317 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
318 |
static void testOnePermutation(String mhName, int[] perm) throws Throwable { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
319 |
MethodHandle mh = findTestMH(mhName, perm); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
320 |
System.out.println("mh = "+mhName+" : "+mh+" { " |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
321 |
+Arrays.toString(junkArgs(mh.type().parameterArray()))); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
322 |
Object[] args = junkArgs(mh.type().parameterArray()); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
323 |
testOnePermutation(mh, perm, args); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
324 |
System.out.println("}"); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
325 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
326 |
|
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
327 |
static Object[] junkArgs(Class<?>[] ptypes) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
328 |
Object[] args = new Object[ptypes.length]; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
329 |
for (int i = 0; i < ptypes.length; i++) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
330 |
Class<?> pt = ptypes[i]; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
331 |
Object arg; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
332 |
if (pt == Void.class) arg = null; |
11534
9949ffb8eb3a
7117167: Misc warnings in java.lang.invoke and sun.invoke.*
jrose
parents:
9859
diff
changeset
|
333 |
else if (pt == int.class) arg = i + 101; |
9949ffb8eb3a
7117167: Misc warnings in java.lang.invoke and sun.invoke.*
jrose
parents:
9859
diff
changeset
|
334 |
else if (pt == long.class) arg = i + 10_000_000_001L; |
9859
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
335 |
else arg = "#" + (i + 1); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
336 |
args[i] = arg; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
337 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
338 |
return args; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
339 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
340 |
|
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
341 |
static int[] nullPerm(int len) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
342 |
int[] perm = new int[len]; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
343 |
for (int i = 0; i < len; i++) |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
344 |
perm[i] = i; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
345 |
return perm; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
346 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
347 |
static void rotate(int[] perm) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
348 |
rotate(perm, 0, perm.length); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
349 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
350 |
static void rotate(int[] perm, int start, int end) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
351 |
int x = perm[end-1]; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
352 |
for (int j = start; j < end; j++) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
353 |
int y = perm[j]; perm[j] = x; x = y; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
354 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
355 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
356 |
static void reverse(int[] perm) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
357 |
reverse(perm, 0, perm.length); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
358 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
359 |
static void reverse(int[] perm, int start, int end) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
360 |
int mid = start + (end - start)/2; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
361 |
for (int j = start; j < mid; j++) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
362 |
int k = (end-1) - j; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
363 |
int x = perm[j]; perm[j] = perm[k]; perm[k] = x; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
364 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
365 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
366 |
// Permute the args according to the inverse of perm. |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
367 |
static Object[] unpermuteArgs(int[] perm, Object[] args) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
368 |
return unpermuteArgs(perm, args, Object[].class); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
369 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
370 |
static <T> T[] unpermuteArgs(int[] perm, T[] args, Class<T[]> Tclass) { |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
371 |
T[] res = Arrays.copyOf(new Object[0], perm.length, Tclass); |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
372 |
for (int i = 0; i < perm.length; i++) |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
373 |
res[perm[i]] = args[i]; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
374 |
return res; |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
375 |
} |
47e26ad535c4
7052202: JSR 292: Crash in sun.invoke.util.ValueConversions.fillArray
jrose
parents:
diff
changeset
|
376 |
} |