comparison src/share/vm/prims/jni.cpp @ 2044:06f017f7daa7

Merge.
author Thomas Wuerthinger <wuerthinger@ssw.jku.at>
date Fri, 07 Jan 2011 18:18:08 +0100
parents 2d26b0046e0d 017cd8bce8a8
children d25d4ca69222
comparison
equal deleted inserted replaced
1942:00bc9eaf0e24 2044:06f017f7daa7
1 /* 1 /*
2 * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1997, 2010, 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. 7 * published by the Free Software Foundation.
20 * or visit www.oracle.com if you need additional information or have any 20 * or visit www.oracle.com if you need additional information or have any
21 * questions. 21 * questions.
22 * 22 *
23 */ 23 */
24 24
25 # include "incls/_precompiled.incl" 25 #include "precompiled.hpp"
26 # include "incls/_jni.cpp.incl" 26 #include "classfile/classLoader.hpp"
27 #include "classfile/javaClasses.hpp"
28 #include "classfile/symbolTable.hpp"
29 #include "classfile/systemDictionary.hpp"
30 #include "classfile/vmSymbols.hpp"
31 #include "interpreter/linkResolver.hpp"
32 #include "memory/allocation.inline.hpp"
33 #include "memory/gcLocker.inline.hpp"
34 #include "memory/oopFactory.hpp"
35 #include "memory/universe.inline.hpp"
36 #include "oops/instanceKlass.hpp"
37 #include "oops/instanceOop.hpp"
38 #include "oops/markOop.hpp"
39 #include "oops/methodOop.hpp"
40 #include "oops/objArrayKlass.hpp"
41 #include "oops/objArrayOop.hpp"
42 #include "oops/oop.inline.hpp"
43 #include "oops/symbolOop.hpp"
44 #include "oops/typeArrayKlass.hpp"
45 #include "oops/typeArrayOop.hpp"
46 #include "prims/jni.h"
47 #include "prims/jniCheck.hpp"
48 #include "prims/jniFastGetField.hpp"
49 #include "prims/jvm.h"
50 #include "prims/jvm_misc.hpp"
51 #include "prims/jvmtiExport.hpp"
52 #include "prims/jvmtiThreadState.hpp"
53 #include "runtime/compilationPolicy.hpp"
54 #include "runtime/fieldDescriptor.hpp"
55 #include "runtime/fprofiler.hpp"
56 #include "runtime/handles.inline.hpp"
57 #include "runtime/interfaceSupport.hpp"
58 #include "runtime/java.hpp"
59 #include "runtime/javaCalls.hpp"
60 #include "runtime/jfieldIDWorkaround.hpp"
61 #include "runtime/reflection.hpp"
62 #include "runtime/sharedRuntime.hpp"
63 #include "runtime/signature.hpp"
64 #include "runtime/vm_operations.hpp"
65 #include "services/runtimeService.hpp"
66 #include "utilities/defaultStream.hpp"
67 #include "utilities/dtrace.hpp"
68 #include "utilities/events.hpp"
69 #include "utilities/histogram.hpp"
70 #ifdef TARGET_ARCH_x86
71 # include "jniTypes_x86.hpp"
72 #endif
73 #ifdef TARGET_ARCH_sparc
74 # include "jniTypes_sparc.hpp"
75 #endif
76 #ifdef TARGET_ARCH_zero
77 # include "jniTypes_zero.hpp"
78 #endif
79 #ifdef TARGET_OS_FAMILY_linux
80 # include "os_linux.inline.hpp"
81 # include "thread_linux.inline.hpp"
82 #endif
83 #ifdef TARGET_OS_FAMILY_solaris
84 # include "os_solaris.inline.hpp"
85 # include "thread_solaris.inline.hpp"
86 #endif
87 #ifdef TARGET_OS_FAMILY_windows
88 # include "os_windows.inline.hpp"
89 # include "thread_windows.inline.hpp"
90 #endif
27 91
28 static jint CurrentVersion = JNI_VERSION_1_6; 92 static jint CurrentVersion = JNI_VERSION_1_6;
29 93
30 94
31 // The DT_RETURN_MARK macros create a scoped object to fire the dtrace 95 // The DT_RETURN_MARK macros create a scoped object to fire the dtrace
2047 2111
2048 2112
2049 JNI_ENTRY(const char*, jni_GetStringUTFChars(JNIEnv *env, jstring string, jboolean *isCopy)) 2113 JNI_ENTRY(const char*, jni_GetStringUTFChars(JNIEnv *env, jstring string, jboolean *isCopy))
2050 JNIWrapper("GetStringUTFChars"); 2114 JNIWrapper("GetStringUTFChars");
2051 DTRACE_PROBE3(hotspot_jni, GetStringUTFChars__entry, env, string, isCopy); 2115 DTRACE_PROBE3(hotspot_jni, GetStringUTFChars__entry, env, string, isCopy);
2052 ResourceMark rm; 2116 oop java_string = JNIHandles::resolve_non_null(string);
2053 char* str = java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(string)); 2117 size_t length = java_lang_String::utf8_length(java_string);
2054 int length = (int)strlen(str); 2118 char* result = AllocateHeap(length + 1, "GetStringUTFChars");
2055 char* result = AllocateHeap(length+1, "GetStringUTFChars"); 2119 java_lang_String::as_utf8_string(java_string, result, (int) length + 1);
2056 strcpy(result, str);
2057 if (isCopy != NULL) *isCopy = JNI_TRUE; 2120 if (isCopy != NULL) *isCopy = JNI_TRUE;
2058 DTRACE_PROBE1(hotspot_jni, GetStringUTFChars__return, result); 2121 DTRACE_PROBE1(hotspot_jni, GetStringUTFChars__return, result);
2059 return result; 2122 return result;
2060 JNI_END 2123 JNI_END
2061 2124
3192 volatile jint safe_to_recreate_vm = 1; 3255 volatile jint safe_to_recreate_vm = 1;
3193 struct JavaVM_ main_vm = {&jni_InvokeInterface}; 3256 struct JavaVM_ main_vm = {&jni_InvokeInterface};
3194 3257
3195 3258
3196 #define JAVASTACKSIZE (400 * 1024) /* Default size of a thread java stack */ 3259 #define JAVASTACKSIZE (400 * 1024) /* Default size of a thread java stack */
3197 #define PROCSTACKSIZE 0 /* 0 means default size in HPI */
3198 enum { VERIFY_NONE, VERIFY_REMOTE, VERIFY_ALL }; 3260 enum { VERIFY_NONE, VERIFY_REMOTE, VERIFY_ALL };
3199 3261
3200 HS_DTRACE_PROBE_DECL1(hotspot_jni, GetDefaultJavaVMInitArgs__entry, void*); 3262 HS_DTRACE_PROBE_DECL1(hotspot_jni, GetDefaultJavaVMInitArgs__entry, void*);
3201 DT_RETURN_MARK_DECL(GetDefaultJavaVMInitArgs, jint); 3263 DT_RETURN_MARK_DECL(GetDefaultJavaVMInitArgs, jint);
3202 3264