Basic Syntax Question - String[].class

From: Evil *** (hq_at_national.org.nz)
Date: 04/27/04


Date: Wed, 28 Apr 2004 02:38:48 +1200

Hi,

I'm building a Bison (LALR(1))-based java language parser, which is
successfully building parse trees on 99.75% of the .java files in a test
codebase.

However, one construct which is derailing it is:

Method m = cls.getMethod("main", new Class[] { String[].class; });

The syntax error happens at the 'String [].class' in the array initializer.

I'm still fairly new to Java, so from my limited understanding, 'String
[].class' produces a Class object, being the class of array of String.

I'm studying the language spec at:

   http://java.sun.com/docs/books/jls/first_edition/html/index.html

but I'm failing to ascertain where 'String [].class' fits into the
formal syntax description. What particular kind of syntactical entity is
this?

Can anyone point me to the right place in the syntax spec?

Thanks in advance
EB


Quantcast