Skip to content

Feature Request Issue 101: Add a support to be able to Capture static and instance initialization blocks in java classes #123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

rahlk
Copy link
Collaborator

@rahlk rahlk commented Feb 18, 2025

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 the analysis.json requiring updates to any dependent code.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the Codellm-Devkit Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

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.

Signed-off-by: Rahul Krishna <i.m.ralk@gmail.com>
…llable.

Signed-off-by: Rahul Krishna <i.m.ralk@gmail.com>
…llable.

Signed-off-by: Rahul Krishna <i.m.ralk@gmail.com>
@rahlk rahlk added enhancement New feature or request kind/feature Feature breaking Breaking Change labels Feb 18, 2025
@rahlk rahlk requested a review from sinha108 February 18, 2025 23:08
@rahlk rahlk self-assigned this Feb 18, 2025
Signed-off-by: Rahul Krishna <i.m.ralk@gmail.com>
@rangeetpan rangeetpan self-requested a review February 19, 2025 21:35
@rahlk rahlk merged commit 86235d0 into main Feb 19, 2025
@rahlk rahlk deleted the 101-add-a-support-to-be-able-to-caputer-static-and-instance-initialization-blocks-in-java-classes branch February 19, 2025 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Breaking Change enhancement New feature or request kind/feature Feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a support to be able to caputer static and instance initialization blocks in Java classes
2 participants