Thursday, April 28, 2022

[FIXED] how to suppress this warning on the `var` keyword?

Issue

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



Answered By - rzwitserloot
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.