Skip to content

Conversation

@cQQkie-dev
Copy link

Summary

Replace deprecated Ghidra comment APIs in BinExport2Builder.java to fix deprecation warnings.

Changes

  • Use CommentType enum instead of int constants

  • Replace CodeUnit.EOL_COMMENTCommentType.EOL

  • Replace CodeUnitIteratorAddressIterator

  • Replace getCommentCodeUnitIterator()getCommentAddressIterator()

  • Replace CodeUnit.getComment(int)Listing.getComment(CommentType, Address)

Motivation

The old APIs produce deprecation warnings when building against Ghidra 11.4+:

> Task :compileJava
./binexport/java/src/main/java/com/google/security/binexport/BinExport2Builder.java:994: warning: [removal] EOL_COMMENT in CodeUnit has been deprecated and marked for removal
    for (int commentType : ImmutableList.of(CodeUnit.EOL_COMMENT)) {
                                                    ^
./binexport/java/src/main/java/com/google/security/binexport/BinExport2Builder.java:995: warning: [removal] getCommentCodeUnitIterator(int,AddressSetView) in Listing has been deprecated and marked for removal
      for (CodeUnitIterator codeIt = listing.getCommentCodeUnitIterator(commentType, addrSet);
                                            ^
./binexport/java/src/main/java/com/google/security/binexport/BinExport2Builder.java:1004: warning: [removal] getComment(int) in CodeUnit has been deprecated and marked for removal
        var str = code.getComment(commentType);
                      ^
3 warnings

Testing

  • Built extension against Ghidra 11.4.2: No deprecation warnings
  • API changes are direct replacements with equivalent behavior per Ghidra documentation

References

@google-cla
Copy link

google-cla bot commented Oct 29, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Changes:

- int commentType → enum CommentType
- CodeUnit.EOL_COMMENT → CommentType.EOL
- CodeUnitIterator → AddressIterator
- getCommentCodeUnitIterator → getCommentAddressIterator
- CodeUnit.getComment(int) → Listing.getComment(CommentType, Address)

Migrate from int-based comment types to CommentType enum and from
CodeUnit-based iteration to Address-based iteration.
@cQQkie-dev cQQkie-dev force-pushed the fix/ghidra-api-deprecation branch from a8a267b to 0930c99 Compare October 29, 2025 21:18
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.

2 participants