Skip to content

Drop guava dependency from code generator#9

Merged
merlimat merged 3 commits into
streamnative:masterfrom
merlimat:drop-guava-dependency
May 12, 2026
Merged

Drop guava dependency from code generator#9
merlimat merged 3 commits into
streamnative:masterfrom
merlimat:drop-guava-dependency

Conversation

@merlimat
Copy link
Copy Markdown
Collaborator

Summary

Removes com.google.guava:guava from lightproto-code-generator. Guava was used for three small utilities, each replaced inline:

  • Joiner.on('/').join(arr)String.join("/", arr) (JDK)
  • Maps.newHashMap()new HashMap<>() (JDK)
  • CaseFormat.LOWER_UNDERSCORE.to(LOWER_CAMEL, s) and the inverse → two small helpers in Util (lowerUnderscoreToLowerCamel, lowerCamelToLowerUnderscore)

The case-format helpers were verified against guava's CaseFormat for every input shape that actually appears in the codebase (proto field names, gRPC method names, short prefixes like get / set, and the embedded-camel _msgSize input where guava's normalization lowercases internal uppercase letters). Generated source is byte-identical to before.

After this change, the code-generator runtime dep tree is just protobuf + slf4j + roaster — guava and its 6 transitive jars (failureaccess, listenablefuture, jsr305, checker-qual, error_prone_annotations, j2objc-annotations) are gone.

Note: stacked on top of #8. Until that one merges, this PR's diff will show both commits. The latest commit (Drop guava dependency) is what this PR is about; the Drop jibx-tools dependency… commit is just the parent.

Test plan

  • mvn install builds clean across all modules
  • All 262 existing tests in lightproto-tests pass unchanged (these exercise generated code that depends on Util.camelCase / Util.upperCase for accessor naming)
  • UtilTest extended with 25 new cases covering both case-format helpers
  • mvn -pl code-generator dependency:tree no longer mentions guava, com.google.common, or any of guava's annotation deps

merlimat added 3 commits May 12, 2026 13:27
jibx-tools was only used in Util.plural / Util.singular to derive
accessor names for `repeated` fields (addItem / getItemsCount / etc.).
It transitively pulled in log4j 1.2.17 (multiple CVEs) and ~10 ancient
Eclipse JDT jars.

The relevant pluralize/depluralize logic from JiBX NameUtilities is
~40 lines of rule-based suffix manipulation with no irregular-plural
handling, so vendor it directly into Util (BSD 3-clause, attribution
in comment). Generated output is byte-identical; all 262 existing
tests pass unchanged.

Add UtilTest covering every branch of plural / singular, including
the case-sensitivity quirk in jibx where "ANY" pluralizes to "ANYs".
guava was used in the code generator only for three small utilities:

- Joiner.on('/').join(arr) -> String.join("/", arr)
- Maps.newHashMap() -> new HashMap<>()
- CaseFormat.LOWER_UNDERSCORE.to(LOWER_CAMEL, s) and the inverse,
  used in Util.camelCase / Util.upperCase

The CaseFormat conversions were replaced by lowerUnderscoreToLowerCamel
and lowerCamelToLowerUnderscore helpers in Util. Their behavior was
verified against guava's CaseFormat across every input shape that
appears in the codebase (proto field names, gRPC method names, short
prefixes like "get"/"set", and the embedded-camel "_msgSize" input
where guava's normalization lowercases internal uppercase letters).
Generated source is byte-identical; all 262 integration tests pass.

Removes guava and its 6 transitive jars (failureaccess,
listenablefuture, jsr305, checker-qual, error_prone_annotations,
j2objc-annotations) from the code-generator runtime tree.
# Conflicts:
#	code-generator/pom.xml
#	code-generator/src/main/java/io/streamnative/lightproto/generator/Util.java
#	code-generator/src/test/java/io/streamnative/lightproto/generator/UtilTest.java
@merlimat merlimat merged commit c5fe606 into streamnative:master May 12, 2026
1 check passed
@merlimat merlimat deleted the drop-guava-dependency branch May 12, 2026 20:42
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