< prev index next >

src/hotspot/share/prims/jni.cpp

Print this page

        

@@ -56,10 +56,11 @@
 #include "oops/objArrayOop.inline.hpp"
 #include "oops/oop.inline.hpp"
 #include "oops/symbol.hpp"
 #include "oops/typeArrayKlass.hpp"
 #include "oops/typeArrayOop.inline.hpp"
+#include "oops/valueKlass.hpp"
 #include "prims/jniCheck.hpp"
 #include "prims/jniExport.hpp"
 #include "prims/jniFastGetField.hpp"
 #include "prims/jvm_misc.hpp"
 #include "prims/jvmtiExport.hpp"

@@ -514,11 +515,11 @@
   DT_RETURN_MARK(ToReflectedMethod, jobject, (const jobject&)ret);
 
   methodHandle m (THREAD, Method::resolve_jmethod_id(method_id));
   assert(m->is_static() == (isStatic != 0), "jni_ToReflectedMethod access flags doesn't match");
   oop reflection_method;
-  if (m->is_initializer()) {
+  if (m->is_object_constructor()) {
     reflection_method = Reflection::new_constructor(m, CHECK_NULL);
   } else {
     reflection_method = Reflection::new_method(m, false, CHECK_NULL);
   }
   ret = JNIHandles::make_local(env, reflection_method);

@@ -576,11 +577,19 @@
   Klass* sub_klass   = java_lang_Class::as_Klass(sub_mirror);
   Klass* super_klass = java_lang_Class::as_Klass(super_mirror);
   assert(sub_klass != NULL && super_klass != NULL, "invalid arguments to jni_IsAssignableFrom");
   jboolean ret = sub_klass->is_subtype_of(super_klass) ?
                    JNI_TRUE : JNI_FALSE;
-
+  if (sub_klass == super_klass && sub_klass->is_value()) {
+    // for inline class, V <: V?
+    ValueKlass* vk = ValueKlass::cast(InstanceKlass::cast(sub_klass));
+    if (sub_mirror == super_mirror || (sub_mirror == vk->value_mirror() && super_mirror == vk->indirect_mirror())) {
+      ret = JNI_TRUE;
+    } else {
+      ret = JNI_FALSE;
+    }
+  }
   HOTSPOT_JNI_ISASSIGNABLEFROM_RETURN(ret);
   return ret;
 JNI_END
 
 

@@ -868,10 +877,11 @@
   virtual void get_int    () = 0;
   virtual void get_long   () = 0;
   virtual void get_float  () = 0;
   virtual void get_double () = 0;
   virtual void get_object () = 0;
+  virtual void get_valuetype() = 0;
 
   JNI_ArgumentPusher(Symbol* signature) : SignatureIterator(signature) {
     this->_return_type = T_ILLEGAL;
     _arguments = NULL;
   }

@@ -888,10 +898,11 @@
   inline void do_int()                      { if (!is_return_type()) get_int();    }
   inline void do_long()                     { if (!is_return_type()) get_long();   }
   inline void do_float()                    { if (!is_return_type()) get_float();  }
   inline void do_double()                   { if (!is_return_type()) get_double(); }
   inline void do_object(int begin, int end) { if (!is_return_type()) get_object(); }
+  inline void do_valuetype(int begin, int end) { if (!is_return_type()) get_valuetype();  }
   inline void do_array(int begin, int end)  { if (!is_return_type()) get_object(); } // do_array uses get_object -- there is no get_array
   inline void do_void()                     { }
 
   JavaCallArguments* arguments()     { return _arguments; }
   void push_receiver(Handle h)       { _arguments->push_oop(h); }

@@ -919,10 +930,11 @@
 
   inline void get_long()   { _arguments->push_long(va_arg(_ap, jlong)); }
   inline void get_float()  { _arguments->push_float((jfloat)va_arg(_ap, jdouble)); } // float is coerced to double w/ va_arg
   inline void get_double() { _arguments->push_double(va_arg(_ap, jdouble)); }
   inline void get_object() { _arguments->push_jobject(va_arg(_ap, jobject)); }
+  inline void get_valuetype() { _arguments->push_jobject(va_arg(_ap, jobject)); }
 
   inline void set_ap(va_list rap) {
     va_copy(_ap, rap);
   }
 

@@ -1008,10 +1020,12 @@
 
   inline void get_long()   { _arguments->push_long((_ap++)->j);  }
   inline void get_float()  { _arguments->push_float((_ap++)->f); }
   inline void get_double() { _arguments->push_double((_ap++)->d);}
   inline void get_object() { _arguments->push_jobject((_ap++)->l); }
+  // value types are implemented with oops too
+  inline void get_valuetype() { _arguments->push_jobject((_ap++)->l); }
 
   inline void set_ap(const jvalue *rap) { _ap = rap; }
 
  public:
   JNI_ArgumentPusherArray(Symbol* signature, const jvalue *rap)

@@ -1102,11 +1116,11 @@
 
   // Invoke the method. Result is returned as oop.
   JavaCalls::call(result, method, &java_args, CHECK);
 
   // Convert result
-  if (result->get_type() == T_OBJECT || result->get_type() == T_ARRAY) {
+  if (result->get_type() == T_OBJECT || result->get_type() == T_ARRAY || result->get_type() == T_VALUETYPE) {
     result->set_jobject(JNIHandles::make_local(env, (oop) result->get_jobject()));
   }
 }
 
 

@@ -1165,11 +1179,11 @@
 
   // Invoke the method. Result is returned as oop.
   JavaCalls::call(result, method, &java_args, CHECK);
 
   // Convert result
-  if (result->get_type() == T_OBJECT || result->get_type() == T_ARRAY) {
+  if (result->get_type() == T_OBJECT || result->get_type() == T_ARRAY || result->get_type() == T_VALUETYPE) {
     result->set_jobject(JNIHandles::make_local(env, (oop) result->get_jobject()));
   }
 }
 
 
< prev index next >