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 7906] New: - Path tag failes when Ant is started from Together 6.0 Antrunner
Date Wed, 10 Apr 2002 06:28:38 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7906>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7906

Path tag failes when Ant is started from Together 6.0 Antrunner

           Summary: Path tag failes when Ant is started from Together 6.0
                    Antrunner
           Product: Ant
           Version: 1.4.1
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Other
        AssignedTo: ant-dev@jakarta.apache.org
        ReportedBy: mei@isogmbh.de
                CC: mei@isogmbh.de


Overview Description: 
 When the path tag is used in an ant build file and ant is started from the 
Together 6.0 Antrunner plugin, Ant throws a NoSuchMethodException in 
org.apache.tools.ant.Project -> public Object createDataType(String typeName).
This problem does not appear with Together versions prior to 6.0.

Steps to Reproduce: 
1) Create a simple build.xml which contains a path tag below the project tag.
2) Activate Antrunner in Together 6.0.
3) Run a target of the build file from within Together with -v flag of ant.

Additional Information:
The Together 6.0 antrunner uses its own Project class which is derived from 
org.apache.tools.ant.Project. The createDataType method in 
org.apache.tools.ant.Project searches for a constructor of the datatype 
(reproducable with Path, may also appear with other datatypes), 
e.g. Path(Project prj) by using reflection. Because the Together plugin uses a 
derived Project class, the line 
ctor = c.getConstructor(new Class[] {getClass()}); 
searches for a constructor Path(TgProject.class) which is not available.

Workaround:
replace
ctor = c.getConstructor(new Class[] {getClass()}); 
with
ctor = c.getConstructor(new Class[] {Project.class});

Full createDataType() method which resolved the problem:
    public Object createDataType(String typeName) throws BuildException {
        Class c = (Class) dataClassDefinitions.get(typeName);

        if (c == null)
            return null;

        try {
            java.lang.reflect.Constructor ctor = null;
            boolean noArg = false;
            // DataType can have a "no arg" constructor or take a single 
            // Project argument.
            try {
                ctor = c.getConstructor(new Class[0]);
                noArg = true;
            } catch (NoSuchMethodException nse) {
            	// BEGIN MEI 09.04.2002 resolves Problem with ant runner in 
Together 6.0 (they use a derived Project class !)
//                ctor = c.getConstructor(new Class[] {getClass()});
                ctor = c.getConstructor(new Class[] {Project.class});
            	// END MEI 09.04.2002 resolves Problem with ant runner in 
Together 6.0 (they use a derived Project class !)
                
                noArg = false;
            }

            Object o = null;
            if (noArg) {
                 o = ctor.newInstance(new Object[0]);
            } else {
                 o = ctor.newInstance(new Object[] {this});
            }
            if (o instanceof ProjectComponent) {
                ((ProjectComponent)o).setProject(this);
            }
            String msg = "   +DataType: " + typeName;
            log (msg, MSG_DEBUG);
            return o;
        } catch (java.lang.reflect.InvocationTargetException ite) {
            Throwable t = ite.getTargetException();
            String msg = "Could not create datatype of type: "
                 + typeName + " due to " + t;
            throw new BuildException(msg, t);
        } catch (Throwable t) {
            String msg = "Could not create datatype of type: "
                 + typeName + " due to " + t;
            throw new BuildException(msg, t);
        }
        finally
        {
		log ("<<< createDataType", MSG_DEBUG);
        }
    }

--
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