Class initialization

In the assertion guide,
http://java.sun.com/j2se/1.4.1/docs/guide/lang/assert.html#design-faq-enable-disable
the following question (8) is presented.
"Why does an assert statement that executes before its class is initialized behave as if assertions were enabled in the class?"
The answer begins
"Few programmers are aware of the fact that a class's constructors and methods can run prior to its initialization."
Would you please explain this sentence (independent of the question)?

Yet the exerpt states the reverse - That the
constructors and methods can be called before the
class is initialised.
This shows a static method running a static method,
but construction still occurs after the static
initialisers have. Do they perhaps mean that instance
initialisers may not have been run before the
constructor completes? This is certainly possible if
an overridden method is invoked in a super constructor
or super class instance initialiser.
How could you instantiate a class without the static
initialisation having occurred (class
initialisation).
I thought it was obvious but the following one should be more so. Note that the class (nothing to do with an instance) is not initialized until the static initializer completes.
And again I want to point that if this happens in real code then the most likely reason is because of a bug or because the design is wrong. The chance of finding a legitimate reason to have code like this is zero in my mind.
    public class TTest
        public static void main(String[] args)
    TTest()
        System.out.println("Now in the constructor");
    static
        System.out.println("Start the static initializer");
        reallyStupid();
        System.out.println("End the static initializer");
    static private boolean isDone;
    private static void reallyStupid()
        System.out.println("really stupid thing to do");
        if (!isDone)
            isDone = true;
            TTest t = new TTest();
  The output is...
  Start the static initializer
  really stupid thing to do
  Now in the constructor
  End the static initializer

