J
javax.swing.JSnarker
Between loading and initialization theres still verification, isn't it?
Verification is a part of loading, rather than coming after it.
Between loading and initialization theres still verification, isn't it?
I'm curious: How do you want to verify something that you haven't loaded
yet?
javax.swing.JSnarker said:Daniel said:How I would expect this to work in reality.
1. Load class
2. get a reference to the static method "void main(String[])"
3. Attempt to execute that reference
3.1 Causes class initialization before execution.
3.2 actual execution occurs.
That has a problem, though, in that class initialization will happen on
every method call, resulting in multiple initializations, if it's part
of "attempt to execute the reference" rather than (as the spec says)
something the JVM does immediately *before* the first such attempt (or
other action that requires an initialized class for the action to begin).
I suppose you could change 3.1 to "see if the class is initialized, and
if not, initialize it", but even that would add to *every method call*
the overhead of a test-and-branch, and would still be dodgy at best on
spec-adherence grounds.
javax.swing.JSnarker said:Daniel said:How I would expect this to work in reality.
1. Load class
2. get a reference to the static method "void main(String[])"
3. Attempt to execute that reference
3.1 Causes class initialization before execution.
3.2 actual execution occurs.
That has a problem, though, in that class initialization will happen on
every method call, resulting in multiple initializations, if it's part
That's not what happens.
As the spec says, it happens upon the first attempt to execute a static method
(if the class has not already been initialized).
That is what the spec says to do. As previously linked.
No, it does what it does and adheres to the spec.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.