src/share/vm/prims/jni.cpp

changeset 8387
e4a935cb6f71
parent 8368
32b682649973
child 8389
392f8722fc51
     1.1 --- a/src/share/vm/prims/jni.cpp	Mon Feb 08 13:08:57 2016 +0000
     1.2 +++ b/src/share/vm/prims/jni.cpp	Wed Feb 10 13:34:14 2016 +0000
     1.3 @@ -1121,7 +1121,14 @@
     1.4   protected:
     1.5    va_list _ap;
     1.6  
     1.7 -  inline void get_bool()   { _arguments->push_int(va_arg(_ap, jint)); } // bool is coerced to int when using va_arg
     1.8 +  inline void get_bool()   {
     1.9 +    // Normalize boolean arguments from native code by converting 1-255 to JNI_TRUE and
    1.10 +    // 0 to JNI_FALSE.  Boolean return values from native are normalized the same in
    1.11 +    // TemplateInterpreterGenerator::generate_result_handler_for and
    1.12 +    // SharedRuntime::generate_native_wrapper.
    1.13 +    jboolean b = va_arg(_ap, jint);
    1.14 +    _arguments->push_int((jint)(b == 0 ? JNI_FALSE : JNI_TRUE));
    1.15 +  }
    1.16    inline void get_char()   { _arguments->push_int(va_arg(_ap, jint)); } // char is coerced to int when using va_arg
    1.17    inline void get_short()  { _arguments->push_int(va_arg(_ap, jint)); } // short is coerced to int when using va_arg
    1.18    inline void get_byte()   { _arguments->push_int(va_arg(_ap, jint)); } // byte is coerced to int when using va_arg
    1.19 @@ -1167,9 +1174,17 @@
    1.20        while ( 1 ) {
    1.21          switch ( fingerprint & parameter_feature_mask ) {
    1.22            case bool_parm:
    1.23 +            get_bool();
    1.24 +            break;
    1.25            case char_parm:
    1.26 +            get_char();
    1.27 +            break;
    1.28            case short_parm:
    1.29 +            get_short();
    1.30 +            break;
    1.31            case byte_parm:
    1.32 +            get_byte();
    1.33 +            break;
    1.34            case int_parm:
    1.35              get_int();
    1.36              break;
    1.37 @@ -1203,7 +1218,14 @@
    1.38   protected:
    1.39    const jvalue *_ap;
    1.40  
    1.41 -  inline void get_bool()   { _arguments->push_int((jint)(_ap++)->z); }
    1.42 +  inline void get_bool()   {
    1.43 +    // Normalize boolean arguments from native code by converting 1-255 to JNI_TRUE and
    1.44 +    // 0 to JNI_FALSE.  Boolean return values from native are normalized the same in
    1.45 +    // TemplateInterpreterGenerator::generate_result_handler_for and
    1.46 +    // SharedRuntime::generate_native_wrapper.
    1.47 +    jboolean b = (_ap++)->z;
    1.48 +    _arguments->push_int((jint)(b == 0 ? JNI_FALSE : JNI_TRUE));
    1.49 +  }
    1.50    inline void get_char()   { _arguments->push_int((jint)(_ap++)->c); }
    1.51    inline void get_short()  { _arguments->push_int((jint)(_ap++)->s); }
    1.52    inline void get_byte()   { _arguments->push_int((jint)(_ap++)->b); }

mercurial