RFR: 7044282: (reflect) Class.forName and Array.newInstance are inconsistent regarding multidimensional arrays

Paul Sandoz paul.sandoz at oracle.com
Thu Oct 10 09:27:36 UTC 2013


On Oct 9, 2013, at 8:33 PM, Joel Borggren-Franck <joel.franck at oracle.com> wrote:

> Hi
> 
> Please review this spec update and test for getting array classes and
> instances of more dimensions than the class file can express or the VM
> can handle.
> 
> Array.newInstance have a test for arrays of more dimensions than 255,
> this patch adds a test for Class.forName as well.
> 
> Also the javadoc for Array.newInstance are clarified.
> 
> Bug: https://bugs.openjdk.java.net/browse/JDK-7044282
> Webrev: http://cr.openjdk.java.net/~jfranck/7044282/webrev.00/
> 

Looks OK, i agree with Joe on the test refactoring.

FYI (because i have streams on my brain...).

String brackets254 = Stream.generate(() -> "[").limit(254).collect(joining());

or:

String name254 = Stream.generate(() -> "[").limit(254).collect(joining("", "", "Ljava.lang.String;"));

or:

IntFunction<String> nameN = (int n) ->  Stream.generate(() -> "[").limit(n).collect(joining("", "", "Ljava.lang.String;"));
String name254 = nameN.apply(254);
String name254 = nameN.apply(255);
String name254 = nameN.apply(256);
String name1 = nameN.apply(1);
String bigName = nameN.apply(Short.MAX_VALUE + 20);

Paul.

> cheers
> /Joel



More information about the core-libs-dev mailing list