Details
-
Improvement
-
Status: Resolved
-
Medium
-
Resolution: Done
-
None
-
None
-
None
Description
https://git.opendaylight.org/gerrit/#/c/68840/ pointed to
yangtools.util.ClassLoaderUtils's{{withClassLoader(...)}}, but this method is hard to use in practice with Java 8 lambdas (perhaps it was written before Java 8) because it has overloaded Supplier as well as Callable signatures, therefore e.g. something like this:
ClassLoaderUtils.withClassLoader(KarafIniWebEnvironment.class.getClassLoader(), () -> { return factory.getInstance(); });
fails with:
The method withClassLoader(ClassLoader, Supplier<SecurityManager>) is ambiguous for the type ClassLoaderUtils
this can be worked around with a cast like this of course, but this is cumbersome:
ClassLoaderUtils.withClassLoader(
KarafIniWebEnvironment.class.getClassLoader(), (Supplier<SecurityManager>) factory::getInstance);