diff --git a/rhino/src/main/java/org/mozilla/javascript/Interpreter.java b/rhino/src/main/java/org/mozilla/javascript/Interpreter.java index d777ae172d..1414de122b 100644 --- a/rhino/src/main/java/org/mozilla/javascript/Interpreter.java +++ b/rhino/src/main/java/org/mozilla/javascript/Interpreter.java @@ -14,6 +14,7 @@ import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Objects; @@ -951,7 +952,10 @@ public void captureStackInfo(RhinoException ex) { --previousCount; } array = new CallFrame[previousCount + 1]; - cx.previousInterpreterInvocations.toArray(array); + + ArrayList tempList = new ArrayList<>(cx.previousInterpreterInvocations); + Collections.reverse(tempList); + tempList.toArray(array); } array[array.length - 1] = (CallFrame) cx.lastInterpreterFrame;