1 /* |
1 /* |
2 * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
72 private static boolean signed8; |
72 private static boolean signed8; |
73 |
73 |
74 // intel is little-endian. sparc is big-endian. |
74 // intel is little-endian. sparc is big-endian. |
75 private static boolean bigEndian; |
75 private static boolean bigEndian; |
76 |
76 |
77 // this is the value of the "java.home" system property. i am looking it up here |
|
78 // for use when trying to load the soundbank, just so |
|
79 // that all the privileged code is localized in this file.... |
|
80 private static String javahome; |
|
81 |
|
82 // this is the value of the "java.class.path" system property |
|
83 private static String classpath; |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 static { |
77 static { |
89 if(Printer.trace)Printer.trace(">> Platform.java: static"); |
78 if(Printer.trace)Printer.trace(">> Platform.java: static"); |
90 |
79 |
91 loadLibraries(); |
80 loadLibraries(); |
92 readProperties(); |
81 readProperties(); |
127 static boolean isSigned8() { |
116 static boolean isSigned8() { |
128 |
117 |
129 return signed8; |
118 return signed8; |
130 } |
119 } |
131 |
120 |
132 |
|
133 /** |
|
134 * Obtain javahome. |
|
135 * $$kk: 04.16.99: this is *bad*!! |
|
136 */ |
|
137 static String getJavahome() { |
|
138 |
|
139 return javahome; |
|
140 } |
|
141 |
|
142 /** |
|
143 * Obtain classpath. |
|
144 * $$jb: 04.21.99: this is *bad* too!! |
|
145 */ |
|
146 static String getClasspath() { |
|
147 |
|
148 return classpath; |
|
149 } |
|
150 |
|
151 |
|
152 // PRIVATE METHODS |
121 // PRIVATE METHODS |
153 |
122 |
154 /** |
123 /** |
155 * Load the native library or libraries. |
124 * Load the native library or libraries. |
156 */ |
125 */ |
157 private static void loadLibraries() { |
126 private static void loadLibraries() { |
158 if(Printer.trace)Printer.trace(">>Platform.loadLibraries"); |
127 if(Printer.trace)Printer.trace(">>Platform.loadLibraries"); |
159 |
128 |
160 try { |
129 // load the main library |
161 // load the main library |
130 AccessController.doPrivileged((PrivilegedAction<Void>) () -> { |
162 AccessController.doPrivileged(new PrivilegedAction<Void>() { |
131 System.loadLibrary(libNameMain); |
163 @Override |
132 return null; |
164 public Void run() { |
133 }); |
165 System.loadLibrary(libNameMain); |
134 // just for the heck of it... |
166 return null; |
135 loadedLibs |= LIB_MAIN; |
167 } |
|
168 }); |
|
169 // just for the heck of it... |
|
170 loadedLibs |= LIB_MAIN; |
|
171 } catch (SecurityException e) { |
|
172 if(Printer.err)Printer.err("Security exception loading main native library. JavaSound requires access to these resources."); |
|
173 throw(e); |
|
174 } |
|
175 |
136 |
176 // now try to load extra libs. They are defined at compile time in the Makefile |
137 // now try to load extra libs. They are defined at compile time in the Makefile |
177 // with the define EXTRA_SOUND_JNI_LIBS |
138 // with the define EXTRA_SOUND_JNI_LIBS |
178 String extraLibs = nGetExtraLibraries(); |
139 String extraLibs = nGetExtraLibraries(); |
179 // the string is the libraries, separated by white space |
140 // the string is the libraries, separated by white space |
180 StringTokenizer st = new StringTokenizer(extraLibs); |
141 StringTokenizer st = new StringTokenizer(extraLibs); |
181 while (st.hasMoreTokens()) { |
142 while (st.hasMoreTokens()) { |
182 final String lib = st.nextToken(); |
143 final String lib = st.nextToken(); |
183 try { |
144 try { |
184 AccessController.doPrivileged(new PrivilegedAction<Void>() { |
145 AccessController.doPrivileged((PrivilegedAction<Void>) () -> { |
185 @Override |
146 System.loadLibrary(lib); |
186 public Void run() { |
147 return null; |
187 System.loadLibrary(lib); |
|
188 return null; |
|
189 } |
|
190 }); |
148 }); |
191 |
149 |
192 if (lib.equals(libNameALSA)) { |
150 if (lib.equals(libNameALSA)) { |
193 loadedLibs |= LIB_ALSA; |
151 loadedLibs |= LIB_ALSA; |
194 if (Printer.debug) Printer.debug("Loaded ALSA lib successfully."); |
152 if (Printer.debug) Printer.debug("Loaded ALSA lib successfully."); |
237 */ |
195 */ |
238 private static void readProperties() { |
196 private static void readProperties() { |
239 // $$fb 2002-03-06: implement check for endianness in native. Facilitates porting ! |
197 // $$fb 2002-03-06: implement check for endianness in native. Facilitates porting ! |
240 bigEndian = nIsBigEndian(); |
198 bigEndian = nIsBigEndian(); |
241 signed8 = nIsSigned8(); // Solaris on Sparc: signed, all others unsigned |
199 signed8 = nIsSigned8(); // Solaris on Sparc: signed, all others unsigned |
242 javahome = JSSecurityManager.getProperty("java.home"); |
|
243 classpath = JSSecurityManager.getProperty("java.class.path"); |
|
244 } |
200 } |
245 } |
201 } |