< prev index next >

src/hotspot/share/prims/jvm.cpp

Print this page
rev 49818 : 8201649: Remove dubious call_jio_print in ostream.cpp


2699 // Misc //////////////////////////////////////////////////////////////////////////////////////////////
2700 
2701 JVM_LEAF(void, JVM_ReleaseUTF(const char *utf))
2702   // So long as UTF8::convert_to_utf8 returns resource strings, we don't have to do anything
2703 JVM_END
2704 
2705 
2706 JVM_ENTRY(jboolean, JVM_IsSameClassPackage(JNIEnv *env, jclass class1, jclass class2))
2707   JVMWrapper("JVM_IsSameClassPackage");
2708   oop class1_mirror = JNIHandles::resolve_non_null(class1);
2709   oop class2_mirror = JNIHandles::resolve_non_null(class2);
2710   Klass* klass1 = java_lang_Class::as_Klass(class1_mirror);
2711   Klass* klass2 = java_lang_Class::as_Klass(class2_mirror);
2712   return (jboolean) Reflection::is_same_class_package(klass1, klass2);
2713 JVM_END
2714 
2715 // Printing support //////////////////////////////////////////////////
2716 extern "C" {
2717 
2718 ATTRIBUTE_PRINTF(3, 0)
2719 int jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args) {

2720   // Reject count values that are negative signed values converted to
2721   // unsigned; see bug 4399518, 4417214
2722   if ((intptr_t)count <= 0) return -1;
2723 
2724   int result = os::vsnprintf(str, count, fmt, args);
2725   if (result > 0 && (size_t)result >= count) {
2726     result = -1;
2727   }
2728 
2729   return result;
2730 }
2731 
2732 ATTRIBUTE_PRINTF(3, 4)
2733 int jio_snprintf(char *str, size_t count, const char *fmt, ...) {

2734   va_list args;
2735   int len;
2736   va_start(args, fmt);
2737   len = jio_vsnprintf(str, count, fmt, args);
2738   va_end(args);
2739   return len;
2740 }
2741 
2742 ATTRIBUTE_PRINTF(2, 3)
2743 int jio_fprintf(FILE* f, const char *fmt, ...) {

2744   int len;
2745   va_list args;
2746   va_start(args, fmt);
2747   len = jio_vfprintf(f, fmt, args);
2748   va_end(args);
2749   return len;
2750 }
2751 
2752 ATTRIBUTE_PRINTF(2, 0)
2753 int jio_vfprintf(FILE* f, const char *fmt, va_list args) {

2754   if (Arguments::vfprintf_hook() != NULL) {
2755      return Arguments::vfprintf_hook()(f, fmt, args);
2756   } else {
2757     return vfprintf(f, fmt, args);
2758   }
2759 }
2760 
2761 ATTRIBUTE_PRINTF(1, 2)
2762 JNIEXPORT int jio_printf(const char *fmt, ...) {
2763   int len;
2764   va_list args;
2765   va_start(args, fmt);
2766   len = jio_vfprintf(defaultStream::output_stream(), fmt, args);
2767   va_end(args);
2768   return len;
2769 }
2770 
2771 
2772 // HotSpot specific jio method
2773 void jio_print(const char* s) {
2774   // Try to make this function as atomic as possible.
2775   if (Arguments::vfprintf_hook() != NULL) {
2776     jio_fprintf(defaultStream::output_stream(), "%s", s);
2777   } else {
2778     // Make an unused local variable to avoid warning from gcc 4.x compiler.
2779     size_t count = ::write(defaultStream::output_fd(), s, (int)strlen(s));
2780   }
2781 }
2782 
2783 } // Extern C
2784 
2785 // java.lang.Thread //////////////////////////////////////////////////////////////////////////////
2786 
2787 // In most of the JVM thread support functions we need to access the
2788 // thread through a ThreadsListHandle to prevent it from exiting and
2789 // being reclaimed while we try to operate on it. The exceptions to this
2790 // rule are when operating on the current thread, or if the monitor of
2791 // the target java.lang.Thread is locked at the Java level - in both
2792 // cases the target cannot exit.
2793 
2794 static void thread_entry(JavaThread* thread, TRAPS) {
2795   HandleMark hm(THREAD);
2796   Handle obj(THREAD, thread->threadObj());
2797   JavaValue result(T_VOID);
2798   JavaCalls::call_virtual(&result,
2799                           obj,




2699 // Misc //////////////////////////////////////////////////////////////////////////////////////////////
2700 
2701 JVM_LEAF(void, JVM_ReleaseUTF(const char *utf))
2702   // So long as UTF8::convert_to_utf8 returns resource strings, we don't have to do anything
2703 JVM_END
2704 
2705 
2706 JVM_ENTRY(jboolean, JVM_IsSameClassPackage(JNIEnv *env, jclass class1, jclass class2))
2707   JVMWrapper("JVM_IsSameClassPackage");
2708   oop class1_mirror = JNIHandles::resolve_non_null(class1);
2709   oop class2_mirror = JNIHandles::resolve_non_null(class2);
2710   Klass* klass1 = java_lang_Class::as_Klass(class1_mirror);
2711   Klass* klass2 = java_lang_Class::as_Klass(class2_mirror);
2712   return (jboolean) Reflection::is_same_class_package(klass1, klass2);
2713 JVM_END
2714 
2715 // Printing support //////////////////////////////////////////////////
2716 extern "C" {
2717 
2718 ATTRIBUTE_PRINTF(3, 0)
2719 JNIEXPORT int
2720 jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args) {
2721   // Reject count values that are negative signed values converted to
2722   // unsigned; see bug 4399518, 4417214
2723   if ((intptr_t)count <= 0) return -1;
2724 
2725   int result = os::vsnprintf(str, count, fmt, args);
2726   if (result > 0 && (size_t)result >= count) {
2727     result = -1;
2728   }
2729 
2730   return result;
2731 }
2732 
2733 ATTRIBUTE_PRINTF(3, 4)
2734 JNIEXPORT int
2735 jio_snprintf(char *str, size_t count, const char *fmt, ...) {
2736   va_list args;
2737   int len;
2738   va_start(args, fmt);
2739   len = jio_vsnprintf(str, count, fmt, args);
2740   va_end(args);
2741   return len;
2742 }
2743 
2744 ATTRIBUTE_PRINTF(2, 3)
2745 JNIEXPORT int
2746 jio_fprintf(FILE* f, const char *fmt, ...) {
2747   int len;
2748   va_list args;
2749   va_start(args, fmt);
2750   len = jio_vfprintf(f, fmt, args);
2751   va_end(args);
2752   return len;
2753 }
2754 
2755 ATTRIBUTE_PRINTF(2, 0)
2756 JNIEXPORT int
2757 jio_vfprintf(FILE* f, const char *fmt, va_list args) {
2758   if (Arguments::vfprintf_hook() != NULL) {
2759      return Arguments::vfprintf_hook()(f, fmt, args);
2760   } else {
2761     return vfprintf(f, fmt, args);






















2762   }
2763 }
2764 
2765 } // Extern C
2766 
2767 // java.lang.Thread //////////////////////////////////////////////////////////////////////////////
2768 
2769 // In most of the JVM thread support functions we need to access the
2770 // thread through a ThreadsListHandle to prevent it from exiting and
2771 // being reclaimed while we try to operate on it. The exceptions to this
2772 // rule are when operating on the current thread, or if the monitor of
2773 // the target java.lang.Thread is locked at the Java level - in both
2774 // cases the target cannot exit.
2775 
2776 static void thread_entry(JavaThread* thread, TRAPS) {
2777   HandleMark hm(THREAD);
2778   Handle obj(THREAD, thread->threadObj());
2779   JavaValue result(T_VOID);
2780   JavaCalls::call_virtual(&result,
2781                           obj,


< prev index next >