@@ -155,11 +155,7 @@ extension AnyJavaObject {
155155 ) throws -> Result {
156156 // Retrieve the method that performs this call, then package the values and
157157 // call it.
158- // Size the frame to 1 ref per argument (strings/objects each need 1;
159- // primitives need 0, so this slightly over-estimates) plus 1 for the result ref.
160158 let jniMethod = Result . jniMethodCall ( in: environment)
161- environment. interface. PushLocalFrame ( environment, Int32 ( countArgs ( repeat each args) + 2 ) )
162- defer { environment. interface. PopLocalFrame ( environment, nil ) }
163159 let jniArgs = getJValues ( repeat each args, in: environment)
164160 let jniResult = try environment. translatingJNIExceptions {
165161 jniMethod ( environment, this, method, jniArgs)
@@ -225,10 +221,7 @@ extension AnyJavaObject {
225221 ) throws {
226222 // Retrieve the method that performs this call, then package the arguments
227223 // and call it.
228- // Size the frame to 1 ref per argument; no result ref needed for void calls.
229224 let jniMethod = environment. interface. CallVoidMethodA!
230- environment. interface. PushLocalFrame ( environment, Int32 ( countArgs ( repeat each args) + 1 ) )
231- defer { environment. interface. PopLocalFrame ( environment, nil ) }
232225 let jniArgs = getJValues ( repeat each args, in: environment)
233226 try environment. translatingJNIExceptions {
234227 jniMethod ( environment, this, method, jniArgs)
@@ -278,16 +271,10 @@ extension AnyJavaObject {
278271 in: environment
279272 )
280273
281- // Retrieve the constructor, then map the arguments and call it. Use a local
282- // frame so args are freed; promote the new object to the outer frame
283- // via PopLocalFrame(result).
284- // Size the frame to 1 ref per argument; result is promoted via PopLocalFrame(newObj).
285- environment. interface. PushLocalFrame ( environment, Int32 ( countArgs ( repeat each arguments) + 1 ) )
286274 let jniArgs = getJValues ( repeat each arguments, in: environment)
287- let newObj = try environment. translatingJNIExceptions {
275+ return try environment. translatingJNIExceptions {
288276 environment. interface. NewObjectA!( environment, thisClass, methodID, jniArgs)
289277 } !
290- return environment. interface. PopLocalFrame ( environment, newObj) !
291278 }
292279 }
293280
@@ -321,9 +308,6 @@ extension AnyJavaObject {
321308
322309 let fieldID = getJNIFieldID ( fieldName, fieldType: fieldType) !
323310 let jniMethod = FieldType . jniFieldSet ( in: environment)
324- // Frame of 2: 1 for the field value's local ref, 1 buffer.
325- environment. interface. PushLocalFrame ( environment, 2 )
326- defer { environment. interface. PopLocalFrame ( environment, nil ) }
327311 jniMethod ( environment, javaThis, fieldID, newValue. getJNIValue ( in: environment) )
328312 }
329313 }
@@ -355,12 +339,7 @@ extension JavaClass {
355339 )
356340 } !
357341
358- // Retrieve the method that performs this call, then package the values and
359- // call it.
360- // Size the frame to 1 ref per argument plus 1 for the result ref.
361342 let jniMethod = Result . jniStaticMethodCall ( in: environment)
362- environment. interface. PushLocalFrame ( environment, Int32 ( countArgs ( repeat each arguments) + 2 ) )
363- defer { environment. interface. PopLocalFrame ( environment, nil ) }
364343 let jniArgs = getJValues ( repeat each arguments, in: environment)
365344 let jniResult = try environment. translatingJNIExceptions {
366345 jniMethod ( environment, thisClass, methodID, jniArgs)
@@ -393,11 +372,7 @@ extension JavaClass {
393372 )
394373 } !
395374
396- // Retrieve the method that performs this call
397- // Size the frame to 1 ref per argument; no result ref needed for void calls.
398375 let jniMethod = environment. interface. CallStaticVoidMethodA
399- environment. interface. PushLocalFrame ( environment, Int32 ( countArgs ( repeat each arguments) + 1 ) )
400- defer { environment. interface. PopLocalFrame ( environment, nil ) }
401376 let jniArgs = getJValues ( repeat each arguments, in: environment)
402377 try environment. translatingJNIExceptions {
403378 jniMethod!( environment, thisClass, methodID, jniArgs)
0 commit comments