< prev index next >

src/java.base/share/native/libjava/System.c

Print this page

280 }
281 
282 JNIEXPORT void JNICALL
283 Java_java_lang_System_setErr0(JNIEnv *env, jclass cla, jobject stream)
284 {
285     jfieldID fid =
286         (*env)->GetStaticFieldID(env,cla,"err","Ljava/io/PrintStream;");
287     if (fid == 0)
288         return;
289     (*env)->SetStaticObjectField(env,cla,fid,stream);
290 }
291 
292 static void cpchars(jchar *dst, char *src, int n)
293 {
294     int i;
295     for (i = 0; i < n; i++) {
296         dst[i] = src[i];
297     }
298 }
299 













300 JNIEXPORT jstring JNICALL
301 Java_java_lang_System_mapLibraryName(JNIEnv *env, jclass ign, jstring libname)
302 {
303     int len;
304     int prefix_len = (int) strlen(JNI_LIB_PREFIX);
305     int suffix_len = (int) strlen(JNI_LIB_SUFFIX);
306 
307     jchar chars[256];
308     if (libname == NULL) {
309         JNU_ThrowNullPointerException(env, 0);
310         return NULL;
311     }
312     len = (*env)->GetStringLength(env, libname);
313     if (len > 240) {
314         JNU_ThrowIllegalArgumentException(env, "name too long");
315         return NULL;
316     }
317     cpchars(chars, JNI_LIB_PREFIX, prefix_len);
318     (*env)->GetStringRegion(env, libname, 0, len, chars + prefix_len);
319     len += prefix_len;

280 }
281 
282 JNIEXPORT void JNICALL
283 Java_java_lang_System_setErr0(JNIEnv *env, jclass cla, jobject stream)
284 {
285     jfieldID fid =
286         (*env)->GetStaticFieldID(env,cla,"err","Ljava/io/PrintStream;");
287     if (fid == 0)
288         return;
289     (*env)->SetStaticObjectField(env,cla,fid,stream);
290 }
291 
292 static void cpchars(jchar *dst, char *src, int n)
293 {
294     int i;
295     for (i = 0; i < n; i++) {
296         dst[i] = src[i];
297     }
298 }
299 
300 JNIEXPORT jboolean JNICALL
301 Java_java_lang_System_AOTIsTraining(JNIEnv *env, jclass ign)
302 {
303     jboolean isTraining = JVM_AOTIsTraining(env);
304     return isTraining;
305 }
306 
307 JNIEXPORT void JNICALL
308 Java_java_lang_System_AOTEndTraining(JNIEnv *env, jclass ign)
309 {
310     JVM_AOTEndTraining(env);
311 }
312 
313 JNIEXPORT jstring JNICALL
314 Java_java_lang_System_mapLibraryName(JNIEnv *env, jclass ign, jstring libname)
315 {
316     int len;
317     int prefix_len = (int) strlen(JNI_LIB_PREFIX);
318     int suffix_len = (int) strlen(JNI_LIB_SUFFIX);
319 
320     jchar chars[256];
321     if (libname == NULL) {
322         JNU_ThrowNullPointerException(env, 0);
323         return NULL;
324     }
325     len = (*env)->GetStringLength(env, libname);
326     if (len > 240) {
327         JNU_ThrowIllegalArgumentException(env, "name too long");
328         return NULL;
329     }
330     cpchars(chars, JNI_LIB_PREFIX, prefix_len);
331     (*env)->GetStringRegion(env, libname, 0, len, chars + prefix_len);
332     len += prefix_len;
< prev index next >