Skip to content

Java: More details about nested arrays #6552

Closed

Description

@artem-smotrakov

Given a multi-dimensional array, the extractor doesn't seem to provide enough information about nested sub-arrays.

For example:

public class Test {

    void test() {
        byte[][] array = new byte[][] {
            new byte[] { 1, 2 },
            new byte[] { 3, 4 ,5 }
        };
    }
}

The following query shows only IntegerLiteral and TypeAccess for the nested arrays:

import java

from ArrayCreationExpr array
select array.getInit().getAnInit().getAChildExpr().getAPrimaryQlClass()

Instead, ArrayCreationExpr should be used to represent the nested arrays, shouldn't it?

This issue was found here.

Activity

  1. tausbn commented on Aug 26, 2021

    @tausbn
    Contributor

    Thank you for reporting this! I will forward it to the Java team.

  2. smowton commented on Sep 10, 2021

    @smowton
    Contributor

    Fixed in the next release: for the best backward compatibility, the representation will be somewhat irregular:

    Syntax Nested context (e.g. { { 1, 2 } }) Non-nested context (e.g. byte[] bs = new byte[10])
    new byte[10] ArrayCreationExpr ArrayCreationExpr
    new byte[] { 1 } ArrayInit ArrayCreationExpr (with a getInit)
    { 1, 2, 3 } ArrayInit ArrayCreationExpr (with a getInit)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    JavaquestionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions