rspec/rules/S3011/java/rule.adoc
2020-06-30 17:16:12 +02:00

17 lines
423 B
Plaintext

include::../description.adoc[]
== Noncompliant Code Example
----
public void makeItPublic(String methodName) throws NoSuchMethodException {
this.getClass().getMethod(methodName).setAccessible(true); // Noncompliant
}
public void setItAnyway(String fieldName, int value) {
this.getClass().getDeclaredField(fieldName).setInt(this, value); // Noncompliant; bypasses controls in setter
}
----
include::../see.adoc[]