• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

uber / NullAway / #950 / 1
93%
master: 93%

Build:
DEFAULT BRANCH: master
Ran 12 Sep 2022 11:21PM UTC
Files 73
Run time 3s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

12 Sep 2022 11:21PM UTC coverage: 92.577% (+0.05%) from 92.531%
#950.1

push

github-actions

web-flow
Fix crash when querying null-markedness of $primitive.class expressions. (#654)

NullAway 0.10.0 introduces a crash when performing dataflow and encountering expressions of the form `${primitive}.class` (e.g. `int.class`, `boolean.class`, `void.class`).

These expressions look to dataflow and AST analysis like standard field accesses, but calling `ASTHelpers.enclosingClass(symbol)` on the symbol representing e.g. `boolean.class`, returns `null`. 

This is despite `symbol.owner` for these expressions being a non-null `ClassSymbol`. What happens there is that the class symbol for int/boolean/etc is one for which `encClass()` returns `null` rather than itself, which is the behavior for "real" classes. 

Before 0.10.0, we were  skipping this kind of expressions via `NullabilityUtil.mayBeNullFieldFromType(...)`, but after #652, we have a new path through handlers that might attempt to query them for null-markedness.

We _could_ skip these fields by partitioning `NullabilityUtil.mayBeNullFieldFromType(...)` into two different methods performing two separate checks:

- One checking for `symbol.getSimpleName().toString().equals("class") || symbol.isEnum()` and aborting `visitFieldAccess(...)` early, without worrying about `handler.onDataflowVisitFieldAccess(...)`
- One checking for `!codeAnnotationInfo.isSymbolUnannotated(symbol, config) && Nullness.hasNullableAnnotation(symbol, config)` and combined with the results from any handler.

That said, a potentially more robust approach (and the one this PR takes), requiring less careful maintenance of invariants, is to add handling of `${primitive}.class` directly into  `CodeAnnotationInfo::isSymbolUnannotated`. This should prevent a similar bug from being re-introduced through a different checking path, which is important given the difficultly of debugging dataflow issues.

This PR also contains a small unrelated test case for static import that appeared to be related during triage of this bug, but... (continued)

4926 of 5321 relevant lines covered (92.58%)

0.93 hits per line

Source Files on job #950.1
  • Tree
  • List 0
  • Changed 2
  • Source Changed 1
  • Coverage Changed 2
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Build 950
  • de1a12bf on github
  • Prev Job for on master (##945.1)
  • Next Job for on master (##952.1)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc