55 lines
1.0 KiB
Plaintext
55 lines
1.0 KiB
Plaintext
== Why is this an issue?
|
|
|
|
Through Java's evolution keywords have been added. While code that uses those words as identifiers may be compilable under older versions of Java, it will not be under modern versions.
|
|
|
|
Following keywords are marked as invalid identifiers
|
|
|
|
[frame=all]
|
|
[cols="^1,^1"]
|
|
|===
|
|
|Keyword|Added
|
|
|
|
|``++_++``|9
|
|
|``++enum++``|5.0
|
|
|===
|
|
|
|
|
|
``++assert++`` and ``++strictfp++`` are another example of valid identifiers which became keywords in later versions, but are not supported by this rule.
|
|
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,java]
|
|
----
|
|
public void doSomething() {
|
|
int enum = 42; // Noncompliant
|
|
String _ = ""; // Noncompliant
|
|
}
|
|
----
|
|
|
|
|
|
=== Compliant solution
|
|
|
|
[source,java]
|
|
----
|
|
public void doSomething() {
|
|
int magic = 42;
|
|
}
|
|
----
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::message.adoc[]
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
include::comments-and-links.adoc[]
|
|
endif::env-github,rspecator-view[]
|