2021-04-28 16:49:39 +02:00
|
|
|
Using the standard ``++getClassLoader()++`` may not return the _right_ class loader in a JEE context. Instead, go through the ``++currentThread++``.
|
|
|
|
|
2021-04-28 18:08:03 +02:00
|
|
|
|
2021-04-28 16:49:39 +02:00
|
|
|
== Noncompliant Code Example
|
|
|
|
|
|
|
|
----
|
|
|
|
ClassLoader cl = this.getClass().getClassLoader(); // Noncompliant
|
|
|
|
----
|
|
|
|
|
2021-04-28 18:08:03 +02:00
|
|
|
|
2021-04-28 16:49:39 +02:00
|
|
|
== Compliant Solution
|
|
|
|
|
|
|
|
----
|
|
|
|
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
|
|
|
----
|
2021-04-28 18:08:03 +02:00
|
|
|
|