An UnsatisfiedLinkError should be thrown - not sure if that will
convert to something else like an ExceptionInitializationError because
its in an static member, but it might.
The best way would be to not have the INSTANCE variable there, and to
abstract the accesses into a wrapper class - use the real functions if
the library loads, else do nothing, or some form of fallback.
2009/1/22 Steve Sobol (JDN) <java...@stevesobol.com>:
Specifically,
interface DWMLibrary extends Library {
DWMLibrary INSTANCE = (DWMLibrary)
Native.loadLibrary("dwmapi",DWMLibrary.class);
NativeLong DwmEnableComposition(int Action);
NativeLong DwmIsCompositionEnabled(IntByReference pfEnabled);
}
These two functions enable or disable Vista's Desktop Window Manager's
Window Composition, effectively turning the Aero visual theme on or off, and
check whether Window Composition is enabled.
This works on Windows Vista, and should also work on Windows Server 2008. It
will fail on any earlier Windows OS, as dwmapi.dll is missing from earlier
versions of Windows. It will also (obviously) fail on non-Windows operating
systems.
My question: If dwmapi.dll doesn't exist (or can't be loaded for some other
reason), will DWMLibrary.INSTANCE return null? That would be very
convenient.
Microsoft's new marketing slogan for Windows is "Life Without Walls."
But if you have no walls, how can you have windows?