-
Enhancement
-
Resolution: Not an Issue
-
P3
-
repo-valhalla
For the method Arrays.copyOf:
static <T,U> T[] copyOf(U[] original, int newLength, Class<? extends T[]> newType)
The erased type is
static Object[] copyOf(Object[] original, int newLength, Class newType)
However, the following code returns a value array, which is not supposed to be castable to an Object[].
import java.util.Arrays;
public class Test {
static final value class V {
public final int v1;
private V () {v1 = 0;}
}
public static void main(String args[]) {
Object oa[] = new Object[1];
oa[0] = V.default;
System.out.println(Arrays.copyOf(oa, oa.length, V[].class).getClass());
}
}
$ java -XX:+EnableValhalla -cp . Test
class [QTest$V;
static <T,U> T[] copyOf(U[] original, int newLength, Class<? extends T[]> newType)
The erased type is
static Object[] copyOf(Object[] original, int newLength, Class newType)
However, the following code returns a value array, which is not supposed to be castable to an Object[].
import java.util.Arrays;
public class Test {
static final value class V {
public final int v1;
private V () {v1 = 0;}
}
public static void main(String args[]) {
Object oa[] = new Object[1];
oa[0] = V.default;
System.out.println(Arrays.copyOf(oa, oa.length, V[].class).getClass());
}
}
$ java -XX:+EnableValhalla -cp . Test
class [QTest$V;