Guard against NoClassDefFoundError when trying to load Unsafe.

Motivation:

OSGI and other enviroments may not allow to even load Unsafe which will lead to an NoClassDefFoundError when trying to access it. We should guard against this.

Modifications:

Catch NoClassDefFoundError when trying to load Unsafe.

Result:

Be able to use netty with a strict OSGI config.
This commit is contained in:
Norman Maurer 2017-11-22 21:05:34 +01:00
parent f9cadc0a8c
commit 65cacc9b15

View File

@ -96,6 +96,10 @@ final class PlatformDependent0 {
return e;
} catch (IllegalAccessException e) {
return e;
} catch (NoClassDefFoundError e) {
// Also catch NoClassDefFoundError in case someone uses for example OSGI and it made
// Unsafe unloadable.
return e;
}
}
});