This is probably a silly question but is there a maximum number of
characters for a static name?
i.e
public static final int ABCDEFGHIJKLMOPQRSTUVWXYZ........... = 1;
Arnaud B. - 01 Feb 2006 15:27 GMT
Hi,
I think there is no limit if it is alaways represented as a String object
like in
: getField(String name) from class java.lang.Class .
But, why would you care?
Arnaud
> This is probably a silly question but is there a maximum number of
> characters for a static name?
>
> i.e
>
> public static final int ABCDEFGHIJKLMOPQRSTUVWXYZ........... = 1;
harry - 01 Feb 2006 15:56 GMT
I have some statics that need to be 30'ish chars long to make them
understandable, seem to remember something somewhere ignoring chars after
32 - really can't remember where, may have even been Cobol many years ago!
Many thanks for all replies!
> Hi,
>
[quoted text clipped - 13 lines]
> >
> > public static final int ABCDEFGHIJKLMOPQRSTUVWXYZ........... = 1;
opalpa@gmail.com opalinski from opalpaweb - 01 Feb 2006 16:20 GMT
Don't know about Cobol, but earlier versions of Fortran had very small
limits. I was maintaining some Fortran about a year ago and asked why
a currency conversion rate was something like fxq2ctq and was informed
that Fortan's original limitations were 7 characters for uniquness and
that alot of them got used up.
This is not a problem for Java. Java does not truncate identifiers.
Opalinski
opalpa@gmail.com
http://www.geocities.com/opalpaweb/
bugbear - 01 Feb 2006 17:07 GMT
> Don't know about Cobol, but earlier versions of Fortran had very small
> limits. I was maintaining some Fortran about a year ago and asked why
> a currency conversion rate was something like fxq2ctq and was informed
> that Fortan's original limitations were 7 characters for uniquness and
> that alot of them got used up.
IIRC Whitesmith's 'C' silently ignored anything
after 6 chars. We tended to use longer indentifiers
for readability.
This led to an EVIL bug when we upgraded
the compiler; we some variable that differed (due a typo)
in char 7 (or 8 or something).
Code ran under Whitesmiths, but not under the new comp.
BugBear
Roedy Green - 01 Feb 2006 20:56 GMT
On 1 Feb 2006 08:20:31 -0800, "opalpa@gmail.com opalinski from
opalpaweb" <opalpa@gmail.com> wrote, quoted or indirectly quoted
someone who said :
>Fortan's original limitations were 7 characters for uniquness and
>that alot of them got used up.
Seems to me the Fortran I used in the early 60s had a 6 character
identifier limit. Character handling was done by packing 6 6-bit
bytes into a 36-bit int. You only had word addressing on the IBM 7044
and Univac 1106.
You had a local 6-bit character set you defined yourself for the shop
and a custom printer chain to print it. I remember how modern and
oddly European the notion of ASCII seemed.
We are going through a period of consolidating 8- bit charsets into a
single 16 bit one, similar to the way we years ago consolidated many
60bit char sets into a 7 bit one.
Even seven bits seemed expansive at the time, and the use of lower
case effete. You had to get special permission to print anything in
lower case since the print chain was so much slower with all those
extra characters on it.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Roedy Green - 01 Feb 2006 20:48 GMT
>I have some statics that need to be 30'ish chars long to make them
>understandable, seem to remember something somewhere ignoring chars after
>32 - really can't remember where, may have even been Cobol many years ago!
might have been IBM PL/If or Univac 90/30 COBOL. One of them just
quietly ignored the tail ends of your identifiers leading to some very
peculiar bugs.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Stefan Ram - 01 Feb 2006 15:29 GMT
>This is probably a silly question but is there a maximum number of
>characters for a static name?
There are no "static names" in Java.
I assume, you meant "for an identifier".
The answer is given by the Java Language Specification, Third
Edition in Section 3.8:
»An identifier is an unlimited-length sequence of Java
letters and Java digits, the first of which must be a Java
letter.«
opalpa@gmail.com opalinski from opalpaweb - 01 Feb 2006 15:45 GMT
There is a limit in implementaitons I've used. Error message is like:
UTF8 representation for string "ABCDEFGHIJKLMOPQRSTUVWXYZ..." is too
long for the constant pool.
Also there used to be, haven't run into it for while, probably still
there, a limit on class size. Used to be 640000 bytes.
Opalinski
opalpa@gmail.com
http://www.geocities.com/opalpaweb/
opalpa@gmail.com opalinski from opalpaweb - 01 Feb 2006 15:50 GMT
The limit is pretty big for String names for practical purposes btw,
you can make it thousands of characters long.
> Also there used to be, haven't run into it for while, probably still
> there, a limit on class size. Used to be 640000 bytes.
This might have been a source size limit. I don't remember.
Opalinski
opalpa@gmail.com
http://www.geocities.com/opalpaweb/
Roedy Green - 01 Feb 2006 20:57 GMT
On 1 Feb 2006 07:45:26 -0800, "opalpa@gmail.com opalinski from
opalpaweb" <opalpa@gmail.com> wrote, quoted or indirectly quoted
someone who said :
>Also there used to be, haven't run into it for while, probably still
>there, a limit on class size. Used to be 640000 bytes.
A local identifier does not go into the class file.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Roedy Green - 01 Feb 2006 20:40 GMT
>This is probably a silly question but is there a maximum number of
>characters for a static name?
see http://mindprod.com/jgloss/naming.html#TECHNICAL

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.