Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/main/java/com/eclipsesource/v8/utils/V8ObjectUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,16 @@ private static V8Array toV8Array(final V8 v8, final List<? extends Object> list,
return result;
}

private static List<Object> toList(Object array){
int length=Array.getLength(array);
List<Object> list = new ArrayList<>(length);

for(int i=0;i<length;i++){
list.add(Array.get(array, i));
}
return list;
}

@SuppressWarnings("unchecked")
private static Object getV8Result(final V8 v8, final Object value, final Map<Object, V8Value> cache) {
if (cache.containsKey(value)) {
Expand Down Expand Up @@ -599,6 +609,9 @@ private static void pushValue(final V8 v8, final V8Array result, final Object va
} else if (value instanceof List) {
V8Array array = toV8Array(v8, (List) value, cache);
result.push(array);
} else if (value.getClass().isArray()){
V8Array array = toV8Array(v8, toList(value), cache);
result.push(array);
} else {
throw new IllegalStateException("Unsupported Object of type: " + value.getClass());
}
Expand Down Expand Up @@ -634,6 +647,9 @@ private static void setValue(final V8 v8, final V8Object result, final String ke
} else if (value instanceof List) {
V8Array array = toV8Array(v8, (List) value, cache);
result.add(key, array);
} else if (value.getClass().isArray()){
V8Array array = toV8Array(v8, toList(value), cache);
result.add(key, array);
} else {
throw new IllegalStateException("Unsupported Object of type: " + value.getClass());
}
Expand Down