{"record":{"id":"0407a94b30661480","repo":"JetBrains/intellij-community","slug":"slice-filter-parse-error-null-filter-not-applicabl","errorCode":"slice.filter.parse.error.null.filter.not.applicable.for.primitive.type","errorMessage":"'null' filter is not applicable to primitive type {0}","messagePattern":"'null' filter is not applicable to primitive type (.+?)","errorType":"validation","errorClass":"SliceFilterParseException","httpStatus":null,"severity":"warning","filePath":"java/java-impl/src/com/intellij/slicer/JavaSliceProvider.java","lineNumber":122,"sourceCode":"      actionGroup.add(new CanItBeNullAction(sliceTreeBuilder));\n    }\n  }\n\n  @Override\n  public boolean supportValueFilters(@NotNull PsiElement expression) {\n    PsiType type = getType(expression);\n    return type != null && !PsiTypes.voidType().equals(type) && !PsiTypes.nullType().equals(type);\n  }\n\n  @Override\n  public @NotNull SliceValueFilter parseFilter(@NotNull PsiElement expression, @NotNull String filter) throws SliceFilterParseException {\n    PsiType type = getType(expression);\n    if (type == null) {\n      return SliceLanguageSupportProvider.super.parseFilter(expression, filter);\n    }\n    if (filter.equals(\"null\")) {\n      if (type instanceof PsiPrimitiveType) {\n        throw new SliceFilterParseException(\n          JavaBundle.message(\"slice.filter.parse.error.null.filter.not.applicable.for.primitive.type\", type.getPresentableText()));\n      }\n      return new JavaValueFilter(DfTypes.NULL);\n    }\n    if (filter.equals(\"!null\")) {\n      if (type instanceof PsiPrimitiveType) {\n        throw new SliceFilterParseException(\n          JavaBundle.message(\"slice.filter.parse.error.not.null.filter.not.applicable.for.primitive.type\", type.getPresentableText()));\n      }\n      return new JavaValueFilter(DfTypes.NOT_NULL_OBJECT);\n    }\n    RelationType relationType = RelationType.EQ;\n    if (PsiTypes.byteType().equals(type) ||\n        PsiTypes.charType().equals(type) ||\n        PsiTypes.shortType().equals(type) ||\n        PsiTypes.intType().equals(type) ||\n        PsiTypes.longType().equals(type)) {\n      for (RelationType relType : RelationType.values()) {","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/JetBrains/intellij-community/blob/be881553f2a76ac8b4ea53950d93f0de78295c19/java/java-impl/src/com/intellij/slicer/JavaSliceProvider.java#L104-L140","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nint count = compute();\n// slice of 'count' + filter 'null' -> throws\n// after\nInteger boxed = compute();\n// slice of 'boxed' + filter 'null' -> valid","handlingStrategy":"type-guard","validationCode":"PsiType type = JavaSliceProvider.getType(expression);\nif (type instanceof PsiPrimitiveType && \"null\".equals(filterText)) {\n  // reject the filter input early with a user-facing message\n}","typeGuard":"static boolean supportsNullFilter(@Nullable PsiType t) {\n  return t != null && !(t instanceof PsiPrimitiveType) && !PsiTypes.voidType().equals(t);\n}","tryCatchPattern":"try { provider.parseFilter(expression, filter); } catch (SliceFilterParseException e) { /* invalid filter for this value's type; clear the filter box */ }","preventionTips":["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."],"tags":["java","slicer","value-filter","primitive-types","null-analysis"],"backgroundTag":null,"analyzedSha":"be881553f2a76ac8b4ea53950d93f0de78295c19","analyzedAt":"2026-08-14T14:13:06.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}