Browse Source

spread the project instance a little further (this accounts for a

number of NPEs when using <taskdef> that have been reported).


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269854 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 23 years ago
parent
commit
31d76fc5d0
3 changed files with 9 additions and 7 deletions
  1. +4
    -5
      src/main/org/apache/tools/ant/IntrospectionHelper.java
  2. +4
    -2
      src/main/org/apache/tools/ant/ProjectHelper.java
  3. +1
    -0
      src/main/org/apache/tools/ant/taskdefs/Ant.java

+ 4
- 5
src/main/org/apache/tools/ant/IntrospectionHelper.java View File

@@ -55,7 +55,6 @@
package org.apache.tools.ant;

import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.DataType;
import org.apache.tools.ant.types.EnumeratedAttribute;

import java.lang.reflect.Method;
@@ -328,8 +327,8 @@ public class IntrospectionHelper implements BuildListener {
}
try {
Object nestedElement = nc.create(element);
if (nestedElement instanceof DataType) {
((DataType)nestedElement).setProject(project);
if (nestedElement instanceof ProjectComponent) {
((ProjectComponent) nestedElement).setProject(project);
}
return nestedElement;
} catch (IllegalAccessException ie) {
@@ -575,8 +574,8 @@ public class IntrospectionHelper implements BuildListener {
throws InvocationTargetException, IllegalAccessException, BuildException {
try {
Object attribute = c.newInstance(new String[] {value});
if (attribute instanceof DataType) {
((DataType)attribute).setProject(p);
if (attribute instanceof ProjectComponent) {
((ProjectComponent) attribute).setProject(p);
}
m.invoke(parent, new Object[] {attribute});
} catch (InstantiationException ie) {


+ 4
- 2
src/main/org/apache/tools/ant/ProjectHelper.java View File

@@ -561,8 +561,10 @@ public class ProjectHelper {
try {
String elementName = propType.toLowerCase(Locale.US);
if (parent instanceof UnknownElement) {
child = new UnknownElement(elementName);
((UnknownElement) parent).addChild((UnknownElement) child);
UnknownElement uc = new UnknownElement(elementName);
uc.setProject(project);
((UnknownElement) parent).addChild(uc);
child = uc;
} else {
child = ih.createElement(project, parent, elementName);
}


+ 1
- 0
src/main/org/apache/tools/ant/taskdefs/Ant.java View File

@@ -260,6 +260,7 @@ public class Ant extends Task {
Enumeration e = properties.elements();
while (e.hasMoreElements()) {
Property p=(Property) e.nextElement();
p.setProject(newProject);
p.execute();
}


Loading…
Cancel
Save