Skip to content

Commit

Permalink
Add support of array of objects in CHECKCAST
Browse files Browse the repository at this point in the history
  • Loading branch information
hextriclosan committed Oct 22, 2024
1 parent 5d833a5 commit 1ce533b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/test_data/TrivialCast.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ public static void main(String[] args) {
Object o2 = new long[] { 1, 2, 3 };
var longArray = (long[]) o2;

Object o3 = new String[10];
var stringArray = (String[]) o3;

int result = 1337;
}
}
Binary file modified tests/test_data/samples/javacore/cast/trivial/TrivialCast.class
Binary file not shown.
1 change: 1 addition & 0 deletions vm/src/execution_engine/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1513,6 +1513,7 @@ impl Engine {
"Error getting class name by index {class_constpool_index}"
))
})?;
let class_of_array = format!("[L{class_of_array};");
let arrayref =
with_heap_write_lock(|heap| heap.create_array(&class_of_array, length));
stack_frame.push(arrayref);
Expand Down

0 comments on commit 1ce533b

Please sign in to comment.