Search code examples
javaintellij-ideawarningsjava-7lombok

how to suppress this warning on the `var` keyword?


The message is:

Warning:(ROW, COLUMN) java: as of release 10, 'var' is a restricted local variable type and cannot be used for type declarations or as the element type of an array

Am using Lombok 1.18.12 from Java 11 targeting version 7, that's how come those var are in there.

How to suppress? What to throw in @SuppressWarnings(...)?

        [...]
        var excepted = false;
        [...]

Solution

  • Just don't use lombok's var, and use the one built into java. That, or, downgrade to java8.

    Lombok's var does effectively the same thing as java10+'s 'var', except lombok allows compound assignments and does not allow non-denotable types (java10 var allows non-denotables, but doesn't allow compound). These are two exotic concepts you're unlikely to need :)