Skip to content

Support analysis of Java 14+ record classes #118

@dsahu75

Description

@dsahu75

Is your feature request related to a problem? Please describe.
codeanalyzer-java fails to generate a parse tree, symbol table, or call graph when analyzing Java code that includes record declarations. This issue affects the analysis of modern Java applications that make use of record types, introduced in Java 14 and finalized in Java 16, for immutable data structures. The missing support leads to incomplete analysis results and may cause downstream issues when performing dependency analysis or refactoring tasks.

Describe the solution you'd like
Support for record declarations should be added to codeanalyzer-java. Specifically, the tool should:

  • Properly parse record declarations into the internal representation.
  • Consider creating a new entity for the record type.
  • Ensure that record fields are properly registered in the symbol table.
  • Integrate record types with existing analyses such as type resolution and call site detection.

Describe alternatives you've considered
None. Record classes were ignored.

Additional context

  • Example code that currently fails to generate a parse tree or call graph:
    public record Person(String name, int age) {
        public String greet() {
            return "Hello, " + name;
        }
    }
  • Expected behavior:
    • The Person record should appear in the symbol table.
    • The greet method should be included in the call graph.
    • Implicitly generated methods should be accounted for.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions