Feature Request Issue 101: Add a support to be able to Capture static and instance initialization blocks in java classes #123
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation and Context
This change introduces a new entity,
InitializationBlock
, to accurately model and capture Java static and instance initialization blocks using JavaParser. Previously, these blocks were not explicitly represented, leading to incomplete analysis of class initialization logic.How Has This Been Tested?
This change has been tested with a newly added test application and a dedicated test case,
mustBeAbleToResolveInitializationBlocks
, ensuring that initialization blocks are correctly parsed, modeled, and resolved.Breaking Changes
Yes, this is a breaking change. The introduction of
InitializationBlock
modifies the existing data model, thereby generating a new filed in theanalysis.json
requiring updates to any dependent code.Types of changes
Checklist
Additional context
This change extends JavaParser’s capabilities by introducing an explicit representation for initialization blocks, aligning with existing abstractions such as methods and constructors. The
InitializationBlock
entity allows for improved static analysis and reasoning about class initialization behavior.