PageRenderTime 54ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 1ms

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

https://bitbucket.org/xiaoqiangnk/hotspot-mips
Java | 67 lines | 32 code | 5 blank | 30 comment | 17 complexity | 6aea331bc1d6b88ad12c0fa0d0d6c041 MD5 | raw file
Possible License(s): GPL-2.0, BSD-3-Clause
  1. /*
  2. * Copyright 2000-2003 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  20. * CA 95054 USA or visit www.sun.com if you need additional information or
  21. * have any 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.startsWith("Windows")) {
  38. return "win32";
  39. } else {
  40. throw new UnsupportedPlatformException("Operating system " + os + " not yet supported");
  41. }
  42. }
  43. /* Returns "sparc" if on SPARC, "x86" if on x86. */
  44. public static String getCPU() throws UnsupportedPlatformException {
  45. String cpu = System.getProperty("os.arch");
  46. if (cpu.equals("i386")) {
  47. return "x86";
  48. } else if (cpu.equals("sparc") || cpu.equals("x86") || cpu.equals("ia64")) {
  49. return cpu;
  50. } else if (cpu.equals("sparcv9")) {
  51. return "sparc";
  52. } else if (cpu.equals("x86_64") || cpu.equals("amd64")) {
  53. return "amd64";
  54. } else {
  55. throw new UnsupportedPlatformException("CPU type " + cpu + " not yet supported");
  56. }
  57. }
  58. // this main is invoked from Makefile to make platform specific agent Makefile(s).
  59. public static void main(String[] args) {
  60. System.out.println(getOS());
  61. }
  62. }