diff --git a/src/etc/testcases/taskdefs/presetdef.xml b/src/etc/testcases/taskdefs/presetdef.xml index 116ed58b0..1cce733b7 100644 --- a/src/etc/testcases/taskdefs/presetdef.xml +++ b/src/etc/testcases/taskdefs/presetdef.xml @@ -49,6 +49,22 @@
+ + + + + + + + + + + + + + MyText diff --git a/src/main/org/apache/tools/ant/IntrospectionHelper.java b/src/main/org/apache/tools/ant/IntrospectionHelper.java index 062b588f6..57762d238 100644 --- a/src/main/org/apache/tools/ant/IntrospectionHelper.java +++ b/src/main/org/apache/tools/ant/IntrospectionHelper.java @@ -349,19 +349,22 @@ public final class IntrospectionHelper implements BuildListener { throws InvocationTargetException, IllegalAccessException, InstantiationException { if (child != null) { - return child; } else if (c.getParameterTypes().length == 0) { - return c.newInstance(new Object[] {}); + child = c.newInstance(new Object[] {}); } else { - return c.newInstance(new Object[] { + child = c.newInstance(new Object[] { project}); } + if (child instanceof PreSetDef.PreSetDefinition) { + child = ((PreSetDef.PreSetDefinition) child) + .createObject(project); + } + return child; } public void store(Object parent, Object child) throws InvocationTargetException, IllegalAccessException, InstantiationException { - m.invoke(parent, new Object[] {child}); } @@ -415,6 +418,10 @@ public final class IntrospectionHelper implements BuildListener { child = c.newInstance(new Object[] { project}); } + if (child instanceof PreSetDef.PreSetDefinition) { + child = ((PreSetDef.PreSetDefinition) child) + .createObject(project); + } m.invoke(parent, new Object[] {child}); return child; } diff --git a/src/testcases/org/apache/tools/ant/taskdefs/PreSetDefTest.java b/src/testcases/org/apache/tools/ant/taskdefs/PreSetDefTest.java index f4561fb13..9b75237c8 100644 --- a/src/testcases/org/apache/tools/ant/taskdefs/PreSetDefTest.java +++ b/src/testcases/org/apache/tools/ant/taskdefs/PreSetDefTest.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2003 The Apache Software Foundation. All rights + * Copyright (c) 2003-2004 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -58,6 +58,7 @@ import org.apache.tools.ant.BuildFileTest; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; +import org.apache.tools.ant.types.FileSet; /** * @author Peter Reilly @@ -102,6 +103,10 @@ public class PreSetDefTest extends BuildFileTest { public void testElementOrder2() { expectLog("element.order2", "Line 1Line 2Line 3"); } + + public void testAntTypeTest() { + expectLog("antTypeTest", ""); + } /** * A test class to check default properties @@ -121,5 +126,15 @@ public class PreSetDefTest extends BuildFileTest { getProject().log("attribute is " + attribute); } } + + /** + * A test class to check presetdef with add and addConfigured and ant-type + */ + public static class AntTypeTest extends Task { + public void addFileSet(FileSet fileset) { + } + public void addConfiguredConfigured(FileSet fileset) { + } + } }