🛠️ Fix: Handle Deprecated Constructors & Improve Logging in DeprecatedHandler #2
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.
This PR fixes an issue in DeprecatedHandler where deprecated constructors were not being processed. Additionally, it enhances the functionality by improving logging, tracking method usage, and adding compile-time warnings.
🔧 Fixes & Enhancements:
✅ Handles Deprecated Constructors: Previously, only deprecated methods were tracked. Now, constructors are also processed.
✅ Adds SLF4J Logging: A Logger is injected to warn whenever a deprecated method/constructor is invoked.
✅ Includes Stack Trace Logging: Helps trace where deprecated methods/constructors are being used.
✅ Generates Compiler Warnings: Shows a @deprecated warning at compile time when such methods/constructors are processed.
✅ Ensures Proper AST Modification: Uses TreeTranslator to inject logging and tracking statements at method/constructor entry.
🔍 Changes in Code:
Updated process() to detect both methods and constructors.
Added logger initialization and a logger.warn() statement to print a warning when a deprecated method is called.
Injected DeprecatedMethodInvocationCounter.onDeprecatedMethodCalled() to track method usage.
Added apContext.getMessager().printMessage() to generate compile-time warnings.
🚀 Next Steps:
Review the changes and verify logging behavior.
Run unit tests to ensure both methods and constructors are handled correctly.
Merge the PR to enhance deprecated method tracking in Apache Dubbo.