解释一下 synchronized() 里面的 Commons Lang 代码?

Explain the Commons Lang code inside of synchronized()?

我正在尝试重写 JakartaCommons-lang 的一段代码,因为我们有一个包需要尽可能少的依赖性

static void unregister(Object value) {
    Set registry = getRegistry();
    if (registry != null) {
        registry.remove(new IDKey(value));
        synchronized(class$org$apache$commons$lang$builder$HashCodeBuilder == null ? (class$org$apache$commons$lang$builder$HashCodeBuilder = class$("org.apache.commons.lang.builder.HashCodeBuilder")) : class$org$apache$commons$lang$builder$HashCodeBuilder) {
            registry = getRegistry();
            if (registry != null && registry.isEmpty()) {
                REGISTRY.set((Object)null);
            }
        }
    }
}

谁能解释一下synchronized()里面的代码?特别是所有 '$'

$ 是有效的标识符字符,因此它只是名称的一部分。

请注意,不鼓励使用 $。 Java 语言规范,第 3.8. Identifiers 节说:

The "Java letters" include uppercase and lowercase ASCII Latin letters A-Z (\u0041-\u005a), and a-z (\u0061-\u007a), and, for historical reasons, the ASCII dollar sign ($, or \u0024) and underscore (_, or \u005f). The dollar sign should be used only in mechanically generated source code or, rarely, to access pre-existing names on legacy systems. The underscore may be used in identifiers formed of two or more characters, but it cannot be used as a one-character identifier due to being a keyword.

如果改用 _ 对您来说可读性会更好吗?

synchronized (class_org_apache_commons_lang_builder_HashCodeBuilder == null ? (class_org_apache_commons_lang_builder_HashCodeBuilder = class_("org.apache.commons.lang.builder.HashCodeBuilder")) : class_org_apache_commons_lang_builder_HashCodeBuilder) {
    ...
}

或更短的名称?

synchronized (builderClass == null ? (builderClass = getClass("org.apache.commons.lang.builder.HashCodeBuilder")) : builderClass) {
    ...
}