JetBrains/intellij-community · warning · SliceFilterParseException
slice.filter.parse.error.null.filter.not.applicable.for.primitive.type
slice.filter.parse.error.null.filter.not.applicable.for.primitive.type
Error message
'null' filter is not applicable to primitive type {0} What it means
Thrown by JavaSliceProvider.parseFilter when a slice/view value filter of 'null' is applied to an expression whose type is a Java primitive (int, boolean, char, ...). Primitives cannot be null, so the null filter is meaningless there and a SliceFilterParseException is raised instead of producing an always-empty slice.
Source
Thrown at java/java-impl/src/com/intellij/slicer/JavaSliceProvider.java:122
actionGroup.add(new CanItBeNullAction(sliceTreeBuilder));
}
}
@Override
public boolean supportValueFilters(@NotNull PsiElement expression) {
PsiType type = getType(expression);
return type != null && !PsiTypes.voidType().equals(type) && !PsiTypes.nullType().equals(type);
}
@Override
public @NotNull SliceValueFilter parseFilter(@NotNull PsiElement expression, @NotNull String filter) throws SliceFilterParseException {
PsiType type = getType(expression);
if (type == null) {
return SliceLanguageSupportProvider.super.parseFilter(expression, filter);
}
if (filter.equals("null")) {
if (type instanceof PsiPrimitiveType) {
throw new SliceFilterParseException(
JavaBundle.message("slice.filter.parse.error.null.filter.not.applicable.for.primitive.type", type.getPresentableText()));
}
return new JavaValueFilter(DfTypes.NULL);
}
if (filter.equals("!null")) {
if (type instanceof PsiPrimitiveType) {
throw new SliceFilterParseException(
JavaBundle.message("slice.filter.parse.error.not.null.filter.not.applicable.for.primitive.type", type.getPresentableText()));
}
return new JavaValueFilter(DfTypes.NOT_NULL_OBJECT);
}
RelationType relationType = RelationType.EQ;
if (PsiTypes.byteType().equals(type) ||
PsiTypes.charType().equals(type) ||
PsiTypes.shortType().equals(type) ||
PsiTypes.intType().equals(type) ||
PsiTypes.longType().equals(type)) {
for (RelationType relType : RelationType.values()) {View on GitHub (pinned to be881553f2)
Solutions
- Remove the 'null' filter for primitive-typed values; use 'true'/'false' for boolean or numeric equality filters where supported.
- If nullability is what you care about, slice a boxed/wrapper expression (Integer) or the point where the value is boxed.
- Check the expression's declared type in the slice tree before applying a 'null' filter.
Example fix
// before int count = compute(); // slice of 'count' + filter 'null' -> throws // after Integer boxed = compute(); // slice of 'boxed' + filter 'null' -> valid
Defensive patterns
Strategy: type-guard
Validate before calling
PsiType type = JavaSliceProvider.getType(expression);
if (type instanceof PsiPrimitiveType && "null".equals(filterText)) {
// reject the filter input early with a user-facing message
} Type guard
static boolean supportsNullFilter(@Nullable PsiType t) {
return t != null && !(t instanceof PsiPrimitiveType) && !PsiTypes.voidType().equals(t);
} Try / catch
try { provider.parseFilter(expression, filter); } catch (SliceFilterParseException e) { /* invalid filter for this value's type; clear the filter box */ } Prevention
- Check the sliced value's type icon/declaration before typing 'null' filters.
- Remember primitives can never be null; use boolean/numeric filters instead where offered.
- Box the value (or slice at the boxing site) when you really need null-based slicing.
When it happens
Trigger: In the Slice tool window, invoking a value filter and typing 'null' while the sliced expression has a primitive type: slicing an int local, a boolean return value, a char field, etc.
Common situations: Users habitually typing 'null' filters after slicing reference expressions and switching to primitive ones; boxing confusion (Integer vs int) when reading the sliced type; typing 'null' into the filter for a method parameter of primitive type.
Related errors
- No JDK specified
- Home directory is not specified for JDK
- {2, choice, 1#flag|1<flags} ''{0}'' not allowed in ''{1}''
- unexpected character ''{0}'' in ''{1}''
- duplicate flag ''{0}'' in ''{1}''
AI-assisted analysis of JetBrains/intellij-community@be881553f2 (2026-08-14).
Data as JSON: /api/errors/0407a94b30661480.
Report an issue: GitHub.