summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDoug Horn <doughorn@google.com>2019-01-22 09:16:08 -0800
committerDoug Horn <doughorn@google.com>2019-01-24 11:26:47 -0800
commit302dc0b3e68bf0b30f8cb6237c19064d53363f0f (patch)
treeee47a127ab7eb15afef5d1b3c325b92c3c4877b0
parentebd71c3d2ed02cab65db168e1adb6d66bfb44f91 (diff)
Remove hardcoded os.name property.
5c9406fb hardcoded "linux" as the value for the os.name property on Android. Because we will now support additional device OSs, this value is no longer static. Reverting back to dynamically querying os.name will regress compile-time initialization for AbstractDatagramSocket. Analysis of this is tracked in b/121268567. Bug: 119271070 Bug: 117987577 Bug: 28174137 Test: Verify os.name keys to the proper underlying OS. Change-Id: I233e87b56b6e5513aab31ef68e1b2afbcd238fc8
-rw-r--r--libart/src/main/java/java/lang/AndroidHardcodedSystemProperties.java4
-rw-r--r--luni/src/test/java/libcore/java/lang/SystemTest.java9
-rw-r--r--ojluni/src/main/java/java/lang/System.java8
3 files changed, 12 insertions, 9 deletions
diff --git a/libart/src/main/java/java/lang/AndroidHardcodedSystemProperties.java b/libart/src/main/java/java/lang/AndroidHardcodedSystemProperties.java
index 87c309674a..931994f0aa 100644
--- a/libart/src/main/java/java/lang/AndroidHardcodedSystemProperties.java
+++ b/libart/src/main/java/java/lang/AndroidHardcodedSystemProperties.java
@@ -96,10 +96,6 @@ public final class AndroidHardcodedSystemProperties {
{ "http.keepAliveDuration", null },
{ "http.maxConnections", null },
- // Hardcode "os.name" to "Linux." Aids compile-time initialization, checked in System.
- // b/28174137
- { "os.name", "Linux" },
-
// Turn off javax.net debugging. This allows compile-time initialization of a range
// of classes. b/28174137
{ "javax.net.debug", null },
diff --git a/luni/src/test/java/libcore/java/lang/SystemTest.java b/luni/src/test/java/libcore/java/lang/SystemTest.java
index 48f45914fe..56b6558449 100644
--- a/luni/src/test/java/libcore/java/lang/SystemTest.java
+++ b/luni/src/test/java/libcore/java/lang/SystemTest.java
@@ -27,8 +27,17 @@ import java.util.Formatter;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicBoolean;
+import android.system.Os;
+
public class SystemTest extends TestCase {
+ public void testOsName() throws Exception {
+ // Ensure os.name always matches the underlying OS.
+ String sysname = Os.uname().sysname;
+ String property = System.getProperty("os.name");
+ assertEquals(sysname, property);
+ }
+
public void testLineSeparator() throws Exception {
try {
// Before Java 7, the small number of classes that wanted the line separator would
diff --git a/ojluni/src/main/java/java/lang/System.java b/ojluni/src/main/java/java/lang/System.java
index c321abb43f..8235bf754b 100644
--- a/ojluni/src/main/java/java/lang/System.java
+++ b/ojluni/src/main/java/java/lang/System.java
@@ -994,11 +994,9 @@ public final class System {
StructUtsname info = Libcore.os.uname();
p.put("os.arch", info.machine);
- if (p.get("os.name") != null && !p.get("os.name").equals(info.sysname)) {
- logE("Wrong compile-time assumption for os.name: " + p.get("os.name") + " vs " +
- info.sysname);
- p.put("os.name", info.sysname);
- }
+ // os.name was previously hardcoded to "Linux", but was reverted due to support
+ // for Fuchsia. b/121268567 shows initialization regressions.
+ p.put("os.name", info.sysname);
p.put("os.version", info.release);
// Android-added: Undocumented properties that exist only on Android.