import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
import com.google.common.collect.UnmodifiableIterator;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
private ImmutableList<QName> getLegacyPath() {
ImmutableList<QName> ret = legacyPath;
if (ret == null) {
- ret = ImmutableList.copyOf(getPathTowardsRoot()).reverse();
+ final List<QName> tmp = new ArrayList<>();
+ for (QName qname : getPathTowardsRoot()) {
+ tmp.add(qname);
+ }
+ ret = ImmutableList.copyOf(Lists.reverse(tmp));
LEGACYPATH_UPDATER.lazySet(this, ret);
}