rspec/rules/S3011/java/rule.adoc

35 lines
824 B
Plaintext
Raw Normal View History

2020-06-30 12:48:39 +02:00
include::../description.adoc[]
== Noncompliant Code Example
2022-02-04 17:28:24 +01:00
[source,java]
2020-06-30 12:48:39 +02:00
----
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
}
----
== See
* https://wiki.sei.cmu.edu/confluence/x/_jZGBQ[CERT, SEC05-J.] - Do not use reflection to increase accessibility of classes, methods, or fields
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[]