int[] joinWeights = sj.getJoiner().getWeights();
    private static boolean raiseDupDupSJChildren(SIRSplitJoin sj)    {	boolean didRaising = false;        // Check that sj's splitter is duplicate:        if (sj.getSplitter().getType() != SIRSplitType.DUPLICATE)            return false;        // For sanity, confirm that we have a round-robin joiner.        if (sj.getJoiner().getType() != SIRJoinType.ROUND_ROBIN &&            sj.getJoiner().getType() != SIRJoinType.WEIGHTED_RR)            return false;        int[] joinWeights = sj.getJoiner().getWeights();                // Whee.  Let's look at sj's children:        for (int index = 0; index < sj.size(); index++)        {            SIRStream child = sj.get(index);            // To continue, child must be a splitjoin with a duplicate            // splitter.            if (!(child instanceof SIRSplitJoin))                continue;            SIRSplitJoin sjChild = (SIRSplitJoin)child;            if (sjChild.getSplitter().getType() != SIRSplitType.DUPLICATE)                continue;            // The useful output rate, for our purposes, is the            // sum of the output weights of the joiner.            int outCount = sjChild.getJoiner().getSumOfWeights();            if (outCount != joinWeights[index])                continue;            // Okay, we can raise the child.  This involves setting a new            // (weighted round robin) joiner, and moving the child's children            // into sj.  Do the joiner first:	    didRaising = true;            JExpression[] oldWeights = sj.getJoiner().getInternalWeights();            JExpression[] newWeights =                new JExpression[sj.size() + sjChild.size() - 1];            JExpression[] childWeights =                sjChild.getJoiner().getInternalWeights();            int i;            for (i = 0; i < index; i++)                newWeights[i] = oldWeights[i];            for (int j = 0; j < childWeights.length; i++, j++)                newWeights[i] = childWeights[j];            for (int j = 1; j < oldWeights.length - index; i++, j++)                newWeights[i] = oldWeights[index + j];            SIRJoiner newJoiner =                SIRJoiner.create(sj, SIRJoinType.WEIGHTED_RR, newWeights);            SIRSplitter newSplitter =                SIRSplitter.create(sj, SIRSplitType.DUPLICATE,                                   newWeights.length);            // ...and raise the children.            while (sjChild.size() > 0)            {                SIRStream child2 = sjChild.get(0);                List params = sjChild.getParams(0);                sjChild.remove(0);                sj.add(index, child2, params);                index++;            }            sj.remove(index);            index--;            sj.setSplitter(newSplitter);            sj.setJoiner(newJoiner);        }        return didRaising;    }