Hi experts,

Recently, I came across a problem in Ant and the solution seems to
write a custom LocalProperties implementation to fix the issue. But I
found that this class has a sole privet constructor which prevents me
from sub-classing it:

55     /**
56      * Construct a new LocalProperties object.
57      */
58     private LocalProperties() {
59     }

I'd like to know, is such design on purpose? What's the consideration
in making it private?

I know Ant provided a mechanism as following which seems to have the
ability to register user-defined LocalProperties class:

LocalProperties l = (LocalProperties) project.getReference(
 MagicNames.REFID_LOCAL_PROPERTIES);

(above line is from line 39 of ant source code
https://git-wip-us.apache.org/repos/asf?p=ant.git;a=blob;f=src/main/org/apache/tools/ant/property/LocalProperties.java;h=fb2fa9c0a80a4cadf0fbc3098eedef16fd710aa9;hb=1c927b15af84cfce315a0ef6f4db60c7d47c2c50,
also seen from many other tasks )


But actually it doesn't work as LocalProperties cannot be extended,
thus above assigning would cause class cast issue. So I'm confused, if
this is not supposed to be extended, then what's the point of having
MagicNames.REFID_LOCAL_PROPERTIES?


Some additional context on why I want to extend the class. Due to this
ant bug: https://issues.apache.org/bugzilla/show_bug.cgi?id=55074, our
framework, which calls ant, occasionally throws
ConcurrentModificationException when parallel is used. To fix the
thread-safe issue in LocalPropertyStack on our side,  I'd like to
create an alternative one by overriding following method in
LocalProperties:


61     /**
62      * Get the initial value.
63      * @return a new localproperties stack.
64      */
65     protected synchronized LocalPropertyStack initialValue() {
66         return new LocalPropertyStack();
67     }


Any input would be appreciated.
Thanks,
Gan

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@ant.apache.org
For additional commands, e-mail: user-h...@ant.apache.org

Reply via email to