Skip to content

Annotation-tools cannot insert anno to array variable with initializer #22

@lnsun

Description

@lnsun

Annotation-tools cannot insert annotation to array variable with initializer, when the enclosing class is not the first in the file.

Java source:

class MyA {
}

class List{
    List() {
        Object[] t = new Object[10];
    }
}

Minimized JAIF:

package qual:
  annotation @Immutable:

package :
class List:

method <init>()V:
insert-annotation Method.body, Block.statement 0, Variable.type, ArrayType.type: @qual.Immutable
insert-annotation Method.body, Block.statement 0, Variable.initializer, NewArray.type 0: @qual.Immutable
insert-annotation Method.body, Block.statement 0, Variable.type: @qual.Immutable

The output does not contain any annotation after running insert-annotations-to-source, with a warning:

Warning: IndexFileSpecification did not find classfile for: List

Expected output:

class MyA {
}

class List{
    List() {
        @Immutable Object @Immutable [] t = new @Immutable Object[10];
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions