ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 30889] - java task should use new ClassLoader for every call.
Date Sun, 03 Sep 2006 16:45:10 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=30889>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=30889


peterreilly@apache.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WONTFIX




------- Additional Comments From peterreilly@apache.org  2006-09-03 16:45 -------
The java task does use a new ClassLoader for every call.
For example:
<project name="statictest" default="static">
  <target name="static">
    <mkdir dir="build/classes"/>
    <mkdir dir="src"/>
    <echo file="src/StaticTest.java">
public class StaticTest {
    private static boolean verbose = false;

    public static void main(String[] argv) {
        System.out.println("verbose is " + verbose);
        verbose = true;
    }
}
    </echo>
    <javac srcdir="src" destdir="build/classes"/>
    <java classname="StaticTest" classpath="build/classes"/>
    <java classname="StaticTest" classpath="build/classes"/>
  </target>
</project>

Will print:

verbose is false
verbose is false

If however the class in question is in the ant classpath,
the classloader used (in the usual delegated classloader fashion)
will be the same as the ant project classloader - which will
not be different each time. If it was different all sorts of
nasty things would happen - i.e. the Project class as see
from the class loaded would be different from the Project class
that created the class.

Marking this as WONTFIX - there is a good workaround for the
case where the class in question is in the ant classpath - use
fork="yes".


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


Mime
View raw message