<分区>
因此,作为示例,我有以下 JNI 代码:
/** This literally does nothing. It's purpose is to call the static initializer early to detect if we have issues before loading. */
public static void nothing() {
}
static {
// should be loaded by CLib
if (CLib.hasGNUTLS() == 1) {
globalinit();
}
}
我发现自己确实创建了一个名为“nothing”的函数,以便在必要时尽早调用它,但我也希望在它被较早引用或我们不调用 nothing()
时调用它。 .现在,我可以做一些涉及检查 boolean 值的令人讨厌的逻辑,但是你会进入线程安全,等等。我想你可以,但它并不漂亮。有没有办法显式调用 GNUTLS.<clinit>();
?