User: ara_e_w Date: 02/06/15 13:25:53 Modified: core/src/xdoclet/tagshandler AbstractProgramElementTagsHandler.java Log: fix the ordering bug of members. This piece of code was sorting the original members list, after that all members are sorted and that wrong (for example for dataobject's constructor, which becomes ordered and backward incompatible). A general problem is that anywhere we return a XBlabla[] it's shared by everyone, and if a piece of code sorts it the shared array is sorted and everyone else affected. I tested returning a new array for each client but that makes it %10 slower (12 seconds more building samples, total=1.42 -> 1.54 sec). So I patched the part that sorts, but the list is still shared. So anyone out there plz note that if you're going to sort a XBlabla[] array make a copy first. Another thing I noticed is that we can make xjavadoc a lot faster by using a flyweight (like the way we did it for parameters) for methods/etc of binary class. Binary classes are always there with java.lang.Class/Method/etc classes, so we can create a pool and create XBlabla[] whenever needed, no create and store the whole stuff. And even more: add isBinary() to XClass and do not even bother looping over its methods for ejb:interface or whatever @tag that can never ever exsit. What a long commit msg :-) Revision Changes Path 1.4 +18 -2 xdoclet/core/src/xdoclet/tagshandler/AbstractProgramElementTagsHandler.java Index: AbstractProgramElementTagsHandler.java =================================================================== RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/tagshandler/AbstractProgramElementTagsHandler.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -w -r1.3 -r1.4 --- AbstractProgramElementTagsHandler.java 31 May 2002 20:43:55 -0000 1.3 +++ AbstractProgramElementTagsHandler.java 15 Jun 2002 20:25:53 -0000 1.4 @@ -35,7 +35,7 @@ /** * @author Ara Abrahamian ([EMAIL PROTECTED]) * @created Oct 15, 2001 - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ */ public abstract class AbstractProgramElementTagsHandler extends XDocletTagSupport { @@ -218,6 +218,21 @@ } /** + * Used to protect returned arrays from being modified (sorted, reordered for example). + * + * @param objects + * @return + */ + protected static Object[] makeCopyOfArray(Object[] objects) + { + Object[] objects_copy = (Object[]) java.lang.reflect.Array.newInstance(objects.getClass().getComponentType(), objects.length); + + System.arraycopy(objects, 0, objects_copy, 0, objects.length); + + return objects_copy; + } + + /** * Sets the value of match variable. * * @param template The body of the block tag @@ -652,7 +667,8 @@ } if (sort) { - // sort fields + // sort fields, but we should make a copy first, because members is not a new copy, it's shared by all + members = (XMember[]) makeCopyOfArray(members); Arrays.sort(members, memberComparator); }
_______________________________________________________________ Don't miss the 2002 Sprint PCS Application Developer's Conference August 25-28 in Las Vegas - http://devcon.sprintpcs.com/adp/index.cfm?source=osdntextlink _______________________________________________ Xdoclet-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/xdoclet-devel