625 new_obj = InstanceKlass::register_finalizer(instanceOop(new_obj), CHECK_NULL); |
601 new_obj = InstanceKlass::register_finalizer(instanceOop(new_obj), CHECK_NULL); |
626 } |
602 } |
627 |
603 |
628 return JNIHandles::make_local(env, oop(new_obj)); |
604 return JNIHandles::make_local(env, oop(new_obj)); |
629 JVM_END |
605 JVM_END |
630 |
|
631 // java.lang.Compiler //////////////////////////////////////////////////// |
|
632 |
|
633 // The initial cuts of the HotSpot VM will not support JITs, and all existing |
|
634 // JITs would need extensive changes to work with HotSpot. The JIT-related JVM |
|
635 // functions are all silently ignored unless JVM warnings are printed. |
|
636 |
|
637 JVM_LEAF(void, JVM_InitializeCompiler (JNIEnv *env, jclass compCls)) |
|
638 if (PrintJVMWarnings) warning("JVM_InitializeCompiler not supported"); |
|
639 JVM_END |
|
640 |
|
641 |
|
642 JVM_LEAF(jboolean, JVM_IsSilentCompiler(JNIEnv *env, jclass compCls)) |
|
643 if (PrintJVMWarnings) warning("JVM_IsSilentCompiler not supported"); |
|
644 return JNI_FALSE; |
|
645 JVM_END |
|
646 |
|
647 |
|
648 JVM_LEAF(jboolean, JVM_CompileClass(JNIEnv *env, jclass compCls, jclass cls)) |
|
649 if (PrintJVMWarnings) warning("JVM_CompileClass not supported"); |
|
650 return JNI_FALSE; |
|
651 JVM_END |
|
652 |
|
653 |
|
654 JVM_LEAF(jboolean, JVM_CompileClasses(JNIEnv *env, jclass cls, jstring jname)) |
|
655 if (PrintJVMWarnings) warning("JVM_CompileClasses not supported"); |
|
656 return JNI_FALSE; |
|
657 JVM_END |
|
658 |
|
659 |
|
660 JVM_LEAF(jobject, JVM_CompilerCommand(JNIEnv *env, jclass compCls, jobject arg)) |
|
661 if (PrintJVMWarnings) warning("JVM_CompilerCommand not supported"); |
|
662 return NULL; |
|
663 JVM_END |
|
664 |
|
665 |
|
666 JVM_LEAF(void, JVM_EnableCompiler(JNIEnv *env, jclass compCls)) |
|
667 if (PrintJVMWarnings) warning("JVM_EnableCompiler not supported"); |
|
668 JVM_END |
|
669 |
|
670 |
|
671 JVM_LEAF(void, JVM_DisableCompiler(JNIEnv *env, jclass compCls)) |
|
672 if (PrintJVMWarnings) warning("JVM_DisableCompiler not supported"); |
|
673 JVM_END |
|
674 |
|
675 |
|
676 |
|
677 // Error message support ////////////////////////////////////////////////////// |
|
678 |
|
679 JVM_LEAF(jint, JVM_GetLastErrorString(char *buf, int len)) |
|
680 JVMWrapper("JVM_GetLastErrorString"); |
|
681 return (jint)os::lasterror(buf, len); |
|
682 JVM_END |
|
683 |
|
684 |
606 |
685 // java.io.File /////////////////////////////////////////////////////////////// |
607 // java.io.File /////////////////////////////////////////////////////////////// |
686 |
608 |
687 JVM_LEAF(char*, JVM_NativePath(char* path)) |
609 JVM_LEAF(char*, JVM_NativePath(char* path)) |
688 JVMWrapper2("JVM_NativePath (%s)", path); |
610 JVMWrapper2("JVM_NativePath (%s)", path); |
1686 |
1587 |
1687 Method* m = InstanceKlass::cast(k)->method_with_idnum(slot); |
1588 Method* m = InstanceKlass::cast(k)->method_with_idnum(slot); |
1688 assert(m != NULL, "cannot find method"); |
1589 assert(m != NULL, "cannot find method"); |
1689 return m; // caller has to deal with NULL in product mode |
1590 return m; // caller has to deal with NULL in product mode |
1690 } |
1591 } |
1691 |
|
1692 |
|
1693 JVM_ENTRY(jbyteArray, JVM_GetMethodAnnotations(JNIEnv *env, jobject method)) |
|
1694 JVMWrapper("JVM_GetMethodAnnotations"); |
|
1695 |
|
1696 // method is a handle to a java.lang.reflect.Method object |
|
1697 Method* m = jvm_get_method_common(method); |
|
1698 if (m == NULL) { |
|
1699 return NULL; |
|
1700 } |
|
1701 |
|
1702 return (jbyteArray) JNIHandles::make_local(env, |
|
1703 Annotations::make_java_array(m->annotations(), THREAD)); |
|
1704 JVM_END |
|
1705 |
|
1706 |
|
1707 JVM_ENTRY(jbyteArray, JVM_GetMethodDefaultAnnotationValue(JNIEnv *env, jobject method)) |
|
1708 JVMWrapper("JVM_GetMethodDefaultAnnotationValue"); |
|
1709 |
|
1710 // method is a handle to a java.lang.reflect.Method object |
|
1711 Method* m = jvm_get_method_common(method); |
|
1712 if (m == NULL) { |
|
1713 return NULL; |
|
1714 } |
|
1715 |
|
1716 return (jbyteArray) JNIHandles::make_local(env, |
|
1717 Annotations::make_java_array(m->annotation_default(), THREAD)); |
|
1718 JVM_END |
|
1719 |
|
1720 |
|
1721 JVM_ENTRY(jbyteArray, JVM_GetMethodParameterAnnotations(JNIEnv *env, jobject method)) |
|
1722 JVMWrapper("JVM_GetMethodParameterAnnotations"); |
|
1723 |
|
1724 // method is a handle to a java.lang.reflect.Method object |
|
1725 Method* m = jvm_get_method_common(method); |
|
1726 if (m == NULL) { |
|
1727 return NULL; |
|
1728 } |
|
1729 |
|
1730 return (jbyteArray) JNIHandles::make_local(env, |
|
1731 Annotations::make_java_array(m->parameter_annotations(), THREAD)); |
|
1732 JVM_END |
|
1733 |
1592 |
1734 /* Type use annotations support (JDK 1.8) */ |
1593 /* Type use annotations support (JDK 1.8) */ |
1735 |
1594 |
1736 JVM_ENTRY(jbyteArray, JVM_GetClassTypeAnnotations(JNIEnv *env, jclass cls)) |
1595 JVM_ENTRY(jbyteArray, JVM_GetClassTypeAnnotations(JNIEnv *env, jclass cls)) |
1737 assert (cls != NULL, "illegal class"); |
1596 assert (cls != NULL, "illegal class"); |
2715 Klass* klass1 = java_lang_Class::as_Klass(class1_mirror); |
2574 Klass* klass1 = java_lang_Class::as_Klass(class1_mirror); |
2716 Klass* klass2 = java_lang_Class::as_Klass(class2_mirror); |
2575 Klass* klass2 = java_lang_Class::as_Klass(class2_mirror); |
2717 return (jboolean) Reflection::is_same_class_package(klass1, klass2); |
2576 return (jboolean) Reflection::is_same_class_package(klass1, klass2); |
2718 JVM_END |
2577 JVM_END |
2719 |
2578 |
2720 |
|
2721 // IO functions //////////////////////////////////////////////////////////////////////////////////////// |
|
2722 |
|
2723 JVM_LEAF(jint, JVM_Open(const char *fname, jint flags, jint mode)) |
|
2724 JVMWrapper2("JVM_Open (%s)", fname); |
|
2725 |
|
2726 //%note jvm_r6 |
|
2727 int result = os::open(fname, flags, mode); |
|
2728 if (result >= 0) { |
|
2729 return result; |
|
2730 } else { |
|
2731 switch(errno) { |
|
2732 case EEXIST: |
|
2733 return JVM_EEXIST; |
|
2734 default: |
|
2735 return -1; |
|
2736 } |
|
2737 } |
|
2738 JVM_END |
|
2739 |
|
2740 |
|
2741 JVM_LEAF(jint, JVM_Close(jint fd)) |
|
2742 JVMWrapper2("JVM_Close (0x%x)", fd); |
|
2743 //%note jvm_r6 |
|
2744 return os::close(fd); |
|
2745 JVM_END |
|
2746 |
|
2747 |
|
2748 JVM_LEAF(jint, JVM_Read(jint fd, char *buf, jint nbytes)) |
|
2749 JVMWrapper2("JVM_Read (0x%x)", fd); |
|
2750 |
|
2751 //%note jvm_r6 |
|
2752 return (jint)os::restartable_read(fd, buf, nbytes); |
|
2753 JVM_END |
|
2754 |
|
2755 |
|
2756 JVM_LEAF(jint, JVM_Write(jint fd, char *buf, jint nbytes)) |
|
2757 JVMWrapper2("JVM_Write (0x%x)", fd); |
|
2758 |
|
2759 //%note jvm_r6 |
|
2760 return (jint)os::write(fd, buf, nbytes); |
|
2761 JVM_END |
|
2762 |
|
2763 |
|
2764 JVM_LEAF(jint, JVM_Available(jint fd, jlong *pbytes)) |
|
2765 JVMWrapper2("JVM_Available (0x%x)", fd); |
|
2766 //%note jvm_r6 |
|
2767 return os::available(fd, pbytes); |
|
2768 JVM_END |
|
2769 |
|
2770 |
|
2771 JVM_LEAF(jlong, JVM_Lseek(jint fd, jlong offset, jint whence)) |
|
2772 JVMWrapper4("JVM_Lseek (0x%x, " INT64_FORMAT ", %d)", fd, (int64_t) offset, whence); |
|
2773 //%note jvm_r6 |
|
2774 return os::lseek(fd, offset, whence); |
|
2775 JVM_END |
|
2776 |
|
2777 |
|
2778 JVM_LEAF(jint, JVM_SetLength(jint fd, jlong length)) |
|
2779 JVMWrapper3("JVM_SetLength (0x%x, " INT64_FORMAT ")", fd, (int64_t) length); |
|
2780 return os::ftruncate(fd, length); |
|
2781 JVM_END |
|
2782 |
|
2783 |
|
2784 JVM_LEAF(jint, JVM_Sync(jint fd)) |
|
2785 JVMWrapper2("JVM_Sync (0x%x)", fd); |
|
2786 //%note jvm_r6 |
|
2787 return os::fsync(fd); |
|
2788 JVM_END |
|
2789 |
|
2790 |
|
2791 // Printing support ////////////////////////////////////////////////// |
2579 // Printing support ////////////////////////////////////////////////// |
2792 extern "C" { |
2580 extern "C" { |
2793 |
2581 |
2794 ATTRIBUTE_PRINTF(3, 0) |
2582 ATTRIBUTE_PRINTF(3, 0) |
2795 int jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args) { |
2583 int jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args) { |
3457 } |
3245 } |
3458 |
3246 |
3459 return (!access.is_private() && InstanceKlass::cast(current_class)->is_same_class_package(field_class)); |
3247 return (!access.is_private() && InstanceKlass::cast(current_class)->is_same_class_package(field_class)); |
3460 } |
3248 } |
3461 |
3249 |
3462 |
|
3463 // JVM_AllocateNewObject and JVM_AllocateNewArray are unused as of 1.4 |
|
3464 JVM_ENTRY(jobject, JVM_AllocateNewObject(JNIEnv *env, jobject receiver, jclass currClass, jclass initClass)) |
|
3465 JVMWrapper("JVM_AllocateNewObject"); |
|
3466 JvmtiVMObjectAllocEventCollector oam; |
|
3467 // Receiver is not used |
|
3468 oop curr_mirror = JNIHandles::resolve_non_null(currClass); |
|
3469 oop init_mirror = JNIHandles::resolve_non_null(initClass); |
|
3470 |
|
3471 // Cannot instantiate primitive types |
|
3472 if (java_lang_Class::is_primitive(curr_mirror) || java_lang_Class::is_primitive(init_mirror)) { |
|
3473 ResourceMark rm(THREAD); |
|
3474 THROW_0(vmSymbols::java_lang_InvalidClassException()); |
|
3475 } |
|
3476 |
|
3477 // Arrays not allowed here, must use JVM_AllocateNewArray |
|
3478 if (java_lang_Class::as_Klass(curr_mirror)->oop_is_array() || |
|
3479 java_lang_Class::as_Klass(init_mirror)->oop_is_array()) { |
|
3480 ResourceMark rm(THREAD); |
|
3481 THROW_0(vmSymbols::java_lang_InvalidClassException()); |
|
3482 } |
|
3483 |
|
3484 instanceKlassHandle curr_klass (THREAD, java_lang_Class::as_Klass(curr_mirror)); |
|
3485 instanceKlassHandle init_klass (THREAD, java_lang_Class::as_Klass(init_mirror)); |
|
3486 |
|
3487 assert(curr_klass->is_subclass_of(init_klass()), "just checking"); |
|
3488 |
|
3489 // Interfaces, abstract classes, and java.lang.Class classes cannot be instantiated directly. |
|
3490 curr_klass->check_valid_for_instantiation(false, CHECK_NULL); |
|
3491 |
|
3492 // Make sure klass is initialized, since we are about to instantiate one of them. |
|
3493 curr_klass->initialize(CHECK_NULL); |
|
3494 |
|
3495 methodHandle m (THREAD, |
|
3496 init_klass->find_method(vmSymbols::object_initializer_name(), |
|
3497 vmSymbols::void_method_signature())); |
|
3498 if (m.is_null()) { |
|
3499 ResourceMark rm(THREAD); |
|
3500 THROW_MSG_0(vmSymbols::java_lang_NoSuchMethodError(), |
|
3501 Method::name_and_sig_as_C_string(init_klass(), |
|
3502 vmSymbols::object_initializer_name(), |
|
3503 vmSymbols::void_method_signature())); |
|
3504 } |
|
3505 |
|
3506 if (curr_klass == init_klass && !m->is_public()) { |
|
3507 // Calling the constructor for class 'curr_klass'. |
|
3508 // Only allow calls to a public no-arg constructor. |
|
3509 // This path corresponds to creating an Externalizable object. |
|
3510 THROW_0(vmSymbols::java_lang_IllegalAccessException()); |
|
3511 } |
|
3512 |
|
3513 if (!force_verify_field_access(curr_klass(), init_klass(), m->access_flags(), false)) { |
|
3514 // subclass 'curr_klass' does not have access to no-arg constructor of 'initcb' |
|
3515 THROW_0(vmSymbols::java_lang_IllegalAccessException()); |
|
3516 } |
|
3517 |
|
3518 Handle obj = curr_klass->allocate_instance_handle(CHECK_NULL); |
|
3519 // Call constructor m. This might call a constructor higher up in the hierachy |
|
3520 JavaCalls::call_default_constructor(thread, m, obj, CHECK_NULL); |
|
3521 |
|
3522 return JNIHandles::make_local(obj()); |
|
3523 JVM_END |
|
3524 |
|
3525 |
|
3526 JVM_ENTRY(jobject, JVM_AllocateNewArray(JNIEnv *env, jobject obj, jclass currClass, jint length)) |
|
3527 JVMWrapper("JVM_AllocateNewArray"); |
|
3528 JvmtiVMObjectAllocEventCollector oam; |
|
3529 oop mirror = JNIHandles::resolve_non_null(currClass); |
|
3530 |
|
3531 if (java_lang_Class::is_primitive(mirror)) { |
|
3532 THROW_0(vmSymbols::java_lang_InvalidClassException()); |
|
3533 } |
|
3534 Klass* k = java_lang_Class::as_Klass(mirror); |
|
3535 oop result; |
|
3536 |
|
3537 if (k->oop_is_typeArray()) { |
|
3538 // typeArray |
|
3539 result = TypeArrayKlass::cast(k)->allocate(length, CHECK_NULL); |
|
3540 } else if (k->oop_is_objArray()) { |
|
3541 // objArray |
|
3542 ObjArrayKlass* oak = ObjArrayKlass::cast(k); |
|
3543 oak->initialize(CHECK_NULL); // make sure class is initialized (matches Classic VM behavior) |
|
3544 result = oak->allocate(length, CHECK_NULL); |
|
3545 } else { |
|
3546 THROW_0(vmSymbols::java_lang_InvalidClassException()); |
|
3547 } |
|
3548 return JNIHandles::make_local(env, result); |
|
3549 JVM_END |
|
3550 |
|
3551 |
|
3552 // Return the first non-null class loader up the execution stack, or null |
3250 // Return the first non-null class loader up the execution stack, or null |
3553 // if only code from the null class loader is on the stack. |
3251 // if only code from the null class loader is on the stack. |
3554 |
3252 |
3555 JVM_ENTRY(jobject, JVM_LatestUserDefinedLoader(JNIEnv *env)) |
3253 JVM_ENTRY(jobject, JVM_LatestUserDefinedLoader(JNIEnv *env)) |
3556 for (vframeStream vfst(thread); !vfst.at_end(); vfst.next()) { |
3254 for (vframeStream vfst(thread); !vfst.at_end(); vfst.next()) { |
3559 if (loader != NULL) { |
3257 if (loader != NULL) { |
3560 return JNIHandles::make_local(env, loader); |
3258 return JNIHandles::make_local(env, loader); |
3561 } |
3259 } |
3562 } |
3260 } |
3563 return NULL; |
3261 return NULL; |
3564 JVM_END |
|
3565 |
|
3566 |
|
3567 // Load a class relative to the most recent class on the stack with a non-null |
|
3568 // classloader. |
|
3569 // This function has been deprecated and should not be considered part of the |
|
3570 // specified JVM interface. |
|
3571 |
|
3572 JVM_ENTRY(jclass, JVM_LoadClass0(JNIEnv *env, jobject receiver, |
|
3573 jclass currClass, jstring currClassName)) |
|
3574 JVMWrapper("JVM_LoadClass0"); |
|
3575 // Receiver is not used |
|
3576 ResourceMark rm(THREAD); |
|
3577 |
|
3578 // Class name argument is not guaranteed to be in internal format |
|
3579 Handle classname (THREAD, JNIHandles::resolve_non_null(currClassName)); |
|
3580 Handle string = java_lang_String::internalize_classname(classname, CHECK_NULL); |
|
3581 |
|
3582 const char* str = java_lang_String::as_utf8_string(string()); |
|
3583 |
|
3584 if (str == NULL || (int)strlen(str) > Symbol::max_length()) { |
|
3585 // It's impossible to create this class; the name cannot fit |
|
3586 // into the constant pool. |
|
3587 THROW_MSG_0(vmSymbols::java_lang_NoClassDefFoundError(), str); |
|
3588 } |
|
3589 |
|
3590 TempNewSymbol name = SymbolTable::new_symbol(str, CHECK_NULL); |
|
3591 Handle curr_klass (THREAD, JNIHandles::resolve(currClass)); |
|
3592 // Find the most recent class on the stack with a non-null classloader |
|
3593 oop loader = NULL; |
|
3594 oop protection_domain = NULL; |
|
3595 if (curr_klass.is_null()) { |
|
3596 for (vframeStream vfst(thread); |
|
3597 !vfst.at_end() && loader == NULL; |
|
3598 vfst.next()) { |
|
3599 if (!vfst.method()->is_native()) { |
|
3600 InstanceKlass* holder = vfst.method()->method_holder(); |
|
3601 loader = holder->class_loader(); |
|
3602 protection_domain = holder->protection_domain(); |
|
3603 } |
|
3604 } |
|
3605 } else { |
|
3606 Klass* curr_klass_oop = java_lang_Class::as_Klass(curr_klass()); |
|
3607 loader = InstanceKlass::cast(curr_klass_oop)->class_loader(); |
|
3608 protection_domain = InstanceKlass::cast(curr_klass_oop)->protection_domain(); |
|
3609 } |
|
3610 Handle h_loader(THREAD, loader); |
|
3611 Handle h_prot (THREAD, protection_domain); |
|
3612 jclass result = find_class_from_class_loader(env, name, true, h_loader, h_prot, |
|
3613 false, thread); |
|
3614 if (TraceClassResolution && result != NULL) { |
|
3615 trace_class_resolution(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(result))); |
|
3616 } |
|
3617 return result; |
|
3618 JVM_END |
3262 JVM_END |
3619 |
3263 |
3620 |
3264 |
3621 // Array /////////////////////////////////////////////////////////////////////////////////////////// |
3265 // Array /////////////////////////////////////////////////////////////////////////////////////////// |
3622 |
3266 |
3711 oop result = Reflection::reflect_new_multi_array(element_mirror, typeArrayOop(dim_array), CHECK_NULL); |
3355 oop result = Reflection::reflect_new_multi_array(element_mirror, typeArrayOop(dim_array), CHECK_NULL); |
3712 return JNIHandles::make_local(env, result); |
3356 return JNIHandles::make_local(env, result); |
3713 JVM_END |
3357 JVM_END |
3714 |
3358 |
3715 |
3359 |
3716 // Networking library support //////////////////////////////////////////////////////////////////// |
|
3717 |
|
3718 JVM_LEAF(jint, JVM_InitializeSocketLibrary()) |
|
3719 JVMWrapper("JVM_InitializeSocketLibrary"); |
|
3720 return 0; |
|
3721 JVM_END |
|
3722 |
|
3723 |
|
3724 JVM_LEAF(jint, JVM_Socket(jint domain, jint type, jint protocol)) |
|
3725 JVMWrapper("JVM_Socket"); |
|
3726 return os::socket(domain, type, protocol); |
|
3727 JVM_END |
|
3728 |
|
3729 |
|
3730 JVM_LEAF(jint, JVM_SocketClose(jint fd)) |
|
3731 JVMWrapper2("JVM_SocketClose (0x%x)", fd); |
|
3732 //%note jvm_r6 |
|
3733 return os::socket_close(fd); |
|
3734 JVM_END |
|
3735 |
|
3736 |
|
3737 JVM_LEAF(jint, JVM_SocketShutdown(jint fd, jint howto)) |
|
3738 JVMWrapper2("JVM_SocketShutdown (0x%x)", fd); |
|
3739 //%note jvm_r6 |
|
3740 return os::socket_shutdown(fd, howto); |
|
3741 JVM_END |
|
3742 |
|
3743 |
|
3744 JVM_LEAF(jint, JVM_Recv(jint fd, char *buf, jint nBytes, jint flags)) |
|
3745 JVMWrapper2("JVM_Recv (0x%x)", fd); |
|
3746 //%note jvm_r6 |
|
3747 return os::recv(fd, buf, (size_t)nBytes, (uint)flags); |
|
3748 JVM_END |
|
3749 |
|
3750 |
|
3751 JVM_LEAF(jint, JVM_Send(jint fd, char *buf, jint nBytes, jint flags)) |
|
3752 JVMWrapper2("JVM_Send (0x%x)", fd); |
|
3753 //%note jvm_r6 |
|
3754 return os::send(fd, buf, (size_t)nBytes, (uint)flags); |
|
3755 JVM_END |
|
3756 |
|
3757 |
|
3758 JVM_LEAF(jint, JVM_Timeout(int fd, long timeout)) |
|
3759 JVMWrapper2("JVM_Timeout (0x%x)", fd); |
|
3760 //%note jvm_r6 |
|
3761 return os::timeout(fd, timeout); |
|
3762 JVM_END |
|
3763 |
|
3764 |
|
3765 JVM_LEAF(jint, JVM_Listen(jint fd, jint count)) |
|
3766 JVMWrapper2("JVM_Listen (0x%x)", fd); |
|
3767 //%note jvm_r6 |
|
3768 return os::listen(fd, count); |
|
3769 JVM_END |
|
3770 |
|
3771 |
|
3772 JVM_LEAF(jint, JVM_Connect(jint fd, struct sockaddr *him, jint len)) |
|
3773 JVMWrapper2("JVM_Connect (0x%x)", fd); |
|
3774 //%note jvm_r6 |
|
3775 return os::connect(fd, him, (socklen_t)len); |
|
3776 JVM_END |
|
3777 |
|
3778 |
|
3779 JVM_LEAF(jint, JVM_Bind(jint fd, struct sockaddr *him, jint len)) |
|
3780 JVMWrapper2("JVM_Bind (0x%x)", fd); |
|
3781 //%note jvm_r6 |
|
3782 return os::bind(fd, him, (socklen_t)len); |
|
3783 JVM_END |
|
3784 |
|
3785 |
|
3786 JVM_LEAF(jint, JVM_Accept(jint fd, struct sockaddr *him, jint *len)) |
|
3787 JVMWrapper2("JVM_Accept (0x%x)", fd); |
|
3788 //%note jvm_r6 |
|
3789 socklen_t socklen = (socklen_t)(*len); |
|
3790 jint result = os::accept(fd, him, &socklen); |
|
3791 *len = (jint)socklen; |
|
3792 return result; |
|
3793 JVM_END |
|
3794 |
|
3795 |
|
3796 JVM_LEAF(jint, JVM_RecvFrom(jint fd, char *buf, int nBytes, int flags, struct sockaddr *from, int *fromlen)) |
|
3797 JVMWrapper2("JVM_RecvFrom (0x%x)", fd); |
|
3798 //%note jvm_r6 |
|
3799 socklen_t socklen = (socklen_t)(*fromlen); |
|
3800 jint result = os::recvfrom(fd, buf, (size_t)nBytes, (uint)flags, from, &socklen); |
|
3801 *fromlen = (int)socklen; |
|
3802 return result; |
|
3803 JVM_END |
|
3804 |
|
3805 |
|
3806 JVM_LEAF(jint, JVM_GetSockName(jint fd, struct sockaddr *him, int *len)) |
|
3807 JVMWrapper2("JVM_GetSockName (0x%x)", fd); |
|
3808 //%note jvm_r6 |
|
3809 socklen_t socklen = (socklen_t)(*len); |
|
3810 jint result = os::get_sock_name(fd, him, &socklen); |
|
3811 *len = (int)socklen; |
|
3812 return result; |
|
3813 JVM_END |
|
3814 |
|
3815 |
|
3816 JVM_LEAF(jint, JVM_SendTo(jint fd, char *buf, int len, int flags, struct sockaddr *to, int tolen)) |
|
3817 JVMWrapper2("JVM_SendTo (0x%x)", fd); |
|
3818 //%note jvm_r6 |
|
3819 return os::sendto(fd, buf, (size_t)len, (uint)flags, to, (socklen_t)tolen); |
|
3820 JVM_END |
|
3821 |
|
3822 |
|
3823 JVM_LEAF(jint, JVM_SocketAvailable(jint fd, jint *pbytes)) |
|
3824 JVMWrapper2("JVM_SocketAvailable (0x%x)", fd); |
|
3825 //%note jvm_r6 |
|
3826 return os::socket_available(fd, pbytes); |
|
3827 JVM_END |
|
3828 |
|
3829 |
|
3830 JVM_LEAF(jint, JVM_GetSockOpt(jint fd, int level, int optname, char *optval, int *optlen)) |
|
3831 JVMWrapper2("JVM_GetSockOpt (0x%x)", fd); |
|
3832 //%note jvm_r6 |
|
3833 socklen_t socklen = (socklen_t)(*optlen); |
|
3834 jint result = os::get_sock_opt(fd, level, optname, optval, &socklen); |
|
3835 *optlen = (int)socklen; |
|
3836 return result; |
|
3837 JVM_END |
|
3838 |
|
3839 |
|
3840 JVM_LEAF(jint, JVM_SetSockOpt(jint fd, int level, int optname, const char *optval, int optlen)) |
|
3841 JVMWrapper2("JVM_GetSockOpt (0x%x)", fd); |
|
3842 //%note jvm_r6 |
|
3843 return os::set_sock_opt(fd, level, optname, optval, (socklen_t)optlen); |
|
3844 JVM_END |
|
3845 |
|
3846 |
|
3847 JVM_LEAF(int, JVM_GetHostName(char* name, int namelen)) |
|
3848 JVMWrapper("JVM_GetHostName"); |
|
3849 return os::get_host_name(name, namelen); |
|
3850 JVM_END |
|
3851 |
|
3852 |
|
3853 // Library support /////////////////////////////////////////////////////////////////////////// |
3360 // Library support /////////////////////////////////////////////////////////////////////////// |
3854 |
3361 |
3855 JVM_ENTRY_NO_ENV(void*, JVM_LoadLibrary(const char* name)) |
3362 JVM_ENTRY_NO_ENV(void*, JVM_LoadLibrary(const char* name)) |
3856 //%note jvm_ct |
3363 //%note jvm_ct |
3857 JVMWrapper2("JVM_LoadLibrary (%s)", name); |
3364 JVMWrapper2("JVM_LoadLibrary (%s)", name); |
4190 } |
3675 } |
4191 return (jobjectArray) JNIHandles::make_local(dest()); |
3676 return (jobjectArray) JNIHandles::make_local(dest()); |
4192 } |
3677 } |
4193 JVM_END |
3678 JVM_END |
4194 |
3679 |
4195 JVM_ENTRY(jintArray, JVM_GetThreadStateValues(JNIEnv* env, |
|
4196 jint javaThreadState)) |
|
4197 { |
|
4198 // If new thread states are added in future JDK and VM versions, |
|
4199 // this should check if the JDK version is compatible with thread |
|
4200 // states supported by the VM. Return NULL if not compatible. |
|
4201 // |
|
4202 // This function must map the VM java_lang_Thread::ThreadStatus |
|
4203 // to the Java thread state that the JDK supports. |
|
4204 // |
|
4205 |
|
4206 typeArrayHandle values_h; |
|
4207 switch (javaThreadState) { |
|
4208 case JAVA_THREAD_STATE_NEW : { |
|
4209 typeArrayOop r = oopFactory::new_typeArray(T_INT, 1, CHECK_NULL); |
|
4210 values_h = typeArrayHandle(THREAD, r); |
|
4211 values_h->int_at_put(0, java_lang_Thread::NEW); |
|
4212 break; |
|
4213 } |
|
4214 case JAVA_THREAD_STATE_RUNNABLE : { |
|
4215 typeArrayOop r = oopFactory::new_typeArray(T_INT, 1, CHECK_NULL); |
|
4216 values_h = typeArrayHandle(THREAD, r); |
|
4217 values_h->int_at_put(0, java_lang_Thread::RUNNABLE); |
|
4218 break; |
|
4219 } |
|
4220 case JAVA_THREAD_STATE_BLOCKED : { |
|
4221 typeArrayOop r = oopFactory::new_typeArray(T_INT, 1, CHECK_NULL); |
|
4222 values_h = typeArrayHandle(THREAD, r); |
|
4223 values_h->int_at_put(0, java_lang_Thread::BLOCKED_ON_MONITOR_ENTER); |
|
4224 break; |
|
4225 } |
|
4226 case JAVA_THREAD_STATE_WAITING : { |
|
4227 typeArrayOop r = oopFactory::new_typeArray(T_INT, 2, CHECK_NULL); |
|
4228 values_h = typeArrayHandle(THREAD, r); |
|
4229 values_h->int_at_put(0, java_lang_Thread::IN_OBJECT_WAIT); |
|
4230 values_h->int_at_put(1, java_lang_Thread::PARKED); |
|
4231 break; |
|
4232 } |
|
4233 case JAVA_THREAD_STATE_TIMED_WAITING : { |
|
4234 typeArrayOop r = oopFactory::new_typeArray(T_INT, 3, CHECK_NULL); |
|
4235 values_h = typeArrayHandle(THREAD, r); |
|
4236 values_h->int_at_put(0, java_lang_Thread::SLEEPING); |
|
4237 values_h->int_at_put(1, java_lang_Thread::IN_OBJECT_WAIT_TIMED); |
|
4238 values_h->int_at_put(2, java_lang_Thread::PARKED_TIMED); |
|
4239 break; |
|
4240 } |
|
4241 case JAVA_THREAD_STATE_TERMINATED : { |
|
4242 typeArrayOop r = oopFactory::new_typeArray(T_INT, 1, CHECK_NULL); |
|
4243 values_h = typeArrayHandle(THREAD, r); |
|
4244 values_h->int_at_put(0, java_lang_Thread::TERMINATED); |
|
4245 break; |
|
4246 } |
|
4247 default: |
|
4248 // Unknown state - probably incompatible JDK version |
|
4249 return NULL; |
|
4250 } |
|
4251 |
|
4252 return (jintArray) JNIHandles::make_local(env, values_h()); |
|
4253 } |
|
4254 JVM_END |
|
4255 |
|
4256 |
|
4257 JVM_ENTRY(jobjectArray, JVM_GetThreadStateNames(JNIEnv* env, |
|
4258 jint javaThreadState, |
|
4259 jintArray values)) |
|
4260 { |
|
4261 // If new thread states are added in future JDK and VM versions, |
|
4262 // this should check if the JDK version is compatible with thread |
|
4263 // states supported by the VM. Return NULL if not compatible. |
|
4264 // |
|
4265 // This function must map the VM java_lang_Thread::ThreadStatus |
|
4266 // to the Java thread state that the JDK supports. |
|
4267 // |
|
4268 |
|
4269 ResourceMark rm; |
|
4270 |
|
4271 // Check if threads is null |
|
4272 if (values == NULL) { |
|
4273 THROW_(vmSymbols::java_lang_NullPointerException(), 0); |
|
4274 } |
|
4275 |
|
4276 typeArrayOop v = typeArrayOop(JNIHandles::resolve_non_null(values)); |
|
4277 typeArrayHandle values_h(THREAD, v); |
|
4278 |
|
4279 objArrayHandle names_h; |
|
4280 switch (javaThreadState) { |
|
4281 case JAVA_THREAD_STATE_NEW : { |
|
4282 assert(values_h->length() == 1 && |
|
4283 values_h->int_at(0) == java_lang_Thread::NEW, |
|
4284 "Invalid threadStatus value"); |
|
4285 |
|
4286 objArrayOop r = oopFactory::new_objArray(SystemDictionary::String_klass(), |
|
4287 1, /* only 1 substate */ |
|
4288 CHECK_NULL); |
|
4289 names_h = objArrayHandle(THREAD, r); |
|
4290 Handle name = java_lang_String::create_from_str("NEW", CHECK_NULL); |
|
4291 names_h->obj_at_put(0, name()); |
|
4292 break; |
|
4293 } |
|
4294 case JAVA_THREAD_STATE_RUNNABLE : { |
|
4295 assert(values_h->length() == 1 && |
|
4296 values_h->int_at(0) == java_lang_Thread::RUNNABLE, |
|
4297 "Invalid threadStatus value"); |
|
4298 |
|
4299 objArrayOop r = oopFactory::new_objArray(SystemDictionary::String_klass(), |
|
4300 1, /* only 1 substate */ |
|
4301 CHECK_NULL); |
|
4302 names_h = objArrayHandle(THREAD, r); |
|
4303 Handle name = java_lang_String::create_from_str("RUNNABLE", CHECK_NULL); |
|
4304 names_h->obj_at_put(0, name()); |
|
4305 break; |
|
4306 } |
|
4307 case JAVA_THREAD_STATE_BLOCKED : { |
|
4308 assert(values_h->length() == 1 && |
|
4309 values_h->int_at(0) == java_lang_Thread::BLOCKED_ON_MONITOR_ENTER, |
|
4310 "Invalid threadStatus value"); |
|
4311 |
|
4312 objArrayOop r = oopFactory::new_objArray(SystemDictionary::String_klass(), |
|
4313 1, /* only 1 substate */ |
|
4314 CHECK_NULL); |
|
4315 names_h = objArrayHandle(THREAD, r); |
|
4316 Handle name = java_lang_String::create_from_str("BLOCKED", CHECK_NULL); |
|
4317 names_h->obj_at_put(0, name()); |
|
4318 break; |
|
4319 } |
|
4320 case JAVA_THREAD_STATE_WAITING : { |
|
4321 assert(values_h->length() == 2 && |
|
4322 values_h->int_at(0) == java_lang_Thread::IN_OBJECT_WAIT && |
|
4323 values_h->int_at(1) == java_lang_Thread::PARKED, |
|
4324 "Invalid threadStatus value"); |
|
4325 objArrayOop r = oopFactory::new_objArray(SystemDictionary::String_klass(), |
|
4326 2, /* number of substates */ |
|
4327 CHECK_NULL); |
|
4328 names_h = objArrayHandle(THREAD, r); |
|
4329 Handle name0 = java_lang_String::create_from_str("WAITING.OBJECT_WAIT", |
|
4330 CHECK_NULL); |
|
4331 Handle name1 = java_lang_String::create_from_str("WAITING.PARKED", |
|
4332 CHECK_NULL); |
|
4333 names_h->obj_at_put(0, name0()); |
|
4334 names_h->obj_at_put(1, name1()); |
|
4335 break; |
|
4336 } |
|
4337 case JAVA_THREAD_STATE_TIMED_WAITING : { |
|
4338 assert(values_h->length() == 3 && |
|
4339 values_h->int_at(0) == java_lang_Thread::SLEEPING && |
|
4340 values_h->int_at(1) == java_lang_Thread::IN_OBJECT_WAIT_TIMED && |
|
4341 values_h->int_at(2) == java_lang_Thread::PARKED_TIMED, |
|
4342 "Invalid threadStatus value"); |
|
4343 objArrayOop r = oopFactory::new_objArray(SystemDictionary::String_klass(), |
|
4344 3, /* number of substates */ |
|
4345 CHECK_NULL); |
|
4346 names_h = objArrayHandle(THREAD, r); |
|
4347 Handle name0 = java_lang_String::create_from_str("TIMED_WAITING.SLEEPING", |
|
4348 CHECK_NULL); |
|
4349 Handle name1 = java_lang_String::create_from_str("TIMED_WAITING.OBJECT_WAIT", |
|
4350 CHECK_NULL); |
|
4351 Handle name2 = java_lang_String::create_from_str("TIMED_WAITING.PARKED", |
|
4352 CHECK_NULL); |
|
4353 names_h->obj_at_put(0, name0()); |
|
4354 names_h->obj_at_put(1, name1()); |
|
4355 names_h->obj_at_put(2, name2()); |
|
4356 break; |
|
4357 } |
|
4358 case JAVA_THREAD_STATE_TERMINATED : { |
|
4359 assert(values_h->length() == 1 && |
|
4360 values_h->int_at(0) == java_lang_Thread::TERMINATED, |
|
4361 "Invalid threadStatus value"); |
|
4362 objArrayOop r = oopFactory::new_objArray(SystemDictionary::String_klass(), |
|
4363 1, /* only 1 substate */ |
|
4364 CHECK_NULL); |
|
4365 names_h = objArrayHandle(THREAD, r); |
|
4366 Handle name = java_lang_String::create_from_str("TERMINATED", CHECK_NULL); |
|
4367 names_h->obj_at_put(0, name()); |
|
4368 break; |
|
4369 } |
|
4370 default: |
|
4371 // Unknown state - probably incompatible JDK version |
|
4372 return NULL; |
|
4373 } |
|
4374 return (jobjectArray) JNIHandles::make_local(env, names_h()); |
|
4375 } |
|
4376 JVM_END |
|
4377 |
|
4378 JVM_ENTRY(void, JVM_GetVersionInfo(JNIEnv* env, jvm_version_info* info, size_t info_size)) |
3680 JVM_ENTRY(void, JVM_GetVersionInfo(JNIEnv* env, jvm_version_info* info, size_t info_size)) |
4379 { |
3681 { |
4380 memset(info, 0, info_size); |
3682 memset(info, 0, info_size); |
4381 |
3683 |
4382 info->jvm_version = Abstract_VM_Version::jvm_version(); |
3684 info->jvm_version = Abstract_VM_Version::jvm_version(); |