Re: strange behevior of the JVM or compiler...



On Jul 8, 12:33 pm, Roedy Green <see_webs...@xxxxxxxxxxxxxxxxxxxx>
wrote:
Second, static finals get turned into literals (constants) even when
they are referred outside the class. If you modify them, you must
recompile the universe to make sure the new value gets propagated.

Efficient though this is, it seems to mean that for "constants" that
you expect might change in a future version of a library you should
provide accessor methods and not a public static final field.
Otherwise, drop-in replacement of the older version with the newer
version in a deployed app's classpath might fail in bizarre ways. To
make sure newer versions of a library are binary-compatible with apps
that use the library, and not just source-compatible, requires not
changing the values of public static final fields.

So you'd want to use

public static final int MAX_FACTORIAL = 12; // 12! is less than
// Integer.MAX_VALUE; 13! is greater; and this will never change.

public static int getMaxTreeDepth () {
return 5;
// In later versions this might be increased to 6 or even 7.
}


.



Relevant Pages

  • Re: Support for building individual .kos would be nice :-)
    ... > for it) and a need to modify one line of a module, recompile it, ... > replace existing module with it and continue business as usual ... If you leave the compiled tree intact, all you need to do is modify ... send the line "unsubscribe linux-kernel" in ...
    (Linux-Kernel)
  • Re: Minimizing Compile Time Dependencies
    ... > enforce a coding rule not to modify the signature of a class unless he ... > is willing to recompile his entire application..... ...
    (comp.lang.java.programmer)
  • Re: Writting Pluggins
    ... can extend your system with arbitrary functions, with no recompile, check ... out MiniBasic, on my website. ... Full compilable source is free. ... You can modify ...
    (comp.lang.c)
  • Re: which compiler was used to compile?
    ... >versions of the class (in different jars) for each compiler. ... Don't you have to recompile the universe if you use a public static ...
    (comp.lang.java.programmer)
  • Re: its giving the different address !!!!!!!!!!
    ... So you compile one form, run it, and see the output; ... then modify, recompile and run again, and get different ... BTW what exactly are you trying to determine? ...
    (comp.lang.c)