7373public class PsychEmitter extends RubyObject {
7474 public static void initPsychEmitter (Ruby runtime , RubyModule psych ) {
7575 RubyClass psychHandler = runtime .defineClassUnder ("Handler" , runtime .getObject (), runtime .getObject ().getAllocator (), psych );
76- RubyClass psychEmitter = runtime .defineClassUnder ("Emitter" , psychHandler , new ObjectAllocator () {
77- public IRubyObject allocate (Ruby runtime , RubyClass klazz ) {
78- return new PsychEmitter (runtime , klazz );
79- }
80- }, psych );
76+ RubyClass psychEmitter = runtime .defineClassUnder ("Emitter" , psychHandler , PsychEmitter ::new , psych );
8177
8278 psychEmitter .defineAnnotatedMethods (PsychEmitter .class );
8379 }
@@ -135,16 +131,19 @@ public IRubyObject end_stream(ThreadContext context) {
135131
136132 @ JRubyMethod
137133 public IRubyObject start_document (ThreadContext context , IRubyObject _version , IRubyObject tags , IRubyObject implicit ) {
134+ Ruby runtime = context .runtime ;
135+
138136 DumperOptions .Version version = null ;
139137 boolean implicitBool = implicit .isTrue ();
140138 Map <String , String > tagsMap = null ;
141139
142- TypeConverter .checkType (context , _version , context .runtime .getArray ());
140+ RubyClass arrayClass = runtime .getArray ();
141+ TypeConverter .checkType (context , _version , arrayClass );
143142
144143 RubyArray versionAry = _version .convertToArray ();
145144 if (versionAry .size () == 2 ) {
146- int versionInt0 = ( int ) versionAry .eltInternal (0 ).convertToInteger ().getLongValue ();
147- int versionInt1 = ( int ) versionAry .eltInternal (1 ).convertToInteger ().getLongValue ();
145+ int versionInt0 = versionAry .eltInternal (0 ).convertToInteger ().getIntValue ();
146+ int versionInt1 = versionAry .eltInternal (1 ).convertToInteger ().getIntValue ();
148147
149148 if (versionInt0 == 1 ) {
150149 if (versionInt1 == 0 ) {
@@ -154,20 +153,20 @@ public IRubyObject start_document(ThreadContext context, IRubyObject _version, I
154153 }
155154 }
156155 if (version == null ) {
157- throw context . runtime .newArgumentError ("invalid YAML version: " + versionAry );
156+ throw runtime .newArgumentError ("invalid YAML version: " + versionAry );
158157 }
159158 }
160159
161160 if (!tags .isNil ()) {
162- TypeConverter .checkType (context , tags , context . runtime . getArray () );
161+ TypeConverter .checkType (context , tags , arrayClass );
163162
164163 RubyArray tagsAry = tags .convertToArray ();
165164 if (tagsAry .size () > 0 ) {
166165 tagsMap = new HashMap <>(tagsAry .size ());
167166 for (int i = 0 ; i < tagsAry .size (); i ++) {
168167 RubyArray tagsTuple = tagsAry .eltInternal (i ).convertToArray ();
169168 if (tagsTuple .size () != 2 ) {
170- throw context . runtime .newRuntimeError ("tags tuple must be of length 2" );
169+ throw runtime .newRuntimeError ("tags tuple must be of length 2" );
171170 }
172171 IRubyObject key = tagsTuple .eltInternal (0 );
173172 IRubyObject value = tagsTuple .eltInternal (1 );
0 commit comments