tryToLoadClass() — netty Function Reference
Architecture documentation for the tryToLoadClass() function in NativeLibraryLoader.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD ad07e32d_733a_fab6_069d_362602f3f820["tryToLoadClass()"] e940cc67_3be6_5ff3_e560_4d68972dc13b["NativeLibraryLoader"] ad07e32d_733a_fab6_069d_362602f3f820 -->|defined in| e940cc67_3be6_5ff3_e560_4d68972dc13b bafe3f15_b0bf_647a_3a35_cd885f9d3174["loadLibrary()"] bafe3f15_b0bf_647a_3a35_cd885f9d3174 -->|calls| ad07e32d_733a_fab6_069d_362602f3f820 b457bef5_b901_945e_103b_a802b8d26790["classToByteArray()"] ad07e32d_733a_fab6_069d_362602f3f820 -->|calls| b457bef5_b901_945e_103b_a802b8d26790 style ad07e32d_733a_fab6_069d_362602f3f820 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
common/src/main/java/io/netty/util/internal/NativeLibraryLoader.java lines 447–480
private static Class<?> tryToLoadClass(final ClassLoader loader, final Class<?> helper)
throws ClassNotFoundException {
try {
return Class.forName(helper.getName(), false, loader);
} catch (ClassNotFoundException e1) {
if (loader == null) {
// cannot defineClass inside bootstrap class loader
throw e1;
}
try {
// The helper class is NOT found in target ClassLoader, we have to define the helper class.
final byte[] classBinary = classToByteArray(helper);
return AccessController.doPrivileged(new PrivilegedAction<Class<?>>() {
@Override
public Class<?> run() {
try {
// Define the helper class in the target ClassLoader,
// then we can call the helper to load the native library.
Method defineClass = ClassLoader.class.getDeclaredMethod("defineClass", String.class,
byte[].class, int.class, int.class);
defineClass.setAccessible(true);
return (Class<?>) defineClass.invoke(loader, helper.getName(), classBinary, 0,
classBinary.length);
} catch (Exception e) {
throw new IllegalStateException("Define class failed!", e);
}
}
});
} catch (ClassNotFoundException | RuntimeException | Error e2) {
ThrowableUtil.addSuppressed(e2, e1);
throw e2;
}
}
}
Domain
Subdomains
Calls
Called By
Source
Frequently Asked Questions
What does tryToLoadClass() do?
tryToLoadClass() is a function in the netty codebase, defined in common/src/main/java/io/netty/util/internal/NativeLibraryLoader.java.
Where is tryToLoadClass() defined?
tryToLoadClass() is defined in common/src/main/java/io/netty/util/internal/NativeLibraryLoader.java at line 447.
What does tryToLoadClass() call?
tryToLoadClass() calls 1 function(s): classToByteArray.
What calls tryToLoadClass()?
tryToLoadClass() is called by 1 function(s): loadLibrary.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free