git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@278078 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -310,12 +310,7 @@ public final class IntrospectionHelper implements BuildListener { | |||||
| * @return a helper for the specified class | * @return a helper for the specified class | ||||
| */ | */ | ||||
| public static synchronized IntrospectionHelper getHelper(Class c) { | public static synchronized IntrospectionHelper getHelper(Class c) { | ||||
| IntrospectionHelper ih = (IntrospectionHelper) helpers.get(c); | |||||
| if (ih == null) { | |||||
| ih = new IntrospectionHelper(c); | |||||
| helpers.put(c, ih); | |||||
| } | |||||
| return ih; | |||||
| return getHelper(null, c); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -332,9 +327,19 @@ public final class IntrospectionHelper implements BuildListener { | |||||
| * @return a helper for the specified class | * @return a helper for the specified class | ||||
| */ | */ | ||||
| public static IntrospectionHelper getHelper(Project p, Class c) { | public static IntrospectionHelper getHelper(Project p, Class c) { | ||||
| IntrospectionHelper ih = getHelper(c); | |||||
| // Cleanup at end of project | |||||
| p.addBuildListener(ih); | |||||
| IntrospectionHelper ih = (IntrospectionHelper) helpers.get(c); | |||||
| if (ih == null) { | |||||
| ih = new IntrospectionHelper(c); | |||||
| if (p != null) { | |||||
| // #30162: do *not* cache this if there is no project, as we | |||||
| // cannot guarantee that the cache will be cleared. | |||||
| helpers.put(c, ih); | |||||
| } | |||||
| } | |||||
| if (p != null) { | |||||
| // Cleanup at end of project | |||||
| p.addBuildListener(ih); | |||||
| } | |||||
| return ih; | return ih; | ||||
| } | } | ||||
| @@ -304,9 +304,7 @@ public class ProjectHelper { | |||||
| } | } | ||||
| IntrospectionHelper ih = | IntrospectionHelper ih = | ||||
| IntrospectionHelper.getHelper(target.getClass()); | |||||
| project.addBuildListener(ih); | |||||
| IntrospectionHelper.getHelper(project, target.getClass()); | |||||
| for (int i = 0; i < attrs.getLength(); i++) { | for (int i = 0; i < attrs.getLength(); i++) { | ||||
| // reflect these into the target | // reflect these into the target | ||||
| @@ -368,7 +366,7 @@ public class ProjectHelper { | |||||
| target = ((TypeAdapter) target).getProxy(); | target = ((TypeAdapter) target).getProxy(); | ||||
| } | } | ||||
| IntrospectionHelper.getHelper(target.getClass()).addText(project, | |||||
| IntrospectionHelper.getHelper(project, target.getClass()).addText(project, | |||||
| target, text); | target, text); | ||||
| } | } | ||||
| @@ -388,7 +386,7 @@ public class ProjectHelper { | |||||
| public static void storeChild(Project project, Object parent, | public static void storeChild(Project project, Object parent, | ||||
| Object child, String tag) { | Object child, String tag) { | ||||
| IntrospectionHelper ih | IntrospectionHelper ih | ||||
| = IntrospectionHelper.getHelper(parent.getClass()); | |||||
| = IntrospectionHelper.getHelper(project, parent.getClass()); | |||||
| ih.storeElement(project, parent, child, tag); | ih.storeElement(project, parent, child, tag); | ||||
| } | } | ||||
| @@ -320,7 +320,7 @@ public class UnknownElement extends Task { | |||||
| String parentUri = getNamespace(); | String parentUri = getNamespace(); | ||||
| Class parentClass = parent.getClass(); | Class parentClass = parent.getClass(); | ||||
| IntrospectionHelper ih = IntrospectionHelper.getHelper(parentClass); | |||||
| IntrospectionHelper ih = IntrospectionHelper.getHelper(getProject(), parentClass); | |||||
| if (children != null) { | if (children != null) { | ||||
| @@ -863,7 +863,7 @@ public class ProjectHelperImpl extends ProjectHelper { | |||||
| public void init(String propType, AttributeList attrs) throws SAXParseException { | public void init(String propType, AttributeList attrs) throws SAXParseException { | ||||
| Class parentClass = parent.getClass(); | Class parentClass = parent.getClass(); | ||||
| IntrospectionHelper ih = | IntrospectionHelper ih = | ||||
| IntrospectionHelper.getHelper(parentClass); | |||||
| IntrospectionHelper.getHelper(helperImpl.project, parentClass); | |||||
| try { | try { | ||||
| String elementName = propType.toLowerCase(Locale.US); | String elementName = propType.toLowerCase(Locale.US); | ||||
| @@ -200,7 +200,7 @@ public class AntStructure extends Task { | |||||
| IntrospectionHelper ih = null; | IntrospectionHelper ih = null; | ||||
| try { | try { | ||||
| ih = IntrospectionHelper.getHelper(element); | |||||
| ih = IntrospectionHelper.getHelper(getProject(), element); | |||||
| } catch (Throwable t) { | } catch (Throwable t) { | ||||
| /* | /* | ||||
| * XXX - failed to load the class properly. | * XXX - failed to load the class properly. | ||||