Skip to content
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

feat: canonicalize based on ClassModel #4

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

algomaster99
Copy link
Member

Here we attempt to canonicalize bytecode using java.lang.classfile.ClassModel. Approach:

  1. First establish the correct order of constant pool - we let the depth first search visitor provided decide that.
  2. Then we changes indices of all the constant pool entries and then classfile sections where the entry is referred.

@algomaster99
Copy link
Member Author

There are some constant pool entries that are not in the AST. For example, SourceFile attribute's name is also in the constant pool. To infer its index, we will have to refer to the exact position in the byte array which java.lang.classfile API should provide.

@algomaster99 algomaster99 marked this pull request as draft September 10, 2024 20:14
@algomaster99
Copy link
Member Author

payloadStart is the index where u1 info[attribute_length]; starts. If we go 6 indices before payloadStart, we can get exact index of SourceFile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant