1 /*
2 * Copyright (c) 2011, 2012, 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. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25 package com.apple.jobjc;
26
27 import java.lang.reflect.Field;
28 import java.nio.ByteOrder;
29 import java.util.ArrayList;
30 import java.util.List;
31
32 import sun.misc.Unsafe;
33
34 import javax.tools.annotation.GenerateNativeHeader;
35
36 /* No native methods here, but the constants are needed in the supporting JNI code */
37 @GenerateNativeHeader
38 public final class JObjCRuntime {
39 static { System.loadLibrary("JObjC"); }
40
41 @GenerateNativeHeader
42 public static enum Arch{ ppc, i386, x86_64 };
43 @GenerateNativeHeader
44 public static enum Width{ W32, W64 };
45
46 public static final Arch ARCH = getArch();
47 public static final Width WIDTH = getWidth();
48
49 private static Arch getArch(){
50 String arch = System.getProperty("os.arch");
51 if("ppc".equals(arch)) return Arch.ppc;
52 if("i386".equals(arch)) return Arch.i386;
53 if("x86_64".equals(arch)) return Arch.x86_64;
54 if("amd64".equals(arch)) return Arch.x86_64;
55 if("universal".equals(arch)) return Arch.x86_64;
56 throw new RuntimeException("Did not recognize os.arch system property: '" + arch + "'");
57 }
58
59 private static Width getWidth(){
60 String width = System.getProperty("sun.arch.data.model");
61 if("32".equals(width)) return Width.W32;
62 if("64".equals(width)) return Width.W64;
63 throw new RuntimeException("Did not recognize sun.arch.data.model system property: '" + width + "'");
|
1 /*
2 * Copyright (c) 2011, 2013, 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. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25 package com.apple.jobjc;
26
27 import java.lang.reflect.Field;
28 import java.nio.ByteOrder;
29 import java.util.ArrayList;
30 import java.util.List;
31
32 import sun.misc.Unsafe;
33
34
35 public final class JObjCRuntime {
36 static { System.loadLibrary("JObjC"); }
37
38 public static enum Arch{ ppc, i386, x86_64 };
39 public static enum Width{ W32, W64 };
40
41 public static final Arch ARCH = getArch();
42 public static final Width WIDTH = getWidth();
43
44 private static Arch getArch(){
45 String arch = System.getProperty("os.arch");
46 if("ppc".equals(arch)) return Arch.ppc;
47 if("i386".equals(arch)) return Arch.i386;
48 if("x86_64".equals(arch)) return Arch.x86_64;
49 if("amd64".equals(arch)) return Arch.x86_64;
50 if("universal".equals(arch)) return Arch.x86_64;
51 throw new RuntimeException("Did not recognize os.arch system property: '" + arch + "'");
52 }
53
54 private static Width getWidth(){
55 String width = System.getProperty("sun.arch.data.model");
56 if("32".equals(width)) return Width.W32;
57 if("64".equals(width)) return Width.W64;
58 throw new RuntimeException("Did not recognize sun.arch.data.model system property: '" + width + "'");
|