Maximum length of Static name?

Discussion in 'Java' started by harry, Feb 1, 2006.

  1. harry

    harry Guest

    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, Feb 1, 2006
    #1
    1. Advertising

  2. harry

    Arnaud B. Guest

    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


    "harry" <> a écrit dans le message de
    news:Qg4Ef.13247$...
    > 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., Feb 1, 2006
    #2
    1. Advertising

  3. harry

    Stefan Ram Guest

    "harry" <> writes:
    >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.«
     
    Stefan Ram, Feb 1, 2006
    #3
  4. 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

    http://www.geocities.com/opalpaweb/
     
    opalinski from opalpaweb, Feb 1, 2006
    #4
  5. 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

    http://www.geocities.com/opalpaweb/
     
    opalinski from opalpaweb, Feb 1, 2006
    #5
  6. harry

    harry Guest

    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!



    "Arnaud B." <> wrote in message
    news:drqk1k$jvg$...
    > 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
    >
    >
    > "harry" <> a écrit dans le message de
    > news:Qg4Ef.13247$...
    > > 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, Feb 1, 2006
    #6
  7. 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

    http://www.geocities.com/opalpaweb/
     
    opalinski from opalpaweb, Feb 1, 2006
    #7
  8. harry

    bugbear Guest

    opalinski from opalpaweb wrote:
    > 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
     
    bugbear, Feb 1, 2006
    #8
  9. harry

    Roedy Green Guest

    On Wed, 01 Feb 2006 15:16:00 GMT, "harry" <> wrote, quoted or
    indirectly quoted someone who said :

    >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
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Java custom programming, consulting and coaching.
     
    Roedy Green, Feb 1, 2006
    #9
  10. harry

    Roedy Green Guest

    On Wed, 01 Feb 2006 15:56:28 GMT, "harry" <> wrote, quoted or
    indirectly quoted someone who said :

    >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.
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Java custom programming, consulting and coaching.
     
    Roedy Green, Feb 1, 2006
    #10
  11. harry

    Roedy Green Guest

    On 1 Feb 2006 08:20:31 -0800, " opalinski from
    opalpaweb" <> 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.
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Java custom programming, consulting and coaching.
     
    Roedy Green, Feb 1, 2006
    #11
  12. harry

    Roedy Green Guest

    On 1 Feb 2006 07:45:26 -0800, " opalinski from
    opalpaweb" <> 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.
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Java custom programming, consulting and coaching.
     
    Roedy Green, Feb 1, 2006
    #12
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?SG96aQ==?=
    Replies:
    1
    Views:
    7,032
    Ken Cox [Microsoft MVP]
    Jun 2, 2004
  2. Replies:
    2
    Views:
    5,976
  3. David T. Ashley

    Maximum Function / Variable Name Identifier Length?

    David T. Ashley, Jan 2, 2007, in forum: C Programming
    Replies:
    3
    Views:
    676
    aegis
    Jan 2, 2007
  4. MattC
    Replies:
    7
    Views:
    13,718
    Piotr Kobzda
    Mar 20, 2007
  5. phanhuyich
    Replies:
    4
    Views:
    333
Loading...

Share This Page