ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Magesh Umasankar" <>
Subject Re: ExecuteJava and initializeClass
Date Wed, 16 Jan 2002 16:47:22 GMT
From: "Conor MacNeill" <>

> OK, check here for some relevant bugs from Ant
> These were the original motivaters for this change. It would be good if
> these continue to stay fixed.

This is the patch I propose (sorry it is not in diff yet)

            } else {
                loader = new AntClassLoader(project.getCoreLoader(),
project, classpath, false);
                target = loader.forceLoadClass(classname);
                java.lang.reflect.Constructor[] c =
                if (c != null) {//This check is not really needed, but
                    java.lang.reflect.Constructor c1 = c[0]; //Class will
have at least one constructor.
                    String[] s = new String[1024];  //Hope nobody has a
constructor which taken in 1024 arguments
                    try {
                    } catch (Throwable t) {
                            Ignore as static initializers would have
                            been loaded anyway.

> You are thinking reflection not straight Class.newInstance?

> You'll need a valid Constructor object for that and I'm not sure
> it will work but worth a try.

JVM guarantees that each class *will* have a constructor, either
provided by default or explicitly specified.  So, getting a constructor
object is easy and it can be safely assumed that we will get
a constructor object when using reflection.

> I remember trying a number of things to trigger startic initializers to
> run to no avail. Let me know if you have more success.

I would be most pleased if you can please cross-verify and let
me know if this works after patching up ExecuteJava with what
I have provided above.  It works in my environments...

After you confirm, perhaps, I may even move this piece
into AntClassLoader itself.

> Conor


To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message