Initializing all Java classes at Start-Up 56
Jean-Marie Dautelle writes "Java classes are initialized at first-use only which can introduce significant runtime delays detrimental to real-time or games applications (for which accurate scheduling is often required).
To solve this problem, the latest open-source Javolution library supports initialization of all Java classes at start-up (e.g.
javolution.lang.ClassInitializer.initializeAll(); // Initialize runtime classes (rt.jar) and all classes in classpath).
Note: Runtime class initialization (rt.jar) takes typically a few seconds and about 3 Mbytes of memory."
Re: How long would it take to write this? (Score:3, Informative)
Maybe a day ?
(1) Identify all files and directories that can be found in the CLASSPATH.
(2) Look at the directories and add all contained files to the list of files.
(3) Differentiate beween types of files:
(4) Add
(5) Look through all zip format files (.jar,
(6) Call ClassLoader#loadClass with all classnames.
(5) will take longest to wri
Re: How long would it take to write this? (Score:1)
Re: How long would it take to write this? (Score:1)
Re: How long would it take to write this? (Score:2)
Re: How long would it take to write this? (Score:2)
Wow (Score:1)
On a serious note, This is interesting. I program in java, some games in fact, and I think I'll be checking this one out, just to see if/what an impact it makes.
tumbleweed? (Score:4, Funny)
Wow... tumbleweeds... (Score:2)
Benefits for anything other than games? (Score:2, Interesting)
The problem with Java startup times is that every Java app loads it's own complete runtime environment. This is not easy to fix, since many apps depend on the fact that they get their own.
Re:Benefits for anything other than games? (Score:5, Interesting)
Re:Benefits for anything other than games? (Score:2)
Only on the 2nd and later instances. The initial java application startup would still be slow.
-Rick
Yeah, but you wouldn't notice it (Score:2)
Re:Yeah, but you wouldn't notice it (Score:2)
-Rick
Re:Benefits for anything other than games? (Score:2)
http://java.sun.com/j2se/1.5.0/docs/guide/vm/class -data-sharing.html [sun.com]
Basically the VM slurps up the runtime library, preparses it, and dumps it ba
Re:Benefits for anything other than games? (Score:2)
There are benefits outside of gaming, for example, when testing applications, especially distributed ones, a random bit of latency can be the difference between a pass and a fail, and can also be a total bastard to debug, so being able to minimise the unexpected is a welcome tool.
Regardless of this, the garbage collector can always throw a spanner in somewhere, so it's a moot point.
Re:Benefits for anything other than games? (Score:2)
During testing, wouldn't you want the application to fail if it at all can, to find bugs ? Wouldn't adding random latency help the testing process ?
Or what did you mean ?
Re:Benefits for anything other than games? (Score:1)
Re:Benefits for anything other than games? (Score:2)
If it fails due to random latency in the VM, then it has a programming error. After all, no multitasking system can possibly guarantee certain latencies - the system could have a higher-priority thread running just when your thread needs to be run. Or some piece of data or code you need might be swapped out (altought that can be prevented by locking it in memory). Or something else might go wrong.
Any program
Re:Benefits for anything other than games? (Score:2)
In most cases, yes; 'though testing usually just proves compliance to an agreed set of interfaces and service levels, the fact that the testing process finds bugs is an agreeable side effect.
Also the JVM and it's contents may not be under test, they may be part of the test harness.
When testing, we minimise the unknown and then measure one thing at a time.
Re:Is this newsworthy? (Score:3, Funny)
>Egad... Time to submit my hello world-programs...
My hello world program takes a array of char to describe which world is being greeted. The version under development will accept an array of pointers to strings so that more than one world can be greeted.
Re:Is this newsworthy? (Score:1)
Re:Firefox problem (Score:1)
Re:Firefox problem (Score:1)
Don't use {font-family: "Courier New"}, instead use {font-family: "Courier New", "Courier", "monospace"}. No matter how common the font, never NEVER assume that the user has it.
Please see http://www.w3.org/TR/REC-CSS1#font-family [w3.org]
Very, very rarely a good idea (Score:5, Interesting)
The advantage of doing eager initialization is predictability, and in the case where almost all classes get initialized sooner or later (which would be very rare considering the size of the Java API) a slight performance increase.
Maybe some kinds of games would benefit from this, but almost all other applications would benefit from more lazy initialization, not less.
Re:Very, very rarely a good idea (Score:2)
When a new class rises to the level of the weakest member of the startup herd, it takes its place. Over time the system will coverge to optimal behavior given the resources you're willing to devote to this purpose, adjusting as the usage of the computer chang
Re:Very, very rarely a good idea (Score:2)
Of course. No one is questioning this. But the blurb says it is doing this for real-time and game applications. These are the exceptions and not the norm, but are no less valid because they are not the norm.
Most dynamically typed languages suck like a Hoover when it comes to realtime, so this is a solution that may help.
Shameless Plug or Valid Selfpromotion? (Score:5, Interesting)
Let's see. Submitter of story: Jean-Marie Dautelle. Javolution project owner: Jean-Marie Dautelle.
Re:Shameless Plug or Valid Selfpromotion? (Score:3, Interesting)
BTW, a lot of realtime Java has to do with deterministic behavior, and lazy initialization is non-deterministic. I don't think the main point here is to save a little bit of
Great code quality (Score:2)
Re:Great code quality (Score:2)
At best, I suppose it suggests that the programmer may be thorough and methodical, and I'll grant that those are good attributes for a programmer to have. But it says nothing about security, efficiency, expandability, reusability, and so forth. Certainly, not enough to proclaim "Great code quality".
Re:Great code quality (Score:1)
Re:Great code quality (Score:2)
int foo(int x)
{
if(x <= 2) return 0;
int f = factorial(x);
if(isprime(f){return -1;}
return 1;
}
That never returns -1, but a compiler can't know that
Re:Great code quality (Score:2)
And your point with this code?
With this particular example, it's absolutely certain that if any analysing tool tells you every control path is covered, then it's lying. It cannot tell you however that this code will never be reached, unless you run test cases for an infinite number of numbers, which is hardly achievable in a life time.
Unfortunately your example is flawed and demonstrates the contrary of what you apparently want to say. However it's a great example to show that tools are just what they ar
Getting to the root of it (Score:2)
Speding up Java Load Times (Score:1, Interesting)
On a more serious note, one of the problems with load times I have noticed in a lot of Java is that people unnecessarily include namespaces where they don't need/use them. Sometimes there's no reason to go into another library when there's an equivalent function in one you're already using and there's certainly no need to reference things you don't use. That also creates a design problem in addition to the performance issue IMO bec
Java "import" considered harmful (Score:2)
Furthermore, "import" has no dependency handling. For instance, org.xml.sax.XMLReader is no use without org.xml.sax.helpers.XMLReaderFactory. Rather than have to manually hunt down the dependencies in the few functions they use, most programmers import org.xml.sax.*.
In C/C++/Objective-C, at least include files tend to include their dependencies.
Re:Java "import" considered harmful (Score:1)
Re:Java "import" considered harmful (Score:2)
Re:Java "import" considered harmful (Score:2)
Re:Java "import" considered harmful (Score:2)
Re:Speding up Java Load Times (Score:2)
The only time that excess namespaces delay processing is during the compilation phase (you know, the *.java -> *.class process). In fact, the class files do not have the concept of import statements, as all class identifiers are fully expanded.
(this applies only to java, I have no experience on the
Re:Speding up Java Load Times (Score:1)
Aah, and this can't happen in C++ how?
Re:Speding up Java Load Times (Score:2)
for which my comment applies.
On the next sentence you talk about the problems Java programmers have when they use many large libraries that have a functionality overlap (correct?), which is a problem, and is unrelated to the first...
Ancient proverb (Score:2)
"He who packs his entire wardrobe for a row across the lake becomes the best-dressed fish around." (Source unknown)