36 #include "classfile/systemDictionary.hpp" |
36 #include "classfile/systemDictionary.hpp" |
37 #include "classfile/vmSymbols.hpp" |
37 #include "classfile/vmSymbols.hpp" |
38 #include "gc/shared/collectedHeap.inline.hpp" |
38 #include "gc/shared/collectedHeap.inline.hpp" |
39 #include "interpreter/bytecode.hpp" |
39 #include "interpreter/bytecode.hpp" |
40 #include "jfr/jfrEvents.hpp" |
40 #include "jfr/jfrEvents.hpp" |
|
41 #include "logging/log.hpp" |
|
42 #include "memory/heapShared.hpp" |
41 #include "memory/oopFactory.hpp" |
43 #include "memory/oopFactory.hpp" |
42 #include "memory/referenceType.hpp" |
44 #include "memory/referenceType.hpp" |
43 #include "memory/resourceArea.hpp" |
45 #include "memory/resourceArea.hpp" |
44 #include "memory/universe.hpp" |
46 #include "memory/universe.hpp" |
45 #include "oops/access.inline.hpp" |
47 #include "oops/access.inline.hpp" |
659 // Make shallow object copy |
661 // Make shallow object copy |
660 const int size = obj->size(); |
662 const int size = obj->size(); |
661 oop new_obj_oop = NULL; |
663 oop new_obj_oop = NULL; |
662 if (obj->is_array()) { |
664 if (obj->is_array()) { |
663 const int length = ((arrayOop)obj())->length(); |
665 const int length = ((arrayOop)obj())->length(); |
664 new_obj_oop = CollectedHeap::array_allocate(klass, size, length, CHECK_NULL); |
666 new_obj_oop = Universe::heap()->array_allocate(klass, size, length, |
|
667 /* do_zero */ true, CHECK_NULL); |
665 } else { |
668 } else { |
666 new_obj_oop = CollectedHeap::obj_allocate(klass, size, CHECK_NULL); |
669 new_obj_oop = Universe::heap()->obj_allocate(klass, size, CHECK_NULL); |
667 } |
670 } |
668 |
671 |
669 HeapAccess<>::clone(obj(), new_obj_oop, size); |
672 HeapAccess<>::clone(obj(), new_obj_oop, size); |
670 |
673 |
671 Handle new_obj(THREAD, new_obj_oop); |
674 Handle new_obj(THREAD, new_obj_oop); |
1890 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
1893 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
1891 return k->access_flags().as_int() & JVM_ACC_WRITTEN_FLAGS; |
1894 return k->access_flags().as_int() & JVM_ACC_WRITTEN_FLAGS; |
1892 } |
1895 } |
1893 JVM_END |
1896 JVM_END |
1894 |
1897 |
|
1898 JVM_ENTRY(jboolean, JVM_AreNestMates(JNIEnv *env, jclass current, jclass member)) |
|
1899 { |
|
1900 JVMWrapper("JVM_AreNestMates"); |
|
1901 Klass* c = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(current)); |
|
1902 assert(c->is_instance_klass(), "must be"); |
|
1903 InstanceKlass* ck = InstanceKlass::cast(c); |
|
1904 Klass* m = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(member)); |
|
1905 assert(m->is_instance_klass(), "must be"); |
|
1906 InstanceKlass* mk = InstanceKlass::cast(m); |
|
1907 return ck->has_nestmate_access_to(mk, THREAD); |
|
1908 } |
|
1909 JVM_END |
|
1910 |
|
1911 JVM_ENTRY(jclass, JVM_GetNestHost(JNIEnv* env, jclass current)) |
|
1912 { |
|
1913 // current is not a primitive or array class |
|
1914 JVMWrapper("JVM_GetNestHost"); |
|
1915 Klass* c = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(current)); |
|
1916 assert(c->is_instance_klass(), "must be"); |
|
1917 InstanceKlass* ck = InstanceKlass::cast(c); |
|
1918 // Don't post exceptions if validation fails |
|
1919 InstanceKlass* host = ck->nest_host(NULL, THREAD); |
|
1920 return (jclass) (host == NULL ? NULL : |
|
1921 JNIHandles::make_local(THREAD, host->java_mirror())); |
|
1922 } |
|
1923 JVM_END |
|
1924 |
|
1925 JVM_ENTRY(jobjectArray, JVM_GetNestMembers(JNIEnv* env, jclass current)) |
|
1926 { |
|
1927 // current is not a primitive or array class |
|
1928 JVMWrapper("JVM_GetNestMembers"); |
|
1929 Klass* c = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(current)); |
|
1930 assert(c->is_instance_klass(), "must be"); |
|
1931 InstanceKlass* ck = InstanceKlass::cast(c); |
|
1932 // Get the nest host for this nest - throw ICCE if validation fails |
|
1933 Symbol* icce = vmSymbols::java_lang_IncompatibleClassChangeError(); |
|
1934 InstanceKlass* host = ck->nest_host(icce, CHECK_NULL); |
|
1935 |
|
1936 { |
|
1937 JvmtiVMObjectAllocEventCollector oam; |
|
1938 Array<u2>* members = host->nest_members(); |
|
1939 int length = members == NULL ? 0 : members->length(); |
|
1940 // nest host is first in the array so make it one bigger |
|
1941 objArrayOop r = oopFactory::new_objArray(SystemDictionary::Class_klass(), |
|
1942 length + 1, CHECK_NULL); |
|
1943 objArrayHandle result (THREAD, r); |
|
1944 result->obj_at_put(0, host->java_mirror()); |
|
1945 if (length != 0) { |
|
1946 int i; |
|
1947 for (i = 0; i < length; i++) { |
|
1948 int cp_index = members->at(i); |
|
1949 Klass* k = host->constants()->klass_at(cp_index, CHECK_NULL); |
|
1950 if (k->is_instance_klass()) { |
|
1951 InstanceKlass* nest_host_k = |
|
1952 InstanceKlass::cast(k)->nest_host(icce, CHECK_NULL); |
|
1953 if (nest_host_k == host) { |
|
1954 result->obj_at_put(i+1, k->java_mirror()); |
|
1955 } |
|
1956 else { |
|
1957 // k's nest host is legal but it isn't our host so |
|
1958 // throw ICCE |
|
1959 ResourceMark rm(THREAD); |
|
1960 Exceptions::fthrow(THREAD_AND_LOCATION, |
|
1961 icce, |
|
1962 "Nest member %s in %s declares a different nest host of %s", |
|
1963 k->external_name(), |
|
1964 host->external_name(), |
|
1965 nest_host_k->external_name() |
|
1966 ); |
|
1967 return NULL; |
|
1968 } |
|
1969 } |
|
1970 else { |
|
1971 // we have a bad nest member entry - throw ICCE |
|
1972 ResourceMark rm(THREAD); |
|
1973 Exceptions::fthrow(THREAD_AND_LOCATION, |
|
1974 icce, |
|
1975 "Class %s can not be a nest member of %s", |
|
1976 k->external_name(), |
|
1977 host->external_name() |
|
1978 ); |
|
1979 return NULL; |
|
1980 } |
|
1981 } |
|
1982 } |
|
1983 else { |
|
1984 assert(host == ck, "must be singleton nest"); |
|
1985 } |
|
1986 return (jobjectArray)JNIHandles::make_local(THREAD, result()); |
|
1987 } |
|
1988 } |
|
1989 JVM_END |
1895 |
1990 |
1896 // Constant pool access ////////////////////////////////////////////////////////// |
1991 // Constant pool access ////////////////////////////////////////////////////////// |
1897 |
1992 |
1898 JVM_ENTRY(jobject, JVM_GetClassConstantPool(JNIEnv *env, jclass cls)) |
1993 JVM_ENTRY(jobject, JVM_GetClassConstantPool(JNIEnv *env, jclass cls)) |
1899 { |
1994 { |
3502 JVM_LEAF(jboolean, JVM_SupportsCX8()) |
3597 JVM_LEAF(jboolean, JVM_SupportsCX8()) |
3503 JVMWrapper("JVM_SupportsCX8"); |
3598 JVMWrapper("JVM_SupportsCX8"); |
3504 return VM_Version::supports_cx8(); |
3599 return VM_Version::supports_cx8(); |
3505 JVM_END |
3600 JVM_END |
3506 |
3601 |
|
3602 JVM_ENTRY(void, JVM_InitializeFromArchive(JNIEnv* env, jclass cls)) |
|
3603 JVMWrapper("JVM_InitializeFromArchive"); |
|
3604 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve(cls)); |
|
3605 assert(k->is_klass(), "just checking"); |
|
3606 HeapShared::initialize_from_archived_subgraph(k); |
|
3607 JVM_END |
|
3608 |
3507 // Returns an array of all live Thread objects (VM internal JavaThreads, |
3609 // Returns an array of all live Thread objects (VM internal JavaThreads, |
3508 // jvmti agent threads, and JNI attaching threads are skipped) |
3610 // jvmti agent threads, and JNI attaching threads are skipped) |
3509 // See CR 6404306 regarding JNI attaching threads |
3611 // See CR 6404306 regarding JNI attaching threads |
3510 JVM_ENTRY(jobjectArray, JVM_GetAllThreads(JNIEnv *env, jclass dummy)) |
3612 JVM_ENTRY(jobjectArray, JVM_GetAllThreads(JNIEnv *env, jclass dummy)) |
3511 ResourceMark rm(THREAD); |
3613 ResourceMark rm(THREAD); |