7 Replies Latest reply: Dec 14, 2008 3:15 PM by 800322 RSS

    maximum number of java classes in package

    807589
      Hi all,

      I want to know if there is a maximum number of classes that i can put in a package

      also is there a limit for number of files (e.g. hibernate mapping file ) that can pe put within the package




        • 1. Re: maximum number of java classes in package
          807589
          amgad wrote:
          Hi all,

          I want to know if there is a maximum number of classes that i can put in a package
          Not that I am aware of.

          That is one of those questions that is very frightening that you should ask it. Why did you ask it?
          also is there a limit for number of files (e.g. hibernate mapping file ) that can pe put within the package
          This is not a hibernate forum.
          • 2. Re: maximum number of java classes in package
            masijade
            cotton.m wrote:
            amgad wrote:
            Hi all,

            I want to know if there is a maximum number of classes that i can put in a package
            Not that I am aware of.

            That is one of those questions that is very frightening that you should ask it. Why did you ask it?
            The entire project in one package? ;-)
            • 3. Re: maximum number of java classes in package
              807589
              cotton.m wrote:

              That is one of those questions that is very frightening that you should ask it. Why did you ask it?
              ok i have to explain the entire situation

              I have the data model in a jar

              whaen i run the project while the data model is in the jar the project runs successfuly

              then i decomiled the jar package by pakage

              it continued running till i decompiled a package that have 170 classes and 170 xml file (hbm.xml) it start run but hang up

              i use jdeveloper 10.2.2

              Edited by: amgad on Dec 14, 2008 7:41 AM
              • 4. Re: maximum number of java classes in package
                jwenting
                I'd expect classes to be stored in memory in a HashMap or something similar, indexed by classname.
                Package name at the moment is not used as an index anywhere (it's just an identifier), though that is likely to change with the planned introduction of superpackages in Java 7 which will introduce true package hierarchies.

                This would suggest there to be a maximum number of loaded classes in a single classloader of roughly MAXLONG, more than you should ever need.
                There would also be a similar limit to the number of active classloaders.
                • 5. Re: maximum number of java classes in package
                  807589
                  I'm currently using java 1.4 !
                  • 6. Re: maximum number of java classes in package
                    796440
                    If I'm not mistaken, class names are held in the constant pool, and I believe there are only 64k slots available. If so, that would be an absolute upper bound. The sum of the length of the names may also impose a limit.

                    Regardless, whatever the limit is, I'm sure that it's large enough that if you're getting anywhere near it, you need to look at doing some serious refactoring.
                    • 7. Re: maximum number of java classes in package
                      800322
                      There is no real limit. Not all of a package has to be deployed with a program, and not all classes need to be loaded. Whether there's a limit to the amount of loadable classes is a different question. ;)