• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

devonfw / IDEasy / 25736422770

12 May 2026 01:06PM UTC coverage: 70.677% (+0.05%) from 70.624%
25736422770

Pull #1932

github

web-flow
Merge 5611c8234 into e6efbbdff
Pull Request #1932: #1844: Fix VSCode installation haning in WSL

4434 of 6924 branches covered (64.04%)

Branch coverage included in aggregate %.

11399 of 15478 relevant lines covered (73.65%)

3.12 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.76
cli/src/main/java/com/devonfw/tools/ide/os/SystemInfoImpl.java
1
package com.devonfw.tools.ide.os;
2

3
import java.io.BufferedReader;
4
import java.io.InputStreamReader;
5

6
import com.devonfw.tools.ide.version.VersionIdentifier;
7

8
/**
9
 * Implementation of {@link SystemInfo}.
10
 */
11
public class SystemInfoImpl implements SystemInfo {
12

13
  /** The default {@link SystemInfo} instance for the operating system running this program. */
14
  public static final SystemInfo INSTANCE = new SystemInfoImpl();
5✔
15

16
  /** Name of {@link System#getProperty(String) system-property} for {@link #getOsName()}: {@value}. */
17
  private static final String PROPERTY_OS_NAME = "os.name";
18

19
  /** Name of {@link System#getProperty(String) system-property} for #getArchitectureName()}: {@value}. */
20
  private static final String PROPERTY_OS_ARCHITECTURE = "os.arch";
21

22
  /** Name of {@link System#getProperty(String) system-property} for {@link #getOsVersion()}: {@value}. */
23
  private static final String PROPERTY_OS_VERSION = "os.version";
24

25
  private final String osName;
26

27
  private final VersionIdentifier osVersion;
28

29
  private final OperatingSystem os;
30

31
  private final String architectureName;
32

33
  private final SystemArchitecture architecture;
34

35
  private final boolean wsl;
36

37
  /**
38
   * The constructor.
39
   */
40
  private SystemInfoImpl() {
41

42
    this(System.getProperty(PROPERTY_OS_NAME).trim(), System.getProperty(PROPERTY_OS_VERSION).trim(),
8✔
43
        resolveArchitecture(), System.getenv("WSL_DISTRO_NAME") != null || System.getenv("WSL_INTEROP") != null);
8!
44
  }
1✔
45

46
  private static String resolveArchitecture() {
47

48
    String arch = System.getProperty(PROPERTY_OS_ARCHITECTURE).trim();
4✔
49
    String osName = System.getProperty(PROPERTY_OS_NAME).trim().toLowerCase(java.util.Locale.ROOT);
6✔
50
    if (!osName.startsWith("windows")) {
4!
51
      try {
52
        Process process = new ProcessBuilder("uname", "-m").start();
15✔
53
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
9✔
54
          String line = reader.readLine();
3✔
55
          if (line != null && !line.isBlank()) {
5!
56
            arch = line.trim();
3✔
57
          }
58
        }
59
      } catch (Exception e) {
×
60
        // fallback to system property
61
      }
1✔
62
    }
63
    return arch;
2✔
64
  }
65

66
  /**
67
   * The constructor.
68
   *
69
   * @param osName the {@link #getOsName() OS name}
70
   * @param osVersion the {@link #getOsVersion() OS version}.
71
   * @param architectureName the {@link #getArchitectureName() architecture name}.
72
   */
73
  public SystemInfoImpl(String osName, String osVersion, String architectureName) {
74

75
    this(osName, osVersion, architectureName, false);
6✔
76
  }
1✔
77

78
  /**
79
   * The constructor.
80
   *
81
   * @param osName the {@link #getOsName() OS name}
82
   * @param osVersion the {@link #getOsVersion() OS version}.
83
   * @param architectureName the {@link #getArchitectureName() architecture name}.
84
   * @param wsl {@code true} if running inside WSL (Windows Subsystem for Linux).
85
   */
86
  public SystemInfoImpl(String osName, String osVersion, String architectureName, boolean wsl) {
87

88
    super();
2✔
89
    this.osName = osName;
3✔
90
    this.osVersion = VersionIdentifier.of(osVersion);
4✔
91
    this.architectureName = architectureName;
3✔
92
    this.os = OperatingSystem.ofName(this.osName);
5✔
93
    this.architecture = detectArchitecture(this.architectureName);
5✔
94
    this.wsl = wsl;
3✔
95
  }
1✔
96

97
  private static SystemArchitecture detectArchitecture(String architectureName) {
98

99
    if (architectureName.contains("arm") || architectureName.contains("aarch")) {
8✔
100
      return SystemArchitecture.ARM64;
2✔
101
    } else {
102
      return SystemArchitecture.X64;
2✔
103
    }
104
  }
105

106
  @Override
107
  public OperatingSystem getOs() {
108

109
    return this.os;
3✔
110
  }
111

112
  @Override
113
  public String getOsName() {
114

115
    return this.osName;
3✔
116
  }
117

118
  @Override
119
  public VersionIdentifier getOsVersion() {
120

121
    return this.osVersion;
3✔
122
  }
123

124
  @Override
125
  public String getArchitectureName() {
126

127
    return this.architectureName;
3✔
128
  }
129

130
  @Override
131
  public SystemArchitecture getArchitecture() {
132

133
    return this.architecture;
3✔
134
  }
135

136
  @Override
137
  public boolean isWsl() {
138

139
    return this.wsl;
3✔
140
  }
141

142
  @Override
143
  public String toString() {
144

145
    return this.os + "@" + this.architecture + "(" + this.osName + "[" + this.osVersion + "]@" + this.architectureName
15✔
146
        + ")";
147
  }
148

149
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc