1

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;
        [...]
1737973
  • 159
  • 18
  • 42

1 Answers1

1

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 :)

rzwitserloot
  • 85,357
  • 5
  • 51
  • 72
  • won't upvote since the choices available are kinda sad, but definitely acceptable answer :shrug: – 1737973 Jun 08 '20 at 16:28
  • Hey, if we could feasible suppress that warning, we would consider it, but if the thing it is warning you about is followed through, then lombok.var would stop working, so, the warning's content is valid. We can hold a debate as to whether it is wise for java to break backwards compatibility like this, but normally 'var' would never be the name of a type, as it doesn't start with a capital. We explicitly introduced 'var' so codebase pre-java10 could start using 'var'. We've had (and continue to support) val for a lot longer than that. Maybe that option is better? 'val' = 'final var'. – rzwitserloot Jun 08 '20 at 21:48
  • theres not that big a deal I mean it's not hard to delombokize Lombok `var` if some project needs go down to zero warnings. Good job either way! – 1737973 Jun 09 '20 at 07:02