RFR: 8490: Include numeric types without Persister in "Add Filter from Attribute" menu [v2]
youngledo
duke at openjdk.org
Sat Jan 31 14:24:08 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(...
youngledo has updated the pull request incrementally with five additional commits since the last revision:
- Fix: Add proper error handling for empty input in numeric filters
Modified both UnitLookup and CommonCellEditors to properly handle empty or invalid
input when editing numeric type filters, preventing "Unhandled event loop exception" errors.
Changes:
1. UnitLookup.java:
- Added try-catch blocks to parsePersisted() and parseInteractive() methods
- Catch NumberFormatException and throw IllegalArgumentException with clear message
- Applied to RAW_NUMBER, RAW_LONG, COUNT, INDEX, and IDENTIFIER types
2. CommonCellEditors.java:
- Added catch block for IllegalArgumentException and NumberFormatException
- Displays error message in UI when user enters invalid value
- Prevents unhandled exception from crashing the UI
This ensures a user-friendly experience when editing numeric filters, especially
when clearing input fields.
Co-Authored-By: Claude Sonnet 4.5 <noreply at anthropic.com>
- Fix: Ensure numeric type compatibility for filter comparisons
Changed parseNumber() to always return Long (for integers) or Double (for decimals)
instead of Integer/Long/Double hierarchy to ensure type compatibility when
comparing filter values.
Problem:
- Previously parseNumber("100") returned Integer(100)
- If actual data was Long(100L), comparison would fail because
Integer(100).equals(Long(100L)) returns false
- This caused filters to not match any data even when values existed
Solution:
- parseNumber() now returns Long for all integer values
- Returns Double only for decimal values
- This ensures Long.equals(Long) comparisons work correctly
- All RAW_NUMBER, COUNT, INDEX, IDENTIFIER types now use consistent types
Co-Authored-By: Claude Sonnet 4.5 <noreply at anthropic.com>
- Fix: Add null/empty string checks to numeric type parsers
This commit adds validation for empty and blank strings in the parseNumber()
method and RAW_LONG persister methods to prevent NumberFormatException
when users clear input fields in the filter editor.
Changes:
- parseNumber(): Check for null/empty string before parsing
- createRawLong() parsePersisted(): Check for empty string before parsing
- createRawLong() parseInteractive(): Check for empty string before parsing
- Updated javadoc to document the NumberFormatException for empty strings
This fixes the issue where editing a numeric filter value and clearing
the input field would cause an unhandled NumberFormatException with
the message "empty String" instead of a more user-friendly error.
Co-Authored-By: Claude Sonnet 4.5 <noreply at anthropic.com>
- Remove .classpath files from version control
- Add proper LeafContentType persisters to numeric types in UnitLookup
This commit adds IPersister implementation to the following numeric types:
- RAW_NUMBER
- RAW_LONG
- COUNT
- INDEX
- IDENTIFIER
These types previously had no Persister, which would cause errors when users
tried to edit or save filters on them. By implementing the IPersister interface
via LeafContentType, these types can now be properly persisted and restored.
Changes:
- Modified createRawNumber() to return a LeafContentType with full persister support
- Modified createRawLong() to return a LeafContentType with full persister support
- Modified createCount() to return a LeafContentType with full persister support
- Modified createIdentifier() to return a LeafContentType with full persister support
- Modified createIndex() to return a LeafContentType with full persister support
- Added parseNumber() helper method to parse string representations of numbers
The persister implementation supports:
- persistableString(): converts Number values to strings for storage
- parsePersisted(): parses strings back to Number objects
- interactiveFormat(): user-friendly string representation
- parseInteractive(): parses user input strings
This fix resolves the issue where attributes with these numeric content types
would appear in the "Add Filter from Attribute" menu but fail when users
attempted to use or save filters on them.
Co-Authored-By: Claude Sonnet 4.5 <noreply at anthropic.com>
-------------
Changes:
- all: https://git.openjdk.org/jmc/pull/699/files
- new: https://git.openjdk.org/jmc/pull/699/files/a6064ca8..ddba4152
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jmc&pr=699&range=01
- incr: https://webrevs.openjdk.org/?repo=jmc&pr=699&range=00-01
Stats: 3576 lines in 134 files changed: 281 ins; 3290 del; 5 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