简体   繁体   English

如何在 `var` 关键字上抑制此警告?

[英]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警告:(ROW,COLUMN)java:从版本 10 开始,'var' 是受限制的局部变量类型,不能用于类型声明或作为数组的元素类型

Am using Lombok 1.18.12 from Java 11 targeting version 7, that's how come those var are in there.我正在使用来自 Java 11 的 Lombok 1.18.12 ,针对版本 7,这就是那些var在那里的原因。

How to suppress?怎么压制? What to throw in @SuppressWarnings(...) ?@SuppressWarnings(...)中抛出什么?

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

Just don't use lombok's var, and use the one built into java.只是不要使用 lombok 的 var,而使用 java 中内置的那个。 That, or, downgrade to java8.那,或者,降级到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). Lombok 的 var 与 java10+ 的 'var' 做同样的事情,除了 lombok 允许复合赋值并且不允许不可表示类型(java10 var 允许不可表示,但不允许复合)。 These are two exotic concepts you're unlikely to need:)这是您不太可能需要的两个奇异概念:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何抑制未经检查的课堂警告 - How to suppress unchecked class warning 如何抑制此警告? - How do I suppress this warning? 如何在java中抑制空指针访问警告? - How to suppress null pointer access warning in java? 如何使用泛型而不是声明来抑制未检查的类型转换警告? - How to suppress unchecked typecast warning with generics not at declaration? 如何取消对注释参数的弃用警告 - How to suppress deprecation warning on annotation argument 如何抑制 Kotlin 中的检查式警告 - How to suppress check-style warning in Kotlin 如何在不从 Eclipse 中得到警告的情况下抑制容易出错的警告? - How to suppress errorprone warnings without getting a warning from eclipse? 如何使用Gradle抑制“警告:忽略匿名内部类的InnerClasses属性”? - How to suppress “warning: Ignoring InnerClasses attribute for an anonymous inner class” with Gradle? 如何抑制枚举常量/值上缺少javadoc checkstyle警告? - How to suppress missing javadoc checkstyle warning on enum constants/values? 如何正确抑制“自动模块需要传递指令”警告? - How to suppress the “requires transitive directive for an automatic module” warning properly?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM