Repository: apple/pkl
File: pkl-core/src/main/java/org/pkl/core/Platform.java (Java)

Code before:
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.pkl.core;

import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.TruffleOptions;
import org.graalvm.home.Version;

/**
 * Information about the Pkl release that the current program runs on. This class is the Java
 * equivalent of standard library module {@code pkl.platform}.
 */
public record Platform(
    org.pkl.core.Platform.Language language,
    org.pkl.core.Platform.Runtime runtime,
    org.pkl.core.Platform.VirtualMachine virtualMachine,
    org.pkl.core.Platform.OperatingSystem operatingSystem,
    org.pkl.core.Platform.Processor processor) {
  private static final Platform CURRENT;

  static {
    var pklVersion = Release.current().version().toString();
    var osName = System.getProperty("os.name");
    if (osName.equals("Mac OS X")) osName = "macOS";
    if (osName.contains("Windows")) osName = "Windows";
    var osVersion = System.getProperty("os.version");
    var architecture = System.getProperty("os.arch");

    var runtimeName = Truffle.getRuntime().getName();
    var runtimeVersion = Version.getCurrent().toString();
    var vmName = TruffleOptions.AOT ? runtimeName : System.getProperty("java.vm.name");
    var vmVersion = TruffleOptions.AOT ? runtimeVersion : System.getProperty("java.vm.version");

    CURRENT =
        new Platform(
            new Language(pklVersion),
            new Runtime(runtimeName, runtimeVersion),
            new VirtualMachine(vmName, vmVersion),
            new OperatingSystem(osName, osVersion),
            new Processor(architecture));
  }

  /** The Pkl release that the current program runs on. */

Review comment (suggestion):
```suggestion
    Language language,
    Runtime runtime,
    VirtualMachine virtualMachine,
    OperatingSystem operatingSystem,
    Processor processor) {
```

Code after:
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.pkl.core;

import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.TruffleOptions;
import org.graalvm.home.Version;

/**
 * Information about the Pkl release that the current program runs on. This class is the Java
 * equivalent of standard library module {@code pkl.platform}.
 */
public record Platform(
    Language language,
    Runtime runtime,
    VirtualMachine virtualMachine,
    OperatingSystem operatingSystem,
    Processor processor) {
  private static final Platform CURRENT;

  static {
    var pklVersion = Release.current().version().toString();
    var osName = System.getProperty("os.name");
    if (osName.equals("Mac OS X")) osName = "macOS";
    if (osName.contains("Windows")) osName = "Windows";
    var osVersion = System.getProperty("os.version");
    var architecture = System.getProperty("os.arch");

    var runtimeName = Truffle.getRuntime().getName();
    var runtimeVersion = Version.getCurrent().toString();
    var vmName = TruffleOptions.AOT ? runtimeName : System.getProperty("java.vm.name");
    var vmVersion = TruffleOptions.AOT ? runtimeVersion : System.getProperty("java.vm.version");

    CURRENT =
        new Platform(
            new Language(pklVersion),
            new Runtime(runtimeName, runtimeVersion),
            new VirtualMachine(vmName, vmVersion),
            new OperatingSystem(osName, osVersion),
            new Processor(architecture));
  }

  /** The Pkl release that the current program runs on. */