Skip to content

Detect ArrayStoreException on illegal array writes #923

Closed
@dtim

Description

@dtim

Description

The symbolic engine does not check array store operations and does not detect assignments to array elements that result in ArrayStoreException. This limitation leads to lost executions on code that involve array assignments or calls to a large number of library methods (e.g., System.arraycopy, Collection.toArray(T[]) etc).

To Reproduce

Create a sample class with the following code:

public class ArrayStoreExample {
    public int foo() {
        Integer[] integers = { 1, 2, 3 };
        Object[] objects = integers;
        objects[1] = "";
        return 1;
    }
}

Generate the test suite for this class (or just for foo method).

Expected behavior

A single test case with expected ArrayStoreException should be generated.

Actual behavior

No tests are generated for foo.

Environment

No specific environment: the check is currently missing and does not depend on any UnitTestBot configuration.

Additional context

ArrayStoreException is thrown to indicate that an attempt has been made to store the wrong type of object into an array of objects:

SAT-1088, SAT-1089

Metadata

Metadata

Assignees

Labels

comp-symbolic-engineIssue is related to the symbolic execution enginectg-enhancementNew feature, improvement or change request

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions