Skip to content

Commit 38abf07

Browse files
cpovirknetdpb
authored andcommitted
Explain when StandardSystemProperty.value() can return a null value, and deprecate JAVA_EXT_DIRS.
value()'s return type has been @nullable since 4232450, but I had forgotten the details about why, despite past CLs to update the test for specific missing keys. I assume that we'll never actually *remove* JAVA_EXT_DIRS. (Just slightly relevant to #2571) RELNOTES=`base`: Deprecated `StandardSystemProperty.JAVA_EXT_DIRS`. We do not plan to remove the API, but in recent versions of Java, that property always has a value of `null`. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=345251412
1 parent 461b7bb commit 38abf07

File tree

2 files changed

+56
-2
lines changed

2 files changed

+56
-2
lines changed

android/guava/src/com/google/common/base/StandardSystemProperty.java

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,15 @@ public enum StandardSystemProperty {
8080
/** Name of JIT compiler to use. */
8181
JAVA_COMPILER("java.compiler"),
8282

83-
/** Path of extension directory or directories. */
83+
/**
84+
* Path of extension directory or directories.
85+
*
86+
* @deprecated This property was <a
87+
* href="https://openjdk.java.net/jeps/220#Removed:-The-extension-mechanism">deprecated</a> in
88+
* Java 8 and removed in Java 9. We do not plan to remove this API from Guava, but if you are
89+
* using it, it is probably not doing what you want.
90+
*/
91+
@Deprecated
8492
JAVA_EXT_DIRS("java.ext.dirs"),
8593

8694
/** Operating system name. */
@@ -124,6 +132,25 @@ public String key() {
124132
/**
125133
* Returns the current value for this system property by delegating to {@link
126134
* System#getProperty(String)}.
135+
*
136+
* <p>The value returned by this method is non-null except in rare circumstances:
137+
*
138+
* <ul>
139+
* <li>{@link #JAVA_EXT_DIRS} was deprecated in Java 8 and removed in Java 9. We have not
140+
* confirmed whether it is available under older versions.
141+
* <li>{@link #JAVA_COMPILER}, while still listed as required as of Java 15, is typically not
142+
* available even under older version.
143+
* <li>Any property may be cleared through APIs like {@link System#clearProperty}.
144+
* <li>Unusual environments like GWT may have their own special handling of system properties.
145+
* </ul>
146+
*
147+
* <p>Note that {@code StandardSystemProperty} does not provide constants for more recently added
148+
* properties, including:
149+
*
150+
* <ul>
151+
* <li>{@code java.vendor.version} (added in Java 11, listed as optional as of Java 13)
152+
* <li>{@code jdk.module.*} (added in Java 9, optional)
153+
* </ul>
127154
*/
128155
@NullableDecl
129156
public String value() {

guava/src/com/google/common/base/StandardSystemProperty.java

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,15 @@ public enum StandardSystemProperty {
8080
/** Name of JIT compiler to use. */
8181
JAVA_COMPILER("java.compiler"),
8282

83-
/** Path of extension directory or directories. */
83+
/**
84+
* Path of extension directory or directories.
85+
*
86+
* @deprecated This property was <a
87+
* href="https://openjdk.java.net/jeps/220#Removed:-The-extension-mechanism">deprecated</a> in
88+
* Java 8 and removed in Java 9. We do not plan to remove this API from Guava, but if you are
89+
* using it, it is probably not doing what you want.
90+
*/
91+
@Deprecated
8492
JAVA_EXT_DIRS("java.ext.dirs"),
8593

8694
/** Operating system name. */
@@ -124,6 +132,25 @@ public String key() {
124132
/**
125133
* Returns the current value for this system property by delegating to {@link
126134
* System#getProperty(String)}.
135+
*
136+
* <p>The value returned by this method is non-null except in rare circumstances:
137+
*
138+
* <ul>
139+
* <li>{@link #JAVA_EXT_DIRS} was deprecated in Java 8 and removed in Java 9. We have not
140+
* confirmed whether it is available under older versions.
141+
* <li>{@link #JAVA_COMPILER}, while still listed as required as of Java 15, is typically not
142+
* available even under older version.
143+
* <li>Any property may be cleared through APIs like {@link System#clearProperty}.
144+
* <li>Unusual environments like GWT may have their own special handling of system properties.
145+
* </ul>
146+
*
147+
* <p>Note that {@code StandardSystemProperty} does not provide constants for more recently added
148+
* properties, including:
149+
*
150+
* <ul>
151+
* <li>{@code java.vendor.version} (added in Java 11, listed as optional as of Java 13)
152+
* <li>{@code jdk.module.*} (added in Java 9, optional)
153+
* </ul>
127154
*/
128155
public @Nullable String value() {
129156
return System.getProperty(key);

0 commit comments

Comments
 (0)