United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-4917091 javac rejects array over 128 in length
JDK-4917091 : javac rejects array over 128 in length

Details
Type:
Bug
Submit Date:
2003-09-04
Status:
Closed
Updated Date:
2010-12-21
Project Name:
JDK
Resolved Date:
2011-03-08
Component:
tools
OS:
solaris_8
Sub-Component:
javac
CPU:
sparc
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.4.2
Fixed Versions:

Related Reports
Relates:
Relates:
Relates:

Sub Tasks

Description
While JVM spec limits the array size to 255, 

http://java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html#41115
> ------
> The number of dimensions in an array is limited to 255 by the size of the 
> dimensions opcode of the multianewarray instruction and by the constraints 
> imposed on the multianewarray, anewarray, and newarray instructions by ??4.8.2.
> ------

jdk 1.4 javac rejects an array that's over 128.   Below is the test.

> /java/re/j2se/1.4.2/arcchive/fcs/binaries/solaris-sparc/bin/javac Test.java
Test.java:2: array type has too many dimensions
            static Object expected = (Object)new Object
                                             ^
1 error

public class Test {
            static Object expected = (Object)new Object
                [1/*001*/][1/*002*/][1/*003*/][1/*004*/][1/*005*/]
                [1/*006*/][1/*007*/][1/*008*/][1/*009*/][1/*010*/]
                [1/*011*/][1/*012*/][1/*013*/][1/*014*/][1/*015*/]
                [1/*016*/][1/*017*/][1/*018*/][1/*019*/][1/*020*/]
                [1/*021*/][1/*022*/][1/*023*/][1/*024*/][1/*025*/]
                [1/*026*/][1/*027*/][1/*028*/][1/*029*/][1/*030*/]
                [1/*031*/][1/*032*/][1/*033*/][1/*034*/][1/*035*/]
                [1/*036*/][1/*037*/][1/*038*/][1/*039*/][1/*040*/]
                [1/*041*/][1/*042*/][1/*043*/][1/*044*/][1/*045*/]
                [1/*046*/][1/*047*/][1/*048*/][1/*049*/][1/*050*/]
                [1/*051*/][1/*052*/][1/*053*/][1/*054*/][1/*055*/]
                [1/*056*/][1/*057*/][1/*058*/][1/*059*/][1/*060*/]
                [1/*061*/][1/*062*/][1/*063*/][1/*064*/][1/*065*/]
                [1/*066*/][1/*067*/][1/*068*/][1/*069*/][1/*070*/]
                [1/*071*/][1/*072*/][1/*073*/][1/*074*/][1/*075*/]
                [1/*076*/][1/*077*/][1/*078*/][1/*079*/][1/*080*/]
                [1/*081*/][1/*082*/][1/*083*/][1/*084*/][1/*085*/]
                [1/*086*/][1/*087*/][1/*088*/][1/*089*/][1/*090*/]
                [1/*091*/][1/*092*/][1/*093*/][1/*094*/][1/*095*/]
                [1/*096*/][1/*097*/][1/*098*/][1/*099*/][1/*100*/]
                [1/*101*/][1/*102*/][1/*103*/][1/*104*/][1/*105*/]
                [1/*106*/][1/*107*/][1/*108*/][1/*109*/][1/*110*/]
                [1/*111*/][1/*112*/][1/*113*/][1/*114*/][1/*115*/]
                [1/*116*/][1/*117*/][1/*118*/][1/*119*/][1/*120*/]
                [1/*121*/][1/*122*/][1/*123*/][1/*124*/][1/*125*/]
                [1/*126*/][1/*127*/][1/*128*/][1/*129*/];
}
###@###.### 10/25/04 21:57 GMT

                                    

Comments
EVALUATION

Looks like a bug.

###@###.### 2003-09-05
                                     
2003-09-05
PUBLIC COMMENTS

...
                                     
2004-07-17
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
mustang


                                     
2004-07-17
EVALUATION

The compiler confuses an array's component type with its element type. So
it gets a wrong dimension while checking limit.
                                     
2006-12-08
EVALUATION

Main spec reference here is JVMS 3, 4.3.2 which says that the type descriptor for any array is limited to 255 dimensions.   This means you can't even allocate (for example) a two-dimensional array of elements which are in turn 254-dimensional arrays, because the cumulative dimensionality exceeds the limits on the array type descriptor.
                                     
2010-12-09
EVALUATION

http://hg.openjdk.java.net/jdk7/build/langtools/rev/bcf44475aeee
                                     
2010-12-25



Hardware and Software, Engineered to Work Together