diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/runtime/GetStackTraceNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/runtime/GetStackTraceNode.java index 1fb7a5a77533..1f841aea0052 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/runtime/GetStackTraceNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/runtime/GetStackTraceNode.java @@ -21,7 +21,7 @@ Array execute() { public static Array stackTraceToArray(Throwable exception) { var elements = TruffleStackTrace.getStackTrace(exception); if (elements == null) return new Array(); - var ret = new Array(elements.size()); + var ret = Array.allocate(elements.size()); for (int i = 0; i < elements.size(); i++) { var element = elements.get(i); ret.getItems()[i] = element.getGuestObject(); diff --git a/engine/runtime/src/main/java/org/enso/interpreter/runtime/callable/atom/Atom.java b/engine/runtime/src/main/java/org/enso/interpreter/runtime/callable/atom/Atom.java index 0db21fc0b931..c168435a7f45 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/runtime/callable/atom/Atom.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/runtime/callable/atom/Atom.java @@ -133,7 +133,7 @@ public boolean hasMembers() { public Array getMembers(boolean includeInternal) { Map members = constructor.getDefinitionScope().getMethods().get(constructor.getType()); if (members == null) { - return new Array(0); + return Array.allocate(0); } Object[] mems = members.keySet().toArray(); return new Array(mems); diff --git a/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/Array.java b/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/Array.java index c3b343d41100..f5e8adeaf430 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/Array.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/Array.java @@ -50,8 +50,9 @@ public Array(Object... items) { */ @Builtin.Method( description = "Creates an uninitialized array of a given size.", - autoRegister = false, name = "new") - public static Array empty(long size) { + autoRegister = false, + name = "new") + public static Array allocate(long size) { var arr = new Object[(int) size]; var ctx = EnsoContext.get(null); var nothing = ctx.getBuiltins().nothing(); @@ -123,7 +124,7 @@ public long length() { /** @return an empty array */ @Builtin.Method(description = "Creates an empty Array", autoRegister = false) public static Object empty() { - return new Array(); + return allocate(0); } /** @return an identity array */ diff --git a/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/Vector.java b/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/Vector.java index 8b20f4b8bcf3..8a626a9d7216 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/Vector.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/Vector.java @@ -74,7 +74,7 @@ public final Vector slice(long start, long end, InteropLibrary interop) long slice_end = Math.min(this_length, end); if (slice_start >= slice_end) { - return new Vector(new Array(0)); + return new Vector(Array.allocate(0)); } if ((slice_start == 0) && (slice_end == this_length)) {