Thu, 09 Dec 2010 08:24:42 -0800
4917091: javac rejects array over 128 in length
Reviewed-by: mcimadamore
1.1 --- a/src/share/classes/com/sun/tools/javac/jvm/Gen.java Thu Dec 09 15:50:57 2010 +0000 1.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/Gen.java Thu Dec 09 08:24:42 2010 -0800 1.3 @@ -1802,7 +1802,7 @@ 1.4 */ 1.5 Item makeNewArray(DiagnosticPosition pos, Type type, int ndims) { 1.6 Type elemtype = types.elemtype(type); 1.7 - if (types.dimensions(elemtype) + ndims > ClassFile.MAX_DIMENSIONS) { 1.8 + if (types.dimensions(type) > ClassFile.MAX_DIMENSIONS) { 1.9 log.error(pos, "limit.dimensions"); 1.10 nerrs++; 1.11 }
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/test/tools/javac/4917091/Test255.java Thu Dec 09 08:24:42 2010 -0800 2.3 @@ -0,0 +1,89 @@ 2.4 +/* 2.5 + * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved. 2.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.7 + * 2.8 + * This code is free software; you can redistribute it and/or modify it 2.9 + * under the terms of the GNU General Public License version 2 only, as 2.10 + * published by the Free Software Foundation. 2.11 + * 2.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 2.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 2.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 2.15 + * version 2 for more details (a copy is included in the LICENSE file that 2.16 + * accompanied this code). 2.17 + * 2.18 + * You should have received a copy of the GNU General Public License version 2.19 + * 2 along with this work; if not, write to the Free Software Foundation, 2.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2.21 + * 2.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 2.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 2.24 + * have any questions. 2.25 + */ 2.26 + 2.27 +/* 2.28 + * @test 2.29 + * @bug 4917091 2.30 + * @summary javac rejects array over 128 in length 2.31 + */ 2.32 + 2.33 + 2.34 +public class Test255 { 2.35 + public static void main(String... args) { 2.36 + // allocating an array with 255 dimensions is allowed 2.37 + Object expected = (Object)new Object 2.38 + [1/*001*/][1/*002*/][1/*003*/][1/*004*/][1/*005*/] 2.39 + [1/*006*/][1/*007*/][1/*008*/][1/*009*/][1/*010*/] 2.40 + [1/*011*/][1/*012*/][1/*013*/][1/*014*/][1/*015*/] 2.41 + [1/*016*/][1/*017*/][1/*018*/][1/*019*/][1/*020*/] 2.42 + [1/*021*/][1/*022*/][1/*023*/][1/*024*/][1/*025*/] 2.43 + [1/*026*/][1/*027*/][1/*028*/][1/*029*/][1/*030*/] 2.44 + [1/*031*/][1/*032*/][1/*033*/][1/*034*/][1/*035*/] 2.45 + [1/*036*/][1/*037*/][1/*038*/][1/*039*/][1/*040*/] 2.46 + [1/*041*/][1/*042*/][1/*043*/][1/*044*/][1/*045*/] 2.47 + [1/*046*/][1/*047*/][1/*048*/][1/*049*/][1/*050*/] 2.48 + [1/*051*/][1/*052*/][1/*053*/][1/*054*/][1/*055*/] 2.49 + [1/*056*/][1/*057*/][1/*058*/][1/*059*/][1/*060*/] 2.50 + [1/*061*/][1/*062*/][1/*063*/][1/*064*/][1/*065*/] 2.51 + [1/*066*/][1/*067*/][1/*068*/][1/*069*/][1/*070*/] 2.52 + [1/*071*/][1/*072*/][1/*073*/][1/*074*/][1/*075*/] 2.53 + [1/*076*/][1/*077*/][1/*078*/][1/*079*/][1/*080*/] 2.54 + [1/*081*/][1/*082*/][1/*083*/][1/*084*/][1/*085*/] 2.55 + [1/*086*/][1/*087*/][1/*088*/][1/*089*/][1/*090*/] 2.56 + [1/*091*/][1/*092*/][1/*093*/][1/*094*/][1/*095*/] 2.57 + [1/*096*/][1/*097*/][1/*098*/][1/*099*/][1/*100*/] 2.58 + 2.59 + [1/*101*/][1/*102*/][1/*103*/][1/*104*/][1/*105*/] 2.60 + [1/*106*/][1/*107*/][1/*108*/][1/*109*/][1/*110*/] 2.61 + [1/*111*/][1/*112*/][1/*113*/][1/*114*/][1/*115*/] 2.62 + [1/*116*/][1/*117*/][1/*118*/][1/*119*/][1/*120*/] 2.63 + [1/*121*/][1/*122*/][1/*123*/][1/*124*/][1/*125*/] 2.64 + [1/*126*/][1/*127*/][1/*128*/][1/*129*/][1/*130*/] 2.65 + [1/*131*/][1/*132*/][1/*133*/][1/*134*/][1/*135*/] 2.66 + [1/*136*/][1/*137*/][1/*138*/][1/*139*/][1/*140*/] 2.67 + [1/*141*/][1/*142*/][1/*143*/][1/*144*/][1/*145*/] 2.68 + [1/*146*/][1/*147*/][1/*148*/][1/*149*/][1/*150*/] 2.69 + [1/*151*/][1/*152*/][1/*153*/][1/*154*/][1/*155*/] 2.70 + [1/*156*/][1/*157*/][1/*158*/][1/*159*/][1/*160*/] 2.71 + [1/*161*/][1/*162*/][1/*163*/][1/*164*/][1/*165*/] 2.72 + [1/*166*/][1/*167*/][1/*168*/][1/*169*/][1/*170*/] 2.73 + [1/*171*/][1/*172*/][1/*173*/][1/*174*/][1/*175*/] 2.74 + [1/*176*/][1/*177*/][1/*178*/][1/*179*/][1/*180*/] 2.75 + [1/*181*/][1/*182*/][1/*183*/][1/*184*/][1/*185*/] 2.76 + [1/*186*/][1/*187*/][1/*188*/][1/*189*/][1/*190*/] 2.77 + [1/*191*/][1/*192*/][1/*193*/][1/*194*/][1/*195*/] 2.78 + [1/*196*/][1/*197*/][1/*198*/][1/*199*/][1/*200*/] 2.79 + 2.80 + [1/*201*/][1/*202*/][1/*203*/][1/*204*/][1/*205*/] 2.81 + [1/*206*/][1/*207*/][1/*208*/][1/*209*/][1/*210*/] 2.82 + [1/*211*/][1/*212*/][1/*213*/][1/*214*/][1/*215*/] 2.83 + [1/*216*/][1/*217*/][1/*218*/][1/*219*/][1/*220*/] 2.84 + [1/*221*/][1/*222*/][1/*223*/][1/*224*/][1/*225*/] 2.85 + [1/*226*/][1/*227*/][1/*228*/][1/*229*/][1/*230*/] 2.86 + [1/*231*/][1/*232*/][1/*233*/][1/*234*/][1/*235*/] 2.87 + [1/*236*/][1/*237*/][1/*238*/][1/*239*/][1/*240*/] 2.88 + [1/*241*/][1/*242*/][1/*243*/][1/*244*/][1/*245*/] 2.89 + [1/*246*/][1/*247*/][1/*248*/][1/*249*/][1/*250*/] 2.90 + [1/*251*/][1/*252*/][1/*253*/][1/*254*/][1/*255*/]; 2.91 + } 2.92 +}
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/test/tools/javac/4917091/Test256a.java Thu Dec 09 08:24:42 2010 -0800 3.3 @@ -0,0 +1,88 @@ 3.4 +/* 3.5 + * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved. 3.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3.7 + * 3.8 + * This code is free software; you can redistribute it and/or modify it 3.9 + * under the terms of the GNU General Public License version 2 only, as 3.10 + * published by the Free Software Foundation. 3.11 + * 3.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 3.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 3.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 3.15 + * version 2 for more details (a copy is included in the LICENSE file that 3.16 + * accompanied this code). 3.17 + * 3.18 + * You should have received a copy of the GNU General Public License version 3.19 + * 2 along with this work; if not, write to the Free Software Foundation, 3.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 3.21 + * 3.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 3.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 3.24 + * have any questions. 3.25 + */ 3.26 + 3.27 +/* 3.28 + * @test 3.29 + * @bug 4917091 3.30 + * @summary javac rejects array over 128 in length 3.31 + * @compile/fail/ref=Test256a.out -XDrawDiagnostics Test256a.java 3.32 + */ 3.33 + 3.34 +public class Test256a { 3.35 + // allocating an array with more than 255 dimensions is not allowed 3.36 + static Object expected = (Object)new Object 3.37 + [1/*001*/][1/*002*/][1/*003*/][1/*004*/][1/*005*/] 3.38 + [1/*006*/][1/*007*/][1/*008*/][1/*009*/][1/*010*/] 3.39 + [1/*011*/][1/*012*/][1/*013*/][1/*014*/][1/*015*/] 3.40 + [1/*016*/][1/*017*/][1/*018*/][1/*019*/][1/*020*/] 3.41 + [1/*021*/][1/*022*/][1/*023*/][1/*024*/][1/*025*/] 3.42 + [1/*026*/][1/*027*/][1/*028*/][1/*029*/][1/*030*/] 3.43 + [1/*031*/][1/*032*/][1/*033*/][1/*034*/][1/*035*/] 3.44 + [1/*036*/][1/*037*/][1/*038*/][1/*039*/][1/*040*/] 3.45 + [1/*041*/][1/*042*/][1/*043*/][1/*044*/][1/*045*/] 3.46 + [1/*046*/][1/*047*/][1/*048*/][1/*049*/][1/*050*/] 3.47 + [1/*051*/][1/*052*/][1/*053*/][1/*054*/][1/*055*/] 3.48 + [1/*056*/][1/*057*/][1/*058*/][1/*059*/][1/*060*/] 3.49 + [1/*061*/][1/*062*/][1/*063*/][1/*064*/][1/*065*/] 3.50 + [1/*066*/][1/*067*/][1/*068*/][1/*069*/][1/*070*/] 3.51 + [1/*071*/][1/*072*/][1/*073*/][1/*074*/][1/*075*/] 3.52 + [1/*076*/][1/*077*/][1/*078*/][1/*079*/][1/*080*/] 3.53 + [1/*081*/][1/*082*/][1/*083*/][1/*084*/][1/*085*/] 3.54 + [1/*086*/][1/*087*/][1/*088*/][1/*089*/][1/*090*/] 3.55 + [1/*091*/][1/*092*/][1/*093*/][1/*094*/][1/*095*/] 3.56 + [1/*096*/][1/*097*/][1/*098*/][1/*099*/][1/*100*/] 3.57 + 3.58 + [1/*101*/][1/*102*/][1/*103*/][1/*104*/][1/*105*/] 3.59 + [1/*106*/][1/*107*/][1/*108*/][1/*109*/][1/*110*/] 3.60 + [1/*111*/][1/*112*/][1/*113*/][1/*114*/][1/*115*/] 3.61 + [1/*116*/][1/*117*/][1/*118*/][1/*119*/][1/*120*/] 3.62 + [1/*121*/][1/*122*/][1/*123*/][1/*124*/][1/*125*/] 3.63 + [1/*126*/][1/*127*/][1/*128*/][1/*129*/][1/*130*/] 3.64 + [1/*131*/][1/*132*/][1/*133*/][1/*134*/][1/*135*/] 3.65 + [1/*136*/][1/*137*/][1/*138*/][1/*139*/][1/*140*/] 3.66 + [1/*141*/][1/*142*/][1/*143*/][1/*144*/][1/*145*/] 3.67 + [1/*146*/][1/*147*/][1/*148*/][1/*149*/][1/*150*/] 3.68 + [1/*151*/][1/*152*/][1/*153*/][1/*154*/][1/*155*/] 3.69 + [1/*156*/][1/*157*/][1/*158*/][1/*159*/][1/*160*/] 3.70 + [1/*161*/][1/*162*/][1/*163*/][1/*164*/][1/*165*/] 3.71 + [1/*166*/][1/*167*/][1/*168*/][1/*169*/][1/*170*/] 3.72 + [1/*171*/][1/*172*/][1/*173*/][1/*174*/][1/*175*/] 3.73 + [1/*176*/][1/*177*/][1/*178*/][1/*179*/][1/*180*/] 3.74 + [1/*181*/][1/*182*/][1/*183*/][1/*184*/][1/*185*/] 3.75 + [1/*186*/][1/*187*/][1/*188*/][1/*189*/][1/*190*/] 3.76 + [1/*191*/][1/*192*/][1/*193*/][1/*194*/][1/*195*/] 3.77 + [1/*196*/][1/*197*/][1/*198*/][1/*199*/][1/*200*/] 3.78 + 3.79 + [1/*201*/][1/*202*/][1/*203*/][1/*204*/][1/*205*/] 3.80 + [1/*206*/][1/*207*/][1/*208*/][1/*209*/][1/*210*/] 3.81 + [1/*211*/][1/*212*/][1/*213*/][1/*214*/][1/*215*/] 3.82 + [1/*216*/][1/*217*/][1/*218*/][1/*219*/][1/*220*/] 3.83 + [1/*221*/][1/*222*/][1/*223*/][1/*224*/][1/*225*/] 3.84 + [1/*226*/][1/*227*/][1/*228*/][1/*229*/][1/*230*/] 3.85 + [1/*231*/][1/*232*/][1/*233*/][1/*234*/][1/*235*/] 3.86 + [1/*236*/][1/*237*/][1/*238*/][1/*239*/][1/*240*/] 3.87 + [1/*241*/][1/*242*/][1/*243*/][1/*244*/][1/*245*/] 3.88 + [1/*246*/][1/*247*/][1/*248*/][1/*249*/][1/*250*/] 3.89 + [1/*251*/][1/*252*/][1/*253*/][1/*254*/][1/*255*/] 3.90 + [1/*256*/]; 3.91 +}
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/test/tools/javac/4917091/Test256a.out Thu Dec 09 08:24:42 2010 -0800 4.3 @@ -0,0 +1,2 @@ 4.4 +Test256a.java:33:46: compiler.err.limit.dimensions 4.5 +1 error
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 5.2 +++ b/test/tools/javac/4917091/Test256b.java Thu Dec 09 08:24:42 2010 -0800 5.3 @@ -0,0 +1,91 @@ 5.4 +/* 5.5 + * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved. 5.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5.7 + * 5.8 + * This code is free software; you can redistribute it and/or modify it 5.9 + * under the terms of the GNU General Public License version 2 only, as 5.10 + * published by the Free Software Foundation. 5.11 + * 5.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 5.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 5.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 5.15 + * version 2 for more details (a copy is included in the LICENSE file that 5.16 + * accompanied this code). 5.17 + * 5.18 + * You should have received a copy of the GNU General Public License version 5.19 + * 2 along with this work; if not, write to the Free Software Foundation, 5.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 5.21 + * 5.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 5.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 5.24 + * have any questions. 5.25 + */ 5.26 + 5.27 +/* 5.28 + * @test 5.29 + * @bug 4917091 5.30 + * @summary javac rejects array over 128 in length 5.31 + * @compile/fail/ref=Test256b.out -XDrawDiagnostics Test256b.java 5.32 + */ 5.33 + 5.34 +public class Test256b { 5.35 + // allocating an array with 255 dimensions whose component 5.36 + // type provides additional dimensions is not allowed, 5.37 + // since the type descriptor for any array is limited to 5.38 + // 255 dimensions: JVMS3, section 4.3.2. 5.39 + static Object expected = (Object)new Object 5.40 + [1/*001*/][1/*002*/][1/*003*/][1/*004*/][1/*005*/] 5.41 + [1/*006*/][1/*007*/][1/*008*/][1/*009*/][1/*010*/] 5.42 + [1/*011*/][1/*012*/][1/*013*/][1/*014*/][1/*015*/] 5.43 + [1/*016*/][1/*017*/][1/*018*/][1/*019*/][1/*020*/] 5.44 + [1/*021*/][1/*022*/][1/*023*/][1/*024*/][1/*025*/] 5.45 + [1/*026*/][1/*027*/][1/*028*/][1/*029*/][1/*030*/] 5.46 + [1/*031*/][1/*032*/][1/*033*/][1/*034*/][1/*035*/] 5.47 + [1/*036*/][1/*037*/][1/*038*/][1/*039*/][1/*040*/] 5.48 + [1/*041*/][1/*042*/][1/*043*/][1/*044*/][1/*045*/] 5.49 + [1/*046*/][1/*047*/][1/*048*/][1/*049*/][1/*050*/] 5.50 + [1/*051*/][1/*052*/][1/*053*/][1/*054*/][1/*055*/] 5.51 + [1/*056*/][1/*057*/][1/*058*/][1/*059*/][1/*060*/] 5.52 + [1/*061*/][1/*062*/][1/*063*/][1/*064*/][1/*065*/] 5.53 + [1/*066*/][1/*067*/][1/*068*/][1/*069*/][1/*070*/] 5.54 + [1/*071*/][1/*072*/][1/*073*/][1/*074*/][1/*075*/] 5.55 + [1/*076*/][1/*077*/][1/*078*/][1/*079*/][1/*080*/] 5.56 + [1/*081*/][1/*082*/][1/*083*/][1/*084*/][1/*085*/] 5.57 + [1/*086*/][1/*087*/][1/*088*/][1/*089*/][1/*090*/] 5.58 + [1/*091*/][1/*092*/][1/*093*/][1/*094*/][1/*095*/] 5.59 + [1/*096*/][1/*097*/][1/*098*/][1/*099*/][1/*100*/] 5.60 + 5.61 + [1/*101*/][1/*102*/][1/*103*/][1/*104*/][1/*105*/] 5.62 + [1/*106*/][1/*107*/][1/*108*/][1/*109*/][1/*110*/] 5.63 + [1/*111*/][1/*112*/][1/*113*/][1/*114*/][1/*115*/] 5.64 + [1/*116*/][1/*117*/][1/*118*/][1/*119*/][1/*120*/] 5.65 + [1/*121*/][1/*122*/][1/*123*/][1/*124*/][1/*125*/] 5.66 + [1/*126*/][1/*127*/][1/*128*/][1/*129*/][1/*130*/] 5.67 + [1/*131*/][1/*132*/][1/*133*/][1/*134*/][1/*135*/] 5.68 + [1/*136*/][1/*137*/][1/*138*/][1/*139*/][1/*140*/] 5.69 + [1/*141*/][1/*142*/][1/*143*/][1/*144*/][1/*145*/] 5.70 + [1/*146*/][1/*147*/][1/*148*/][1/*149*/][1/*150*/] 5.71 + [1/*151*/][1/*152*/][1/*153*/][1/*154*/][1/*155*/] 5.72 + [1/*156*/][1/*157*/][1/*158*/][1/*159*/][1/*160*/] 5.73 + [1/*161*/][1/*162*/][1/*163*/][1/*164*/][1/*165*/] 5.74 + [1/*166*/][1/*167*/][1/*168*/][1/*169*/][1/*170*/] 5.75 + [1/*171*/][1/*172*/][1/*173*/][1/*174*/][1/*175*/] 5.76 + [1/*176*/][1/*177*/][1/*178*/][1/*179*/][1/*180*/] 5.77 + [1/*181*/][1/*182*/][1/*183*/][1/*184*/][1/*185*/] 5.78 + [1/*186*/][1/*187*/][1/*188*/][1/*189*/][1/*190*/] 5.79 + [1/*191*/][1/*192*/][1/*193*/][1/*194*/][1/*195*/] 5.80 + [1/*196*/][1/*197*/][1/*198*/][1/*199*/][1/*200*/] 5.81 + 5.82 + [1/*201*/][1/*202*/][1/*203*/][1/*204*/][1/*205*/] 5.83 + [1/*206*/][1/*207*/][1/*208*/][1/*209*/][1/*210*/] 5.84 + [1/*211*/][1/*212*/][1/*213*/][1/*214*/][1/*215*/] 5.85 + [1/*216*/][1/*217*/][1/*218*/][1/*219*/][1/*220*/] 5.86 + [1/*221*/][1/*222*/][1/*223*/][1/*224*/][1/*225*/] 5.87 + [1/*226*/][1/*227*/][1/*228*/][1/*229*/][1/*230*/] 5.88 + [1/*231*/][1/*232*/][1/*233*/][1/*234*/][1/*235*/] 5.89 + [1/*236*/][1/*237*/][1/*238*/][1/*239*/][1/*240*/] 5.90 + [1/*241*/][1/*242*/][1/*243*/][1/*244*/][1/*245*/] 5.91 + [1/*246*/][1/*247*/][1/*248*/][1/*249*/][1/*250*/] 5.92 + [1/*251*/][1/*252*/][1/*253*/][1/*254*/][1/*255*/] 5.93 + []; 5.94 +}
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 6.2 +++ b/test/tools/javac/4917091/Test256b.out Thu Dec 09 08:24:42 2010 -0800 6.3 @@ -0,0 +1,2 @@ 6.4 +Test256b.java:36:46: compiler.err.limit.dimensions 6.5 +1 error