PageRenderTime 47ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/agent/src/share/classes/sun/jvm/hotspot/utilities/PlatformInfo.java

https://bitbucket.org/luchsh/openjdk8-hotspot
Java | 75 lines | 40 code | 5 blank | 30 comment | 26 complexity | 5e224f47d4f512e94997f01748210ebc MD5 | raw file
Possible License(s): GPL-2.0, BSD-3-Clause-No-Nuclear-License-2014
  1. /*
  2. * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
  3. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4. *
  5. * This code is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License version 2 only, as
  7. * published by the Free Software Foundation.
  8. *
  9. * This code is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  12. * version 2 for more details (a copy is included in the LICENSE file that
  13. * accompanied this code).
  14. *
  15. * You should have received a copy of the GNU General Public License version
  16. * 2 along with this work; if not, write to the Free Software Foundation,
  17. * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18. *
  19. * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20. * or visit www.oracle.com if you need additional information or have any
  21. * questions.
  22. *
  23. */
  24. package sun.jvm.hotspot.utilities;
  25. /** Provides canonicalized OS and CPU information for the rest of the
  26. system. */
  27. public class PlatformInfo {
  28. /* Returns "solaris" if on Solaris; "win32" if Windows; "linux" if
  29. Linux. Used to determine location of dbx and import module, or
  30. possible debugger agent on win32. */
  31. public static String getOS() throws UnsupportedPlatformException {
  32. String os = System.getProperty("os.name");
  33. if (os.equals("SunOS")) {
  34. return "solaris";
  35. } else if (os.equals("Linux")) {
  36. return "linux";
  37. } else if (os.equals("FreeBSD")) {
  38. return "bsd";
  39. } else if (os.equals("NetBSD")) {
  40. return "bsd";
  41. } else if (os.equals("OpenBSD")) {
  42. return "bsd";
  43. } else if (os.equals("Darwin") || os.startsWith("Mac OS X")) {
  44. return "bsd";
  45. } else if (os.startsWith("Windows")) {
  46. return "win32";
  47. } else {
  48. throw new UnsupportedPlatformException("Operating system " + os + " not yet supported");
  49. }
  50. }
  51. /* Returns "sparc" if on SPARC, "x86" if on x86. */
  52. public static String getCPU() throws UnsupportedPlatformException {
  53. String cpu = System.getProperty("os.arch");
  54. if (cpu.equals("i386")) {
  55. return "x86";
  56. } else if (cpu.equals("sparc") || cpu.equals("x86") || cpu.equals("ia64")) {
  57. return cpu;
  58. } else if (cpu.equals("sparcv9")) {
  59. return "sparc";
  60. } else if (cpu.equals("x86_64") || cpu.equals("amd64")) {
  61. return "amd64";
  62. } else {
  63. throw new UnsupportedPlatformException("CPU type " + cpu + " not yet supported");
  64. }
  65. }
  66. // this main is invoked from Makefile to make platform specific agent Makefile(s).
  67. public static void main(String[] args) {
  68. System.out.println(getOS());
  69. }
  70. }