{"record":{"id":"ca9ff12885ba234d","repo":"JetBrains/intellij-community","slug":"slice-filter-parse-error-not-null-filter-not-appli","errorCode":"slice.filter.parse.error.not.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":"error","filePath":"java/java-impl/src/com/intellij/slicer/JavaSliceProvider.java","lineNumber":129,"sourceCode":"    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()) {\n        if (filter.startsWith(relType.toString())) {\n          relationType = relType;\n          filter = filter.substring(relType.toString().length()).trim();\n          break;\n        }\n      }\n    }","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/JetBrains/intellij-community/blob/be881553f2a76ac8b4ea53950d93f0de78295c19/java/java-impl/src/com/intellij/slicer/JavaSliceProvider.java#L111-L147","documentation":"Thrown by JavaSliceProvider.parseFilter when the user types a '!null' filter in the Java Slice (dataflow) tool window for a value whose static type is a primitive (int, boolean, etc.). Primitives can never be null in Java, so a NOT_NULL dataflow value filter is meaningless and the parser rejects it with SliceFilterParseException. The message interpolates the presentable text of the primitive type.","triggerScenarios":"Opening the Slice tool window on a variable/parameter of primitive type (e.g. int x) and entering '!null' in the filter field; parseFilter resolves the type via getType(), sees type instanceof PsiPrimitiveType for the '!null' branch, and throws.","commonSituations":"Users exploring data flow for an int/long/boolean value and reflexively applying the same '!null' filter they use for reference types; plugin code calling SliceLanguageSupportProvider.parseFilter or JavaSliceProvider directly with a hardcoded '!null' filter; analyzing auto-unboxed values where the declared type is still primitive.","solutions":["Remove the '!null' filter when slicing a value of primitive type — primitives are never null by language rules.","If you expected a reference type, check that you are slicing the right expression (e.g. the boxed Integer, not the unboxed int).","Use a value filter appropriate to primitives, such as a relational filter (e.g. '>=5') or a plain constant like '5'.","If you are a plugin author calling this API programmatically, guard with 'type instanceof PsiPrimitiveType' before requesting '!null'."],"exampleFix":"// before (Slice filter on int x):\nfilter = \"!null\"\n\n// after:\nfilter = \">=0\"   // relational constant filter valid for int","handlingStrategy":"validation","validationCode":"PsiType type = JavaSliceProvider.getType(expression); // or resolve the sliced value's type yourself\nboolean primitive = type instanceof PsiPrimitiveType;\n// only offer '!null' filter when !primitive","typeGuard":null,"tryCatchPattern":"try { provider.parseFilter(expression, filter); } catch (SliceFilterParseException e) { /* show e.getMessage() in the filter UI */ }","preventionTips":["Disable/omit the '!null' filter option in UI when the sliced value's type is primitive.","Remember 'null' and '!null' filters are only valid for reference types in the Slice tool window."],"tags":["java","intellij","dataflow","slice","user-input"],"backgroundTag":null,"analyzedSha":"be881553f2a76ac8b4ea53950d93f0de78295c19","analyzedAt":"2026-08-14T14:13:06.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}