Maximum length of Static name?

H

harry

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;
 
A

Arnaud B.

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
 
S

Stefan Ram

harry said:
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.«
 
O

opalpa

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
(e-mail address removed)
http://www.geocities.com/opalpaweb/
 
O

opalpa

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
(e-mail address removed)
http://www.geocities.com/opalpaweb/
 
H

harry

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!
 
O

opalpa

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
(e-mail address removed)
http://www.geocities.com/opalpaweb/
 
B

bugbear

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
 
R

Roedy Green

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.
 
R

Roedy Green

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.
 
R

Roedy Green

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top