RFR: 8490: Include numeric types without Persister in "Add Filter from Attribute" menu
Huang Xiao
duke at openjdk.org
Mon Jan 12 10:04:27 UTC 2026
### Problem
Attributes with numeric ContentTypes that don't have a Persister (such as primitive types: byte, short, int, long, float, double, char) are
excluded from the "Add Filter from Attribute" context menu in the Event Browser's filter editor.
#### Steps to reproduce:
1. Open a JFR file containing events with primitive numeric fields (e.g., Spring Framework's FlightRecorderStartupEvent with long eventId and
long parentId)
2. In Event Browser, right-click on a column → Select "Show Filter"
3. Right-click on the filter area → Select "Add Filter from Attribute"
4. Expected: All filterable attributes should appear in the menu
5. Actual: Primitive numeric type attributes are missing from the menu
<img width="2420" height="1362" alt="image" src="https://github.com/user-attachments/assets/70bcb795-7a7b-42f0-a83e-e34cb8e50361" />
#### Root Cause
The getPersistableAttributes() method in DataPageToolkit.java (line 1006-1007) filters attributes based on whether their ContentType has a
Persister:
```java
.filter(a -> a.equals(JfrAttributes.EVENT_TYPE) || (a.getContentType() instanceof RangeContentType)
|| (a.getContentType().getPersister() != null))
```
However, primitive numeric types use these ContentTypes which don't have a Persister:
- UnitLookup.RAW_NUMBER - used by all primitive numeric types (byte, short, int, long, float, double, char)
- UnitLookup.RAW_LONG - used by some custom Long attributes
- UnitLookup.COUNT, UnitLookup.INDEX, UnitLookup.IDENTIFIER - legacy numeric types
These types return null from getPersister() (see ContentType.java:99-101), causing them to be filtered out.
### Why this is incorrect:
Even though these types cannot be persisted to strings, they fully support filtering via ItemFilters.equals(). Excluding them from the filter
menu is inconsistent with their actual capabilities.
### Solution
Add a helper method isFilterableNumericType() to identify numeric ContentTypes that support filtering even without a Persister, and include them
in the filter:
private static boolean isFilterableNumericType(IAttribute<?> attribute) {
org.openjdk.jmc.common.unit.ContentType<?> ct = attribute.getContentType();
return ct.equals(UnitLookup.RAW_NUMBER) || ct.equals(UnitLookup.RAW_LONG)|| ct.equals(UnitLookup.COUNT) || ct.equals(UnitLookup.INDEX)
|| ct.equals(UnitLookup.IDENTIFIER);
}
Update the filter condition to include these types:
.filter(a -> a.equals(JfrAttributes.EVENT_TYPE)
|| (a.getContentType() instanceof RangeContentType)
|| (a.getContentType().getPersister() != null)
|| isFilterableNumericType(a))
### Testing
Tested with Spring Framework's FlightRecorderStartupEvent which has primitive long fields:
- Before fix: eventId and parentId attributes were missing from "Add Filter from Attribute" menu
- After fix: All primitive numeric attributes appear correctly in the menu and filters work as expected
<img width="2928" height="1366" alt="453be33a-e65c-4fe2-9a84-a060afa99671" src="https://github.com/user-attachments/assets/5f3759e5-933e-4f7f-9e2c-d5b8372507f9" />
**Attachment**: [app.jfr.zip](https://github.com/user-attachments/files/24521734/app.jfr.zip)
**Related issues**: https://github.com/spring-projects/spring-framework/pull/36077#issuecomment-3722544246
-------------
Commit messages:
- Fix: Include numeric types without Persister in "Add Filter from Attribute" menu(Apply Spotless formatting).
- Fix: Include numeric types without Persister in "Add Filter from Attribute" menu(Update copyright year to 2026).
- Fix: Include numeric types without Persister in "Add Filter from Attribute" menu.
Changes: https://git.openjdk.org/jmc/pull/699/files
Webrev: https://webrevs.openjdk.org/?repo=jmc&pr=699&range=00
Issue: https://bugs.openjdk.org/browse/JMC-8490
Stats: 23 lines in 2 files changed: 19 ins; 0 del; 4 mod
Patch: https://git.openjdk.org/jmc/pull/699.diff
Fetch: git fetch https://git.openjdk.org/jmc.git pull/699/head:pull/699
PR: https://git.openjdk.org/jmc/pull/699
More information about the jmc-dev
mailing list