"error: too many constants" - An explanation

Discussion in 'Chit Chat' started by kepler, Mar 25, 2015.

  1. kepler

    kepler Active Member Licensed User


    I'm dealing with a lot of "heavy" routines, both in Java as in B4A.

    I just wanted to share, that the explanation of memory issues, too many variables, etc came very often from the fact that Java can't handle classes bigger than 65535 bytes long.
    Oh, you may have a Public Class in a bigger java file. But each of the sub classes can't exceed this bytes limit.
    This happens also in Visual Basic 6 for instance.
    I'll post here more info as I go along.

    Kind regards,

  2. DonManfred

    DonManfred Expert Licensed User

    EACH time you tell about problems in B4A or JA you are relaying on Code you did not show us.

    Show us you problematic java-project (complete source) so we can see where the problem is.

    I´m sure java will be able to use bigger classes than 64kb.
    The question is; what are doing in that java?

    Even in my BIGGER b4a-libraries written in java does not have this big classes. The biggest i have is around 48kb
    KMatle likes this.
  3. Troberg

    Troberg Well-Known Member Licensed User

    64kB seems extremely little for a class. Sure, most classes are trivial, but there are also some "heavy worker" classes, and they can easily be larger than 64kB.
    Last edited: Mar 26, 2015
  4. kepler

    kepler Active Member Licensed User


    I'm trying to help others - not reporting a problem.

    As an astronomer, I'm programming celestial mechanics routines - an implementation for the Android platform.
    If you are aware, the size of data and routines are indeed very big in terms of size. The data, as an array, is not a problem - although it gives a lot of work to put it in that form. If you don't, you'll get modules with 40-500 Kb (depending of the theory you're using).

    The size is not mesured with the bytes the b4a/java module has in Explorer. It can be much bigger. The INNER classes are the issue. Those do have a limit.
    Solution: divide the best way the info and alghorithms in your inner Class Modules.

    I was just trying to help others that might have this issue.

    Apparently, my mistake.

    Kind regards,

  5. KMatle

    KMatle Expert Licensed User

    It's "not that optimal" to put code & data together. Put all your data in a database (encrypted when needed) or a file but never in the code.
  6. Troberg

    Troberg Well-Known Member Licensed User

    That I agree on, but classes larger than 64kB is not that uncommon, even if it's just code, especially some core classes in complex applications.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice