ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Magesh Umasankar" <umag...@apache.org>
Subject ExecuteJava and initializeClass
Date Wed, 16 Jan 2002 00:03:01 GMT
Hi,
I am working on a PR and came upon some code that
I have difficulty following.  If somebody can shed some
light on it, I would appreciate it very much.

I am looking at ExecuteJava's execute method which
contains

Class target = null;
if (classpath == null) {
    target = Class.forName(classname);
} else {
    loader = new AntClassLoader(project.getCoreLoader(), project, classpath,
false);
    loader.setIsolated(true);
    loader.setThreadContextLoader();
    target = loader.forceLoadClass(classname);
    AntClassLoader.initializeClass(target);
}
    final Method main = target.getMethod("main", param);
    main.invoke(null, argument);

Why is AntClassLoader.initializeClass(target) being called?
This method creates a new instance of the class by calling
its no-arg constructor. I mean, when main.invoke is called, the
static initializers of the class are anyway going to be invoked,
right?  Or is it being invoked to work around some JDK bug?
The issue I have is that the class's constructor gets called
twice if the main method constructs this object also.

Cheers,
Magesh




--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message