< prev index next >

src/hotspot/share/runtime/javaCalls.cpp

Print this page
rev 55090 : secret-sfac

@@ -302,10 +302,23 @@
 
 // ============ allocate and initialize new object instance ============
 
 Handle JavaCalls::construct_new_instance(InstanceKlass* klass, Symbol* constructor_signature, JavaCallArguments* args, TRAPS) {
   klass->initialize(CHECK_NH); // Quick no-op if already initialized.
+
+  // Special case for factory methods
+  if (!constructor_signature->is_void_method_signature()) {
+    assert(klass->is_value(), "inline classes must use factory methods");
+    JavaValue factory_result(T_OBJECT);
+    JavaCalls::call_static(&factory_result, klass,
+                           vmSymbols::object_initializer_name(),
+                           constructor_signature, args, CHECK_NH);
+    return Handle(THREAD, (oop)factory_result.get_jobject());
+  }
+
+  // main branch of code creates a non-inline object:
+  assert(!klass->is_value(), "classic constructors are only for non-inline classes");
   Handle obj = klass->allocate_instance_handle(CHECK_NH);
   JavaValue void_result(T_VOID);
   args->set_receiver(obj); // inserts <obj> as the first argument.
   JavaCalls::call_special(&void_result, klass,
                           vmSymbols::object_initializer_name(),
< prev index next >