@@ -285,17 +285,18 @@ private static RaiseException newTypeError(final Ruby runtime, final String msg,
285285 return withException (createTypeError (runtime .getCurrentContext (), msg .toString ()), e );
286286 }
287287
288- @ JRubyMethod ( name = "allocate " )
288+ @ Deprecated ( since = "10.0 " )
289289 public IRubyObject allocate () {
290- if (superClass == null ) {
291- if (this != runtime .getBasicObject ()) {
292- throw typeError (runtime .getCurrentContext (), "can't instantiate uninitialized class" );
293- }
294- }
295- IRubyObject obj = allocator .allocate (runtime , this );
296- if (getMetaClass (obj ).getRealClass () != getRealClass ()) {
297- throw typeError (runtime .getCurrentContext (), "wrong instance allocation" );
290+ return allocate (getCurrentContext ());
291+ }
292+
293+ @ JRubyMethod (name = "allocate" )
294+ public IRubyObject allocate (ThreadContext context ) {
295+ if (superClass == null && this != basicObjectClass (context )) {
296+ throw typeError (context , "can't instantiate uninitialized class" );
298297 }
298+ IRubyObject obj = allocator .allocate (context .runtime , this );
299+ if (getMetaClass (obj ).getRealClass () != getRealClass ()) throw typeError (context , "wrong instance allocation" );
299300 return obj ;
300301 }
301302
@@ -1006,41 +1007,41 @@ public IRubyObject invokeInherited(ThreadContext context, IRubyObject self, IRub
10061007 */
10071008 @ JRubyMethod (name = "new" , keywords = true )
10081009 public IRubyObject newInstance (ThreadContext context , Block block ) {
1009- IRubyObject obj = allocate ();
1010+ IRubyObject obj = allocate (context );
10101011 baseCallSites [CS_IDX_INITIALIZE ].call (context , obj , obj , block );
10111012 return obj ;
10121013 }
10131014
10141015 @ JRubyMethod (name = "new" , keywords = true )
10151016 public IRubyObject newInstance (ThreadContext context , IRubyObject arg0 , Block block ) {
1016- IRubyObject obj = allocate ();
1017+ IRubyObject obj = allocate (context );
10171018 baseCallSites [CS_IDX_INITIALIZE ].call (context , obj , obj , arg0 , block );
10181019 return obj ;
10191020 }
10201021
10211022 public IRubyObject newInstance (ThreadContext context , IRubyObject arg0 ) {
1022- IRubyObject obj = allocate ();
1023+ IRubyObject obj = allocate (context );
10231024 baseCallSites [CS_IDX_INITIALIZE ].call (context , obj , obj , arg0 );
10241025 return obj ;
10251026 }
10261027
10271028 @ JRubyMethod (name = "new" , keywords = true )
10281029 public IRubyObject newInstance (ThreadContext context , IRubyObject arg0 , IRubyObject arg1 , Block block ) {
1029- IRubyObject obj = allocate ();
1030+ IRubyObject obj = allocate (context );
10301031 baseCallSites [CS_IDX_INITIALIZE ].call (context , obj , obj , arg0 , arg1 , block );
10311032 return obj ;
10321033 }
10331034
10341035 @ JRubyMethod (name = "new" , keywords = true )
10351036 public IRubyObject newInstance (ThreadContext context , IRubyObject arg0 , IRubyObject arg1 , IRubyObject arg2 , Block block ) {
1036- IRubyObject obj = allocate ();
1037+ IRubyObject obj = allocate (context );
10371038 baseCallSites [CS_IDX_INITIALIZE ].call (context , obj , obj , arg0 , arg1 , arg2 , block );
10381039 return obj ;
10391040 }
10401041
10411042 @ JRubyMethod (name = "new" , rest = true , keywords = true )
10421043 public IRubyObject newInstance (ThreadContext context , IRubyObject [] args , Block block ) {
1043- IRubyObject obj = allocate ();
1044+ IRubyObject obj = allocate (context );
10441045 baseCallSites [CS_IDX_INITIALIZE ].call (context , obj , obj , args , block );
10451046 return obj ;
10461047 }
@@ -1500,7 +1501,7 @@ public void marshalTo(Object obj, RubyClass type, NewMarshal marshalStream, Thre
15001501
15011502 @ Override
15021503 public Object unmarshalFrom (Ruby runtime , RubyClass type , UnmarshalStream input ) throws IOException {
1503- IRubyObject result = input .entry (type .allocate ());
1504+ IRubyObject result = input .entry (type .allocate (runtime . getCurrentContext () ));
15041505
15051506 input .ivar (null , result , null );
15061507
0 commit comments