You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[java] UseDiamondOperator: False positive with Guice TypeLiteral #6239
Guice's TypeLiteral exists to capture type information. It forces you to create a subclass and thereby captures the generic type information for use at runtime. Removal of the type information by using the diamond operator changes the behaviour of the code, so PMD should not generate a warning and a suggestion to remove the type information and use the diamond operator.
I overlooked "com.fasterxml.jackson.core.type.TypeReference".
Another possible hint for detection is the anonymous, empty subclass that you have to create in all variants I found.
changed the title [-][java] UseDiamondOperator codestyle rule highlights Guice TypeLiteral[/-][+][java] UseDiamondOperator: False positive with Guice TypeLiteral[/+]on Jan 16, 2026
Activity
mrclmh commentedon Nov 18, 2025
Other TypeLiterals that may be affected:
oowekyala commentedon Nov 20, 2025
Should we just whitelist the name
TypeLiteral? Or should we add a property of the rule with a list of types to ignore?mrclmh commentedon Nov 21, 2025
I overlooked "com.fasterxml.jackson.core.type.TypeReference".
Another possible hint for detection is the anonymous, empty subclass that you have to create in all variants I found.
mrclmh commentedon Dec 5, 2025
Neither the example code above nor this example trigger the rule for me with 7.18 or 7.19:
mrclmh commentedon Dec 5, 2025
Correction:
I can now reproduce my example, but only with the PMD plugin in IntelliJ.
Not via CLI or in a unit test.
[-][java] UseDiamondOperator codestyle rule highlights Guice TypeLiteral[/-][+][java] UseDiamondOperator: False positive with Guice TypeLiteral[/+]UncleOwen commentedon May 27, 2026
@mrclmh Did you provide a complete auxclasspath when trying the CLI?
mrclmh commentedon May 28, 2026
I can't check but I guess not.
[doc] Update release notes (pmd#6239)
[doc] Update release notes (pmd#6239)
[java] Fix #6239: UseDiamondOperator: Implement heuristic for Super T…