Support enum value references in constructor arguments#14
Merged
johnsonlee merged 1 commit intomainfrom Jan 30, 2026
Merged
Conversation
When one enum's constructor takes another enum constant as argument (e.g., TaskConfig.URGENT(Priority.HIGH)), the bytecode uses a getstatic field reference (JFieldRef) which was previously not tracked by the enum value extractor. The value was silently lost as null. - Add EnumValueReference data class to represent cross-enum references - Track JFieldRef assignments in extractEnumValues() for enum constant field reads (where field type == declaring class) - Handle JFieldRef in extractValueFromArg() for direct field references in constructor arguments - Add test enums (Priority, TaskConfig, TaskConfigWithId) and test cases https://claude.ai/code/session_01GCAdzvUbK32TnWEKvkV7TG
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Add support for tracking and extracting enum constant references when one enum's constructor takes another enum as an argument. This enables proper analysis of cross-enum dependencies in Java code.
Changes
New
EnumValueReferencedata class inNode.kt: Represents a reference from one enum's constructor argument to another enum constant (e.g.,Priority.HIGH)Enhanced
SootUpAdapter:$stack1 = getstatic Priority.HIGHextractValueFromArg()to handle directJFieldRefarguments in constructor callsTest fixtures: Added three new enum test classes:
Priority: Simple enum with primitive constructor argumentsTaskConfig: Enum with another enum as constructor argumentTaskConfigWithId: Enum with mixed arguments (primitive + enum reference)Comprehensive test suite (
EnumValueReferenceTest):TaskConfigTaskConfigWithIdImplementation Details
The solution detects the bytecode pattern where enum constants are loaded via
getstaticinstructions and passed to enum constructors. TheEnumValueReferenceobject stores both the fully qualified enum class name and the constant name, allowing downstream analysis to resolve cross-enum relationships.