System.getProperties() 是标准化的 - 每个 Java SE 实现都必须提供它们。 Java 7 没有理由不能为这些标准属性名称引入常量。 它不会阻止新属性的引入。 我认为只是没有人认为值得付出努力(我认为即使是对核心 Java API 的琐碎添加也必须经过流程)。
All the properties documented under System.getProperties() are standardised - every Java SE implementation must provide them. There is no reason that Java 7 could not introduce constants for these standard property names. It would not prevent the introduction of new properties. I think it's just no one has thought it worth the effort (even trivial additions to core Java APIs have to go through processes I think).
我的猜测是 Sun 不想承诺一组预定义的系统属性。 如果它们没有定义为内容,它们可以随时添加系统属性(即使它们只发布 JDK 的增量版本,例如从 1.4.1 到 1.4.2)。
编辑: 任何预定义常量都必须被视为 API 的一部分。 因此,即使改变常量的数量也是 API 的改变。 通过不定义任何常量,Sun 可以定义新的系统属性,而无需引入 API 更改。
My guess is that Sun did not want to commit to a predefined set of system properties. If they are not defined as contants they can add system properties at any time (even if they only release an incremental version of the JDK like from 1.4.1 to 1.4.2).
Edit: Any predefined constants must be considered part of the API. Thus even changing the number of constants is an API change. By not defining any constants Sun is allowed to define new system properties without introducing an API change.
发布评论
评论(5)
System.getProperties() 是标准化的 - 每个 Java SE 实现都必须提供它们。 Java 7 没有理由不能为这些标准属性名称引入常量。 它不会阻止新属性的引入。 我认为只是没有人认为值得付出努力(我认为即使是对核心 Java API 的琐碎添加也必须经过流程)。
All the properties documented under System.getProperties() are standardised - every Java SE implementation must provide them. There is no reason that Java 7 could not introduce constants for these standard property names. It would not prevent the introduction of new properties. I think it's just no one has thought it worth the effort (even trivial additions to core Java APIs have to go through processes I think).
我的猜测是 Sun 不想承诺一组预定义的系统属性。 如果它们没有定义为内容,它们可以随时添加系统属性(即使它们只发布 JDK 的增量版本,例如从 1.4.1 到 1.4.2)。
编辑:
任何预定义常量都必须被视为 API 的一部分。 因此,即使改变常量的数量也是 API 的改变。 通过不定义任何常量,Sun 可以定义新的系统属性,而无需引入 API 更改。
My guess is that Sun did not want to commit to a predefined set of system properties. If they are not defined as contants they can add system properties at any time (even if they only release an incremental version of the JDK like from 1.4.1 to 1.4.2).
Edit:
Any predefined constants must be considered part of the API. Thus even changing the number of constants is an API change. By not defining any constants Sun is allowed to define new system properties without introducing an API change.
出色的 Google Guava 库 最近引入了系统属性常量:请参阅http://docs.guava-libraries.googlecode.com/ git/javadoc/com/google/common/base/StandardSystemProperty.html
The awesome Google Guava library introduced constants for System properties recently: See http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/base/StandardSystemProperty.html
为了完整起见,Apache commons lang具有 SystemUtils 类,提供常用常量和预定义方法。
这种情况已经存在好几年了,您很可能已经在使用 commons lang(2 或 3)。
For completeness, Apache commons lang has the SystemUtils class which provides common constants and predefined methods.
This exists since several years and chances are good you are already using commons lang (2 or 3).
"literal"
和LITERAL
之间有什么区别?两个字符:
"
和"
。当
"literal"
也能正常工作时,不明白为什么还要发明一组复杂的LITERAL
。What's the difference between a
"literal"
and aLITERAL
?Two characters:
"
and"
.Can't see why bother inventing a complex set of
LITERAL
s when"literal"
works just as well.