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

devonfw / IDEasy / 23639809731

27 Mar 2026 09:29AM UTC coverage: 70.443% (+0.02%) from 70.424%
23639809731

Pull #1772

github

web-flow
Merge dd3f29966 into 583ec6c46
Pull Request #1772: #1151: fix arm architecture detection

4165 of 6520 branches covered (63.88%)

Branch coverage included in aggregate %.

10795 of 14717 relevant lines covered (73.35%)

3.09 hits per line

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

90.24
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
  /**
36
   * The constructor.
37
   */
38
  private SystemInfoImpl() {
39

40
    this(System.getProperty(PROPERTY_OS_NAME).trim(), System.getProperty(PROPERTY_OS_VERSION).trim(),
8✔
41
        resolveArchitecture());
1✔
42
  }
1✔
43

44
  private static String resolveArchitecture() {
45

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

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

73
    super();
2✔
74
    this.osName = osName;
3✔
75
    this.osVersion = VersionIdentifier.of(osVersion);
4✔
76
    this.architectureName = architectureName;
3✔
77
    this.os = OperatingSystem.ofName(this.osName);
5✔
78
    this.architecture = detectArchitecture(this.architectureName);
5✔
79
  }
1✔
80

81
  private static SystemArchitecture detectArchitecture(String architectureName) {
82

83
    if (architectureName.contains("arm") || architectureName.contains("aarch")) {
8✔
84
      return SystemArchitecture.ARM64;
2✔
85
    } else {
86
      return SystemArchitecture.X64;
2✔
87
    }
88
  }
89

90
  @Override
91
  public OperatingSystem getOs() {
92

93
    return this.os;
3✔
94
  }
95

96
  @Override
97
  public String getOsName() {
98

99
    return this.osName;
3✔
100
  }
101

102
  @Override
103
  public VersionIdentifier getOsVersion() {
104

105
    return this.osVersion;
3✔
106
  }
107

108
  @Override
109
  public String getArchitectureName() {
110

111
    return this.architectureName;
3✔
112
  }
113

114
  @Override
115
  public SystemArchitecture getArchitecture() {
116

117
    return this.architecture;
3✔
118
  }
119

120
  @Override
121
  public String toString() {
122

123
    return this.os + "@" + this.architecture + "(" + this.osName + "[" + this.osVersion + "]@" + this.architectureName
15✔
124
        + ")";
125
  }
126

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

© 2026 Coveralls, Inc