Similar Messages

  • Interface class Initialization

    A class or interface type T will be initialized immediately before the first occurrence of any one of the following:
    1..T is a class and an instance of T is created.
    2..T is a class and a static method declared by T is invoked.
    3..A static field declared by T is assigned.
    4..A static field declared by T is used and the field is not a constant variable (?4.12.4).
    5..T is a top-level class, and an assert statement (?14.10) lexically nested within T is executed.
    Above is from JLS.
    public class Demo {
         static int y;
         int x=instanceMethod();
         int instanceMethod()
              System.out.println("instance method");
              return 5;
         public static void main(String[] args)
              Demo.y=15;
              Demo.staticMethod();
         static void staticMethod()
              System.out.println("static method");
    }In this case the output is static method
    This contradicts points 2 and 3, since in this program static method is invoked and a static field is assigned , yet instanceMethod is not called, i.e not initialized

    Initialization of a class consists of executing its static initializers and the initializers for static fields (class variables) declared in the class. Initialization of an interface consists of executing the initializers for fields (constants) declared there.
    Your class has no static initializer nor class variable initializer...
    Therefore I wouldn't say your example illustrates the statement you mentioned.

  • JDK class initialization...

    Hi,
    I believe that class level member variables are not guarenteed to be initialized anymore by the JDK starting from jdk1.4 due an optimization that tries to reuse the instances.
    So for example, if I defined a class level String variable, and was creating a number of instances of this class, it could be that some of the valus of this variable would be "dirty", i.e they would contain the previous values leftover from the last instance. So it was the developer's responsibility to make sure to explicitly initalize all class level variables.
    Can anyone confirm this behaviour? Is this still the case?
    Thanks

    Hi,
    I believe that class level member variables are not
    guarenteed to be initialized anymore by the JDK
    starting from jdk1.4 due an optimization that tries to
    reuse the instances.Initialization is very closely described in the spec.
    Refer to these sections to get started:
    12.4 Initialization of Classes and Interfaces
    12.4.1 When Initialization Occurs
    12.4.2 Detailed Initialization Procedure
    http://java.sun.com/docs/books/jls/second_edition/html/execution.doc.html#44411
    So for example, if I defined a class level String
    variable, and was creating a number of instances of
    this class, it could be that some of the valus of this
    variable would be "dirty", i.e they would contain the
    previous values leftover from the last instance. So
    it was the developer's responsibility to make sure to
    explicitly initalize all class level variables.That would sound like a bug to me. Can you post
    a code example that demonstrates this?

  • Ctor/methods running before class initialization

    I was just reading the assert docs (http://java.sun.com/j2se/1.4/docs/guide/lang/assert.html) and have a question on the very last question/answer there:
    "Why does an assert statement that executes before its class is initialized behave as if assertions were enabled in the class?
    Few programmers are aware of the fact that a class's constructors and methods can run prior to its initialization. When this happens, it is quite likely that the class's invariants have not yet been established, which can cause serious and subtle bugs. Any assertion that executes in this state is likely to fail, alerting the programmer to the problem. Thus, it is generally helpful to the programmer to execute all assertions encountered while in this state."
    I'd never heard of this before. A class's constructors and methods can run prior to its initialization? Does anyone know how or why this can happen?
    Thanks.

    When I run the code below with an empty main, it prints "foo", implying the original person's question has not been adequately answered. The question was about how "a class's constructors and methods can run prior to its initialization." (This was mentioned in Sun's jdk1.4 documentation on the Assertion api.
    Can any one help?
    class foo
    private static final foo bar;
    static
    bar = new foo();
    System.out.println(bar.toString());
    private static final String FOO_STR = "foo";
    public foo()
    public String toString()
    return FOO_STR;

  • Class Initialization Sequence

    I got:
    public class Example {
         var exampleVar : Test = Test(component: this);
    public class Test {
         public Test(component: Example){
              this.component = component;
         var component : Example;
    }Is it correct in OO programming? I need bidirectional communication between the two class, without making all Example fields public.
    What about the initialization of Example when I assign that to the component variable?
    Thanks, probably a not-so-smart question.

    Jumpa wrote:
    Is it correct in OO programming? I need bidirectional communication between the two class, without making all Example fields public.This is true in Java, not in JavaFX, which uses a different paradigm.
    In general, we don't have constructors in JavaFX. We use public (or public-init) variables, having often default values, so they can be skipped when creating the class, allowing some flexibility in the object creation:
    var rect1 = Rectangle { x: 10, y: 10, width: 100, height: 50 }
    vs.
    var rect1 = Rectangle { width: 100, height: 50 }
    where Java would need two constructors or lot of accessors.
    This avoids the verbosity of Java where you write lot of boilerplate code to make accessors, flexible constructors doing almost the same thing, etc.
    The power of JavaFX resides in the binding and the on replace idioms: thus, where you have a constructor or setter in Java to check limits, convert types or set secondary variables, you use binding or on replace code to do this stuff.
    You still have encapsulation (public variables as accessors, perhaps private ones if conversion is needed), in a different way.

  • Java class initialization.

    public class ClassTest {
    ClassTest classtest = new ClassTest();
    public static void main(String[] args) {
    new ClassTest();
    Very worse code. but is there possible to break this.

    Ravindar_JAVA wrote:
    Very worse code. Yes indeed.
    but is there possible to break this.I do not understand what you mean. Please elaborate.

  • Why is the static initializer instantiating my class?!

    It seems that the static { ... } blocks for my enhanced classes actually
    create instances of those classes. Gack! It seems, furthermore, that
    this is due to the JDO spec itself, whose JDOImplHelper.registerClass()
    requires an instance of the class being registered. Double gack!
    This is causing a problem for me, because I've put a sequence generator in
    my class's constructor. Now merely **loading** a PC class will cause my
    sequence to be incremented (not great), or will throw an exception if the
    environment isn't set up for the sequence generator (terrible). This
    latter problem happens if I enhance my classes, then try to enhance them
    again -- the enhancer tries to load my class, the static { ... } block
    tries to load the sequence generator, and the whole enhancer blows up.
    Questions:
    * Why is this necessary? Why does JDOImplHelper.registerClass() take an
    instance of the class being registered? Could the call to
    JDOImplHelper.registerClass() happen the first time the ctor is called,
    instead of inside a static { ... } block?
    * Given that the above questions probably have reasonable answers, how
    should I work around this problem?
    Thanks,
    Paul

    Hi Patrick,
    Do you understand why jdoNewInstance and jdoNewObjectIdInstance are not static? And if that could
    be done, would that void the need to register the class when loaded?
    David
    Patrick Linskey wrote:
    >
    On 5/28/02 12:39 PM, "Paul Cantrell" <[email protected]> wrote:
    Questions:
    * Why is this necessary? Why does JDOImplHelper.registerClass() take an
    instance of the class being registered? Could the call to
    JDOImplHelper.registerClass() happen the first time the ctor is called,
    instead of inside a static { ... } block?The JDO spec inserts some utility methods into PersistenceCapable classes
    for which it needs a method around.
    These utility methods are the jdoNewInstance() methods and the
    jdoNewObjectIdInstance() methods. These methods improve performance by
    allowing PersistenceCapable objects and application ID OID classes to be
    created without using reflection.
    This class registration must occur at class initialization time, because
    your first operation on the class might very well be to look up objects of
    that class from the data store, in which the no-args constructor might not
    be called.
    * Given that the above questions probably have reasonable answers, how
    should I work around this problem?Your best bet is probably to not do the sequence generation in your no-args
    constructor. One option would be to create a constructor with a marker
    boolean that designates if sequence generation should occur; another
    probably more elegant solution would be to create a factory method that uses
    the default constructor and then assigns an ID, or fetches an ID and then
    invokes a non-default constructor with that ID.
    -Patrick
    Patrick Linskey [email protected]
    SolarMetric Inc. http://www.solarmetric.com

  • Set fields of derived class in base class constructor via reflection?

    Does the Java Language Specification explicitly allow setting of fields of a derived class from within the base class' constructor via reflection? The following test case runs green, but I would really like to know if this Java code is compatible among different VM implementations.
    Many thanks for your feedback!
    Norman
    public class DerivedClassReflectionWorksInBaseClassConstructorTest extends TestCase {
    abstract static class A {
        A() {
            try {
                getClass().getDeclaredField("x").setInt(this, 42);
            } catch (Exception e) {
                throw new RuntimeException(e);
    static class B extends A {
        int x;
        B() {
        B(int x) {
            this.x = x;
    public void testThatItWorks() {
        assertEquals(42, new B().x);
        assertEquals(99, new B(99).x);
    }

    why not just put a method in the superclass that the subclasses can call to initialize the subclass member variable?In derived classes (which are plug-ins), clients can use a field annotation which provides some parameter metadata such as validators and the default value. The framework must set the default value of fields, before the class' initializer or constructors are called. If the framework would do this after derived class' initializer or constructors are called, they would be overwritten:
    Framework:
    public abstract class Operator {
        public abstract void initialize();
    }Plug-In:
    public class SomeOperator extends Operator {
        @Parameter(defaultValue="42", interval="[0,100)")
        double threshold;
        @Parameter(defaultValue="C", valueSet="A,B,C")
        String mode;
        public void setThreshold(double threshold) {this.threshold = threshold;}
        public void setMode(String mode) {this.mode = mode;}
        // called by the framework after default values have been set
        public void initialize() {
    }On the other hand, the default values and other metadata are also used to create GUIs and XML I/O for the derived operator class, without having it instantiated. So we cannot use the initial instance field values for that, because we don't have an instance.

  • Can't create new instance of class in servlet.

    I'm running Tomcat 5.5 and am trying to create a new instance of a class in a servlet. The class is an Apache Axis (1.4) proxy for a Web Service.
    Is there any particular reason this is happening, and any way to fix it?
    The stack trace is as follows:
    WARNING: Method execution failed:
    java.lang.ExceptionInInitializerError
         at org.apache.axis.utils.Messages.<clinit>(Messages.java:36)
         at org.apache.axis.configuration.EngineConfigurationFactoryFinder.newFactory(EngineConfigurationFactoryFinder.java:184)
         at org.apache.axis.configuration.EngineConfigurationFactoryFinder.access$200(EngineConfigurationFactoryFinder.java:46)
         at org.apache.axis.configuration.EngineConfigurationFactoryFinder$1.run(EngineConfigurationFactoryFinder.java:128)
         at java.security.AccessController.doPrivileged(Native Method)
         at org.apache.axis.configuration.EngineConfigurationFactoryFinder.newFactory(EngineConfigurationFactoryFinder.java:113)
         at org.apache.axis.configuration.EngineConfigurationFactoryFinder.newFactory(EngineConfigurationFactoryFinder.java:160)
         at org.apache.axis.client.Service.getEngineConfiguration(Service.java:813)
         at org.apache.axis.client.Service.getAxisClient(Service.java:104)
         at org.apache.axis.client.Service.<init>(Service.java:113)
         at server.proxies.webservicex.net.stockquote.StockQuoteLocator.<init>(StockQuoteLocator.java:12)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
         at java.lang.reflect.Constructor.newInstance(Unknown Source)
         at java.lang.Class.newInstance0(Unknown Source)
         at java.lang.Class.newInstance(Unknown Source)

    Of course there's a particular reason it's happening. Nothing in a computer happens unless it's for a particular reason. You question ought to be what is that reason.
    Well, I don't know what it is. The class org.apache.axis.utils.Messages threw some kind of exception when it was being loaded, because <clinit> means "class initialization" in a stack trace. That would most likely be in a static initializer block in that class. I expect it is because of some mis-configuration in your system, but you'd have to read and understand the apache code to find out what. Or maybe ask over at the Axis site, where there might be a forum or a mailing list.

  • Instance initializer and static initializer blocks

    Hi guys,
    I read about the above mentioned in the JLS and also in a book before, but I still don't quite understand, what is the use of these. I sort of have a rough idea, but not exactly. I mean, what is the purpose of the instance initializer and static initializer blocks, how can it be useful? I understand I can execute pieces of code that will initialize instance and static variables accordingly, but how is it different then to using a constructor to initialize these fields? Are these pieces of code executed before any constructor is executed, or when otherwise?
    Sorry for my noob, I'm learning.
    PR.

    Static initializers are useful for initializing a class when the initialization is more complex than simply setting a single variable, or when that initialization can throw a checked exception.
    public class Foo {
      private static final Bar bar;
      static {
        try {
          bar = new Bar();
          bar.doSomeInitializationStuff();
        catch (SomeCheckedExceptionThatBarThrows e) {
          throw new ExceptionInInitializerError(e);
    }Here we could not do the two-step new Bar() + doSomeInit() stuff in the line where we declare the bar variable. Additionally, assuming that one or both of those can throw a checked exception, we could not do that on the declaration line; we need the static initializer to wrap that in the appropriate unchecked exception.
    This allows us to do more complex class initialization when the class is loaded than we could do with a simple variable initialization.
    Instance initializers are useful if you want to perform the same steps in every constructor and don't want to have to repeat the code in each constructor. Instance initializers are executed as the first step of each constructor (or maybe it's after any super() calls, I forget).

  • Lazy Initialization

    Josh Bloch and Neal Gafter posted the following code puzzler. The thread in the static block blocks if you do "t.join()" but "t.join(10)" lets the program finish. Is this due to the private static variable which is being lazily initialized? Thanks for any mind-opening explanations!
    public class Lazy {
    private static boolean initialized = false;
    static {
    Thread t = new Thread(new Runnable() {
    public void run() {
    initialized = true;
    t. start();
    try {
    t.join();
    } catch (InterruptedException e) {
    throw new AssertionError(e);
    public static void main(String[] args) {
    System.out.println(initialized);
    }

    o, when the thread tries to update the value of
    the 'initialized' variable, it cannot because the
    lock for the Class object is held by a different
    Thread.
    But.... the Thread is NOT synchronized, so why should
    it care about locks? It's a sort of class
    initialization magic, right?The section in the JVM spec just before the link I provided states:
    =============
    A class or interface type T will be initialized immediately before one of the following occurs:
    * T is a class and an instance of T is created.
    * T is a class and a static method of T is invoked.
    * A nonconstant static field of T is used or assigned.
    =============
    Note the last item.
    Since the static initializer has not exited, the Class has not been initialized, therefore , the attempt to assign a value to 'initialized' in the Thread attepts to initialize the class (again) but finds it locked and the lock will never be released due to the join().
    When join(10) is used, the static block exits, and releases the lock. On release of the lock, any waiting threads are notified, and from the spec:
    =============
    If the class or interface has already been initialized, then no further action is required. Release the lock on the Class object and complete normally
    =============
    So, the second attempt to initialize the class (in the thread) finds the class already initialized, and therefore the initialization simply releases the lock and ends.
    Jim S.

  • Modifiying system classes

    hi
    I would like to change the Java.io.FileInputstream class and would like use System. Loadlibrary in it. Is it possible to do this
    Thanks in advance
    etsr

    Hi all,
    Is it possible to add new functionality to java system
    classes at loadtime?No. Not the way you are going.
    >
    E.g. i would like to add an "int instancecount" Field
    for every system class. This field could be
    incremented by the static class initializer while the
    finalize() method couldt decrement it. In this way i
    would have a rudimentary memory profiler (instance
    counter) without having to rely on the standard
    debugging interface. This would also make life a lot
    easier for ea developers, since the J2E server does
    not need to be restarted with any profiling options
    specified. So download the source and go crazy.
    Presumably you realize that reference counting, besides having a performance impact, is also not reliable. But you probably have already researched that by reading the numerous discussions on these forums which discuss that topic.
    If it was me I would tell the managers at my company to fire all of the idiot programmers that couldn't marginally figure out how to clean up normal resources. And with the real developers left then I would use an automated profiling tool to clean up the few leaks that always slip through. That is me though.
    >
    I've been poking around in the BCEL library
    (http://jakarta.apache.org/bcel/), but have not been
    able to get a custom classloader up and running as
    specified above. Among other problems, i've seen
    securityExceptions and "already loaded" exceptions
    when calling defineclass(....).
    Any ideas? Would this violate the JDK license (i'm not
    modifying the file rt.jar)?The only way to do it is modify the source. And you can do that as long as you don't distribute it to anyone.

  • SP6 Breaks Startup Class

    Hi. I have installed SP6 on WLS 5.1 and have experienced some interesting
    problems.
    Originally I installed the patch to fix some ClassCast problems I had with
    some servlets. This essentially fixed my problems until I installed a couple
    of the servlets as a startup class as follows:
    # Configure the ServletStartup class to run MyServlet's init()
    # method at startup
    # comment these out if the server hangs on startup!!!
    weblogic.system.startupClass.StartFPInitializer=\
    weblogic.servlet.utils.ServletStartup
    weblogic.system.startupArgs.StartFPInitializer=\
    servlet=FPInitializer
    I get two errors:
    1.) Related to my session beans:
    Mon Nov 06 23:09:34 CST 2000:<E> <WebLogicServer> Failed to invoke startup
    class
    StartFPInitializer=weblogic.servlet.utils.ServletStartup
    java.lang.NoClassDefFoundError: com.citadel.ivweb.fundses.FundLookupHome
    at com.citadel.ivweb.servlet.Initializer.class$(Initializer.java:38)
    at
    com.citadel.ivweb.servlet.Initializer.refresh(Initializer.java:83)
    2.) Related to a second startup with a very strangly worded exception (note
    the class not being found):
    Mon Nov 06 23:09:34 CST 2000:<E> <WebLogicServer> Failed to invoke startup
    class
    StartLoginHandler=weblogic.servlet.utils.ServletStartup
    java.lang.NoClassDefFoundError: weblogic/html/HtmlPage
    at java.lang.Class.newInstance0(Native Method)
    at java.lang.Class.newInstance(Class.java:237)
    at
    weblogic.servlet.internal.ServletStubImpl.createServlet(ServletStubIm
    I can work around this as follows:
    Install the sp6boot jar in the java_classpath and install the sp5 jar in the
    wls_classpath.
    Does anyone have any ideas?
    Thanks,
    Terry Trippany
    Citadel Investment Group
    Chicago

    Could you try to register the HelloWorldServlet (mentioned below) and see if the
    servlet gets instantiated at startup or not..
    I would also recommend you to send a test case to support and follow-up with
    them (if you
    need immediate attention)..
    Kumar
    Terry Trippany wrote:
    I can get sp6 to work but not with the startup classes.
    The stacktrace clearly shows
    java.lang.NoClassDefFoundError: com.citadel.ivweb.fundses.FundLookupHome
    Do you have the above class in weblogic classpath?Yes, in fact the only way I can get around both problems is to mix the
    service packs as listed below:
    Install the sp6boot jar in the java_classpath and install the sp5 jar inthe
    wls_classpath.This gets around the ClassCast problem and the ClassNotFound exceptions. I
    have played around with the classpaths but this is the only thing that work
    fore me.
    Thanks,
    Terry
    Kumar Allamraju <[email protected]> wrote in message
    news:[email protected]...
    1) I just tried in SP6 and it works fine for me.
    # Here we register the myservletclass servlet class
    weblogic.httpd.register.MyServlet=examples.servlets.HelloWorldServlet
    # Configure the ServletStartup class to run MyServlet's init() method
    at startup
    weblogic.system.startupClass.StartMyServlet=\
    weblogic.servlet.utils.ServletStartup
    weblogic.system.startupArgs.StartMyServlet=servlet=MyServlet
    The stacktrace clearly shows
    java.lang.NoClassDefFoundError: com.citadel.ivweb.fundses.FundLookupHome
    Do you have the above class in weblogic classpath?
    Does the same thing works fine with SP5?
    Kumar
    Terry Trippany wrote:
    Hi. I have installed SP6 on WLS 5.1 and have experienced some
    interesting
    problems.
    Originally I installed the patch to fix some ClassCast problems I hadwith
    some servlets. This essentially fixed my problems until I installed acouple
    of the servlets as a startup class as follows:
    # Configure the ServletStartup class to run MyServlet's init()
    # method at startup
    # comment these out if the server hangs on startup!!!
    weblogic.system.startupClass.StartFPInitializer=\
    weblogic.servlet.utils.ServletStartup
    weblogic.system.startupArgs.StartFPInitializer=\
    servlet=FPInitializer
    I get two errors:
    1.) Related to my session beans:
    Mon Nov 06 23:09:34 CST 2000:<E> <WebLogicServer> Failed to invokestartup
    class
    StartFPInitializer=weblogic.servlet.utils.ServletStartup
    java.lang.NoClassDefFoundError: com.citadel.ivweb.fundses.FundLookupHome
    atcom.citadel.ivweb.servlet.Initializer.class$(Initializer.java:38)
    at
    com.citadel.ivweb.servlet.Initializer.refresh(Initializer.java:83)
    2.) Related to a second startup with a very strangly worded exception(note
    the class not being found):
    Mon Nov 06 23:09:34 CST 2000:<E> <WebLogicServer> Failed to invokestartup
    class
    StartLoginHandler=weblogic.servlet.utils.ServletStartup
    java.lang.NoClassDefFoundError: weblogic/html/HtmlPage
    at java.lang.Class.newInstance0(Native Method)
    at java.lang.Class.newInstance(Class.java:237)
    at
    weblogic.servlet.internal.ServletStubImpl.createServlet(ServletStubIm
    I can work around this as follows:
    Install the sp6boot jar in the java_classpath and install the sp5 jar inthe
    wls_classpath.
    Does anyone have any ideas?
    Thanks,
    Terry Trippany
    Citadel Investment Group
    Chicago

  • Initializer block not called when static method called

    public class Initializer {
         Initializer(){
              System.out.println("Constructor called");
                   System.out.println("CLASS INITIALIZED");
         static void method(){
              System.out.println("Static method called");
         public static void main(String[] args) {
              Initializer.method();
    From the JLS
    A class or interface type T will be initialized immediately before the first occurrence of any one of the following:
    T is a class and an instance of T is created.
    T is a class and a static method declared by T is invoked.
    [b]
    But when i call the static method , if the class is initialized shouldnt the initializer block be called, it is not called, why.

    Perhaps running something like this will add a little more colour?:
    public class Initializer {
        static {
            System.out.println("First static initializer");
            System.out.println("First instance initializer");
        Initializer() {
            System.out.println("Constructor");
        static {
            System.out.println("Second static initializer");
            System.out.println("Second instance initializer");
        static void staticMethod() {
            System.out.println("staticMethod");
        void instanceMethod() {
            System.out.println("instanceMethod");
        public static void main(String[] args) {
            System.out.println("main");
            staticMethod();
            new Initializer().instanceMethod();
    }

  • Testing classes without a main()...

    i was wondering if its possible to run a test ona class without a main...my prof isnt letting us use "static" methods because it obviously defeats the purpose of OOD. So now im left wondering how the hell to get my test classes running...here is an example of one..i made the "main" method here static and it worked fine...but now how do i go about making it work non static?
    import java.util.*;
    import java.io.*;
    public class BankAccountTest
    public void main(String[] args)
         String testName = "Testy McTesterson";
         BankAccount test = new BankAccount();
         test.setBalance(100.00);
         System.out.println(test.getBalance());
         test.setName(testName);
         System.out.println(test.getName());
    thanks in advance,
    Cuda
    Edited by: 74Cuda on Mar 8, 2008 7:28 PM

    How the Java virtual machine "gets started" is covered in the JVM specification 5.2 "The Java virtual machine starts up by creating an initial class, which is specified in an implementation-dependent manner, using the bootstrap class loader (�5.3.1). The Java virtual machine then links the initial class, initializes it, and invokes its public class method void main(String[])". Note that it's a class - ie static - method that kicks the whole thing off. And it really has to be as no code has been run, and no objects created at this point.
    http://java.sun.com/docs/books/jvms/second_edition/html/ConstantPool.doc.html#51579
    Magic involves suspending the everyday laws of nature and logic to effect the impossible. Stage magic merely hides these laws to create a pleasant illusion.
    I suspect that IDEs' lack of an apparent static main() method when performing unit testing is just stage magic.
    For instance junit.swingui.TestRunner includes this method:
    public static void main(String[] args) {
        new TestRunner().start(args);
    }

Maybe you are looking for

  • Best app to safe website info

    I am trying to find out the best app to save information from different websites. I do not want to use Facebook, Twitter or Pinterest. Is there others and which would be the most accessible from all sites? It is education based and have Vimeo Edmondo

  • Website requires minimum browser: Internet Explorer 6.0

    I am trying to work in an image based website.  The message I recieve when I try to get into the site:  This image flow resource requires one of the following miminum browser versions:  Internet explorer 6.0.  The browser you are currently using is A

  • Entity Currency Adj, Parent Currency adj for Parent-child with same currenc

    Hi, In 11.1.2.1 I noticed that if parent and base entity currencies are same, entity currency and entity currency adjustments equal parent currency and parent currency adjustments respectively. If the currencies are different, the entity currency tot

  • Macbook Air. Unable to send or receive e mails.

    We have just changed from EE broadband to BT Infinity. Coincidently, the same day I could no longer receive e mails.  EE say this is nothing to do with them, BT say it is nothing to do with them. I am a complete techno phobe and have now played aroun

  • BEx Browser table details.

    Dear All, In our SAP BI system BEx Browser,we are having lot of Folders and in each Folder we have multiple queries and work book. I need a table name related to BEx Browser, where i can search, in which Folder contains how many queries etc. Thanks C