Commit dc10d96cde2eaac4cf12eae7783538828242badf

Sylvain Becker 2019-01-11T15:36:16

Android: use the same naming for JNI env local variables

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
diff --git a/src/core/android/SDL_android.c b/src/core/android/SDL_android.c
index e7d0388..40199fe 100644
--- a/src/core/android/SDL_android.c
+++ b/src/core/android/SDL_android.c
@@ -68,7 +68,7 @@
 
 /* Java class SDLActivity */
 JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(
-        JNIEnv *mEnv, jclass cls);
+        JNIEnv *env, jclass cls);
 
 JNIEXPORT int JNICALL SDL_JAVA_INTERFACE(nativeRunMain)(
         JNIEnv *env, jclass cls,
@@ -350,7 +350,7 @@ void checkJNIReady()
 }
 
 /* Activity initialization -- called before SDL_main() to initialize JNI bindings */
-JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv *mEnv, jclass cls)
+JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv *env, jclass cls)
 {
     __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "nativeSetupJNI()");
 
@@ -367,57 +367,57 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv *mEnv, jclass c
 
     Android_JNI_SetupThread();
 
-    mActivityClass = (jclass)((*mEnv)->NewGlobalRef(mEnv, cls));
+    mActivityClass = (jclass)((*env)->NewGlobalRef(env, cls));
 
-    midGetNativeSurface = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
+    midGetNativeSurface = (*env)->GetStaticMethodID(env, mActivityClass,
                                 "getNativeSurface","()Landroid/view/Surface;");
-    midSetSurfaceViewFormat = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
+    midSetSurfaceViewFormat = (*env)->GetStaticMethodID(env, mActivityClass,
                                 "setSurfaceViewFormat","(I)V");
-    midSetActivityTitle = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
+    midSetActivityTitle = (*env)->GetStaticMethodID(env, mActivityClass,
                                 "setActivityTitle","(Ljava/lang/String;)Z");
-    midSetWindowStyle = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
+    midSetWindowStyle = (*env)->GetStaticMethodID(env, mActivityClass,
                                 "setWindowStyle","(Z)V");
-    midSetOrientation = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
+    midSetOrientation = (*env)->GetStaticMethodID(env, mActivityClass,
                                 "setOrientation","(IIZLjava/lang/String;)V");
-    midGetContext = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
+    midGetContext = (*env)->GetStaticMethodID(env, mActivityClass,
                                 "getContext","()Landroid/content/Context;");
-    midIsTablet = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
+    midIsTablet = (*env)->GetStaticMethodID(env, mActivityClass,
                                 "isTablet", "()Z");
-    midIsAndroidTV = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
+    midIsAndroidTV = (*env)->GetStaticMethodID(env, mActivityClass,
                                 "isAndroidTV","()Z");
-    midIsChromebook = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
+    midIsChromebook = (*env)->GetStaticMethodID(env, mActivityClass,
                                 "isChromebook", "()Z");
-    midIsDeXMode = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
+    midIsDeXMode = (*env)->GetStaticMethodID(env, mActivityClass,
                                 "isDeXMode", "()Z");
-    midManualBackButton = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
+    midManualBackButton = (*env)->GetStaticMethodID(env, mActivityClass,
                                 "manualBackButton", "()V");
-    midInitTouch = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
+    midInitTouch = (*env)->GetStaticMethodID(env, mActivityClass,
                                 "initTouch", "()V");
-    midSendMessage = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
+    midSendMessage = (*env)->GetStaticMethodID(env, mActivityClass,
                                 "sendMessage", "(II)Z");
-    midShowTextInput =  (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
+    midShowTextInput =  (*env)->GetStaticMethodID(env, mActivityClass,
                                 "showTextInput", "(IIII)Z");
-    midIsScreenKeyboardShown = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
+    midIsScreenKeyboardShown = (*env)->GetStaticMethodID(env, mActivityClass,
                                 "isScreenKeyboardShown","()Z");
-    midClipboardSetText = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
+    midClipboardSetText = (*env)->GetStaticMethodID(env, mActivityClass,
                                 "clipboardSetText", "(Ljava/lang/String;)V");
-    midClipboardGetText = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
+    midClipboardGetText = (*env)->GetStaticMethodID(env, mActivityClass,
                                 "clipboardGetText", "()Ljava/lang/String;");
-    midClipboardHasText = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
+    midClipboardHasText = (*env)->GetStaticMethodID(env, mActivityClass,
                                 "clipboardHasText", "()Z");
-    midOpenAPKExpansionInputStream = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
+    midOpenAPKExpansionInputStream = (*env)->GetStaticMethodID(env, mActivityClass,
                                 "openAPKExpansionInputStream", "(Ljava/lang/String;)Ljava/io/InputStream;");
 
-    midGetManifestEnvironmentVariables = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
+    midGetManifestEnvironmentVariables = (*env)->GetStaticMethodID(env, mActivityClass,
                                 "getManifestEnvironmentVariables", "()Z");
 
-    midGetDisplayDPI = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "getDisplayDPI", "()Landroid/util/DisplayMetrics;");
-    midCreateCustomCursor = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "createCustomCursor", "([IIIII)I");
-    midSetCustomCursor = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "setCustomCursor", "(I)Z");
-    midSetSystemCursor = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "setSystemCursor", "(I)Z");
+    midGetDisplayDPI = (*env)->GetStaticMethodID(env, mActivityClass, "getDisplayDPI", "()Landroid/util/DisplayMetrics;");
+    midCreateCustomCursor = (*env)->GetStaticMethodID(env, mActivityClass, "createCustomCursor", "([IIIII)I");
+    midSetCustomCursor = (*env)->GetStaticMethodID(env, mActivityClass, "setCustomCursor", "(I)Z");
+    midSetSystemCursor = (*env)->GetStaticMethodID(env, mActivityClass, "setSystemCursor", "(I)Z");
 
-    midSupportsRelativeMouse = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "supportsRelativeMouse", "()Z");
-    midSetRelativeMouseEnabled = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "setRelativeMouseEnabled", "(Z)Z");
+    midSupportsRelativeMouse = (*env)->GetStaticMethodID(env, mActivityClass, "supportsRelativeMouse", "()Z");
+    midSetRelativeMouseEnabled = (*env)->GetStaticMethodID(env, mActivityClass, "setRelativeMouseEnabled", "(Z)Z");
 
 
     if (!midGetNativeSurface || !midSetSurfaceViewFormat ||
@@ -430,7 +430,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv *mEnv, jclass c
         __android_log_print(ANDROID_LOG_WARN, "SDL", "Missing some Java callbacks, do you have the latest version of SDLActivity.java?");
     }
 
-    fidSeparateMouseAndTouch = (*mEnv)->GetStaticFieldID(mEnv, mActivityClass, "mSeparateMouseAndTouch", "Z");
+    fidSeparateMouseAndTouch = (*env)->GetStaticFieldID(env, mActivityClass, "mSeparateMouseAndTouch", "Z");
 
     if (!fidSeparateMouseAndTouch) {
         __android_log_print(ANDROID_LOG_WARN, "SDL", "Missing some Java static fields, do you have the latest version of SDLActivity.java?");
@@ -440,35 +440,35 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv *mEnv, jclass c
 }
 
 /* Audio initialization -- called before SDL_main() to initialize JNI bindings */
-JNIEXPORT void JNICALL SDL_JAVA_AUDIO_INTERFACE(nativeSetupJNI)(JNIEnv *mEnv, jclass cls)
+JNIEXPORT void JNICALL SDL_JAVA_AUDIO_INTERFACE(nativeSetupJNI)(JNIEnv *env, jclass cls)
 {
     __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "AUDIO nativeSetupJNI()");
 
     Android_JNI_SetupThread();
 
-    mAudioManagerClass = (jclass)((*mEnv)->NewGlobalRef(mEnv, cls));
+    mAudioManagerClass = (jclass)((*env)->NewGlobalRef(env, cls));
 
-    midAudioOpen = (*mEnv)->GetStaticMethodID(mEnv, mAudioManagerClass,
+    midAudioOpen = (*env)->GetStaticMethodID(env, mAudioManagerClass,
                                 "audioOpen", "(IIII)[I");
-    midAudioWriteByteBuffer = (*mEnv)->GetStaticMethodID(mEnv, mAudioManagerClass,
+    midAudioWriteByteBuffer = (*env)->GetStaticMethodID(env, mAudioManagerClass,
                                 "audioWriteByteBuffer", "([B)V");
-    midAudioWriteShortBuffer = (*mEnv)->GetStaticMethodID(mEnv, mAudioManagerClass,
+    midAudioWriteShortBuffer = (*env)->GetStaticMethodID(env, mAudioManagerClass,
                                 "audioWriteShortBuffer", "([S)V");
-    midAudioWriteFloatBuffer = (*mEnv)->GetStaticMethodID(mEnv, mAudioManagerClass,
+    midAudioWriteFloatBuffer = (*env)->GetStaticMethodID(env, mAudioManagerClass,
                                 "audioWriteFloatBuffer", "([F)V");
-    midAudioClose = (*mEnv)->GetStaticMethodID(mEnv, mAudioManagerClass,
+    midAudioClose = (*env)->GetStaticMethodID(env, mAudioManagerClass,
                                 "audioClose", "()V");
-    midCaptureOpen = (*mEnv)->GetStaticMethodID(mEnv, mAudioManagerClass,
+    midCaptureOpen = (*env)->GetStaticMethodID(env, mAudioManagerClass,
                                 "captureOpen", "(IIII)[I");
-    midCaptureReadByteBuffer = (*mEnv)->GetStaticMethodID(mEnv, mAudioManagerClass,
+    midCaptureReadByteBuffer = (*env)->GetStaticMethodID(env, mAudioManagerClass,
                                 "captureReadByteBuffer", "([BZ)I");
-    midCaptureReadShortBuffer = (*mEnv)->GetStaticMethodID(mEnv, mAudioManagerClass,
+    midCaptureReadShortBuffer = (*env)->GetStaticMethodID(env, mAudioManagerClass,
                                 "captureReadShortBuffer", "([SZ)I");
-    midCaptureReadFloatBuffer = (*mEnv)->GetStaticMethodID(mEnv, mAudioManagerClass,
+    midCaptureReadFloatBuffer = (*env)->GetStaticMethodID(env, mAudioManagerClass,
                                 "captureReadFloatBuffer", "([FZ)I");
-    midCaptureClose = (*mEnv)->GetStaticMethodID(mEnv, mAudioManagerClass,
+    midCaptureClose = (*env)->GetStaticMethodID(env, mAudioManagerClass,
                                 "captureClose", "()V");
-    midAudioSetThreadPriority = (*mEnv)->GetStaticMethodID(mEnv, mAudioManagerClass,
+    midAudioSetThreadPriority = (*env)->GetStaticMethodID(env, mAudioManagerClass,
                                 "audioSetThreadPriority", "(ZI)V");
 
     if (!midAudioOpen || !midAudioWriteByteBuffer || !midAudioWriteShortBuffer || !midAudioWriteFloatBuffer || !midAudioClose ||
@@ -480,21 +480,21 @@ JNIEXPORT void JNICALL SDL_JAVA_AUDIO_INTERFACE(nativeSetupJNI)(JNIEnv *mEnv, jc
 }
 
 /* Controller initialization -- called before SDL_main() to initialize JNI bindings */
-JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeSetupJNI)(JNIEnv *mEnv, jclass cls)
+JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeSetupJNI)(JNIEnv *env, jclass cls)
 {
     __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "CONTROLLER nativeSetupJNI()");
 
     Android_JNI_SetupThread();
 
-    mControllerManagerClass = (jclass)((*mEnv)->NewGlobalRef(mEnv, cls));
+    mControllerManagerClass = (jclass)((*env)->NewGlobalRef(env, cls));
 
-    midPollInputDevices = (*mEnv)->GetStaticMethodID(mEnv, mControllerManagerClass,
+    midPollInputDevices = (*env)->GetStaticMethodID(env, mControllerManagerClass,
                                 "pollInputDevices", "()V");
-    midPollHapticDevices = (*mEnv)->GetStaticMethodID(mEnv, mControllerManagerClass,
+    midPollHapticDevices = (*env)->GetStaticMethodID(env, mControllerManagerClass,
                                 "pollHapticDevices", "()V");
-    midHapticRun = (*mEnv)->GetStaticMethodID(mEnv, mControllerManagerClass,
+    midHapticRun = (*env)->GetStaticMethodID(env, mControllerManagerClass,
                                 "hapticRun", "(IFI)V");
-    midHapticStop = (*mEnv)->GetStaticMethodID(mEnv, mControllerManagerClass,
+    midHapticStop = (*env)->GetStaticMethodID(env, mControllerManagerClass,
                                 "hapticStop", "(I)V");
 
     if (!midPollInputDevices || !midPollHapticDevices || !midHapticRun || !midHapticStop) {
@@ -1087,7 +1087,7 @@ ANativeWindow* Android_JNI_GetNativeWindow(void)
 
 void Android_JNI_SetSurfaceViewFormat(int format)
 {
-    JNIEnv *mEnv = Android_JNI_GetEnv();
+    JNIEnv *env = Android_JNI_GetEnv();
     int new_format = 0;
 
     /* Format from android/native_window.h,
@@ -1102,31 +1102,31 @@ void Android_JNI_SetSurfaceViewFormat(int format)
         new_format = 0;
     }
 
-    (*mEnv)->CallStaticVoidMethod(mEnv, mActivityClass, midSetSurfaceViewFormat, new_format);
+    (*env)->CallStaticVoidMethod(env, mActivityClass, midSetSurfaceViewFormat, new_format);
 }
 
 void Android_JNI_SetActivityTitle(const char *title)
 {
-    JNIEnv *mEnv = Android_JNI_GetEnv();
+    JNIEnv *env = Android_JNI_GetEnv();
 
-    jstring jtitle = (jstring)((*mEnv)->NewStringUTF(mEnv, title));
-    (*mEnv)->CallStaticBooleanMethod(mEnv, mActivityClass, midSetActivityTitle, jtitle);
-    (*mEnv)->DeleteLocalRef(mEnv, jtitle);
+    jstring jtitle = (jstring)((*env)->NewStringUTF(env, title));
+    (*env)->CallStaticBooleanMethod(env, mActivityClass, midSetActivityTitle, jtitle);
+    (*env)->DeleteLocalRef(env, jtitle);
 }
 
 void Android_JNI_SetWindowStyle(SDL_bool fullscreen)
 {
-    JNIEnv *mEnv = Android_JNI_GetEnv();
-    (*mEnv)->CallStaticVoidMethod(mEnv, mActivityClass, midSetWindowStyle, fullscreen ? 1 : 0);
+    JNIEnv *env = Android_JNI_GetEnv();
+    (*env)->CallStaticVoidMethod(env, mActivityClass, midSetWindowStyle, fullscreen ? 1 : 0);
 }
 
 void Android_JNI_SetOrientation(int w, int h, int resizable, const char *hint)
 {
-    JNIEnv *mEnv = Android_JNI_GetEnv();
+    JNIEnv *env = Android_JNI_GetEnv();
 
-    jstring jhint = (jstring)((*mEnv)->NewStringUTF(mEnv, (hint ? hint : "")));
-    (*mEnv)->CallStaticVoidMethod(mEnv, mActivityClass, midSetOrientation, w, h, (resizable? 1 : 0), jhint);
-    (*mEnv)->DeleteLocalRef(mEnv, jhint);
+    jstring jhint = (jstring)((*env)->NewStringUTF(env, (hint ? hint : "")));
+    (*env)->CallStaticVoidMethod(env, mActivityClass, midSetOrientation, w, h, (resizable? 1 : 0), jhint);
+    (*env)->DeleteLocalRef(env, jhint);
 }
 
 SDL_bool Android_JNI_GetAccelerometerValues(float values[3])
@@ -1522,42 +1522,42 @@ void Android_JNI_AudioSetThreadPriority(int iscapture, int device_id)
 /* If the parameter silent is truthy then SDL_SetError() will not be called. */
 static SDL_bool Android_JNI_ExceptionOccurred(SDL_bool silent)
 {
-    JNIEnv *mEnv = Android_JNI_GetEnv();
+    JNIEnv *env = Android_JNI_GetEnv();
     jthrowable exception;
 
     /* Detect mismatch LocalReferenceHolder_Init/Cleanup */
     SDL_assert((s_active > 0));
 
-    exception = (*mEnv)->ExceptionOccurred(mEnv);
+    exception = (*env)->ExceptionOccurred(env);
     if (exception != NULL) {
         jmethodID mid;
 
         /* Until this happens most JNI operations have undefined behaviour */
-        (*mEnv)->ExceptionClear(mEnv);
+        (*env)->ExceptionClear(env);
 
         if (!silent) {
-            jclass exceptionClass = (*mEnv)->GetObjectClass(mEnv, exception);
-            jclass classClass = (*mEnv)->FindClass(mEnv, "java/lang/Class");
+            jclass exceptionClass = (*env)->GetObjectClass(env, exception);
+            jclass classClass = (*env)->FindClass(env, "java/lang/Class");
             jstring exceptionName;
             const char *exceptionNameUTF8;
             jstring exceptionMessage;
 
-            mid = (*mEnv)->GetMethodID(mEnv, classClass, "getName", "()Ljava/lang/String;");
-            exceptionName = (jstring)(*mEnv)->CallObjectMethod(mEnv, exceptionClass, mid);
-            exceptionNameUTF8 = (*mEnv)->GetStringUTFChars(mEnv, exceptionName, 0);
+            mid = (*env)->GetMethodID(env, classClass, "getName", "()Ljava/lang/String;");
+            exceptionName = (jstring)(*env)->CallObjectMethod(env, exceptionClass, mid);
+            exceptionNameUTF8 = (*env)->GetStringUTFChars(env, exceptionName, 0);
 
-            mid = (*mEnv)->GetMethodID(mEnv, exceptionClass, "getMessage", "()Ljava/lang/String;");
-            exceptionMessage = (jstring)(*mEnv)->CallObjectMethod(mEnv, exception, mid);
+            mid = (*env)->GetMethodID(env, exceptionClass, "getMessage", "()Ljava/lang/String;");
+            exceptionMessage = (jstring)(*env)->CallObjectMethod(env, exception, mid);
 
             if (exceptionMessage != NULL) {
-                const char *exceptionMessageUTF8 = (*mEnv)->GetStringUTFChars(mEnv, exceptionMessage, 0);
+                const char *exceptionMessageUTF8 = (*env)->GetStringUTFChars(env, exceptionMessage, 0);
                 SDL_SetError("%s: %s", exceptionNameUTF8, exceptionMessageUTF8);
-                (*mEnv)->ReleaseStringUTFChars(mEnv, exceptionMessage, exceptionMessageUTF8);
+                (*env)->ReleaseStringUTFChars(env, exceptionMessage, exceptionMessageUTF8);
             } else {
                 SDL_SetError("%s", exceptionNameUTF8);
             }
 
-            (*mEnv)->ReleaseStringUTFChars(mEnv, exceptionName, exceptionNameUTF8);
+            (*env)->ReleaseStringUTFChars(env, exceptionName, exceptionNameUTF8);
         }
 
         return SDL_TRUE;
@@ -1583,8 +1583,8 @@ static int Internal_Android_JNI_FileOpen(SDL_RWops *ctx)
     jclass fdCls;
     jfieldID descriptor;
 
-    JNIEnv *mEnv = Android_JNI_GetEnv();
-    if (!LocalReferenceHolder_Init(&refs, mEnv)) {
+    JNIEnv *env = Android_JNI_GetEnv();
+    if (!LocalReferenceHolder_Init(&refs, env)) {
         goto failure;
     }
 
@@ -1592,40 +1592,40 @@ static int Internal_Android_JNI_FileOpen(SDL_RWops *ctx)
     ctx->hidden.androidio.position = 0;
 
     /* context = SDLActivity.getContext(); */
-    context = (*mEnv)->CallStaticObjectMethod(mEnv, mActivityClass, midGetContext);
+    context = (*env)->CallStaticObjectMethod(env, mActivityClass, midGetContext);
 
     /* assetManager = context.getAssets(); */
-    mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, context),
+    mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, context),
             "getAssets", "()Landroid/content/res/AssetManager;");
-    assetManager = (*mEnv)->CallObjectMethod(mEnv, context, mid);
+    assetManager = (*env)->CallObjectMethod(env, context, mid);
 
     /* First let's try opening the file to obtain an AssetFileDescriptor.
     * This method reads the files directly from the APKs using standard *nix calls
     */
-    mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, assetManager), "openFd", "(Ljava/lang/String;)Landroid/content/res/AssetFileDescriptor;");
-    inputStream = (*mEnv)->CallObjectMethod(mEnv, assetManager, mid, fileNameJString);
+    mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, assetManager), "openFd", "(Ljava/lang/String;)Landroid/content/res/AssetFileDescriptor;");
+    inputStream = (*env)->CallObjectMethod(env, assetManager, mid, fileNameJString);
     if (Android_JNI_ExceptionOccurred(SDL_TRUE)) {
         goto fallback;
     }
 
-    mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, inputStream), "getStartOffset", "()J");
-    ctx->hidden.androidio.offset = (long)(*mEnv)->CallLongMethod(mEnv, inputStream, mid);
+    mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, inputStream), "getStartOffset", "()J");
+    ctx->hidden.androidio.offset = (long)(*env)->CallLongMethod(env, inputStream, mid);
     if (Android_JNI_ExceptionOccurred(SDL_TRUE)) {
         goto fallback;
     }
 
-    mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, inputStream), "getDeclaredLength", "()J");
-    ctx->hidden.androidio.size = (long)(*mEnv)->CallLongMethod(mEnv, inputStream, mid);
+    mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, inputStream), "getDeclaredLength", "()J");
+    ctx->hidden.androidio.size = (long)(*env)->CallLongMethod(env, inputStream, mid);
     if (Android_JNI_ExceptionOccurred(SDL_TRUE)) {
         goto fallback;
     }
 
-    mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, inputStream), "getFileDescriptor", "()Ljava/io/FileDescriptor;");
-    fd = (*mEnv)->CallObjectMethod(mEnv, inputStream, mid);
-    fdCls = (*mEnv)->GetObjectClass(mEnv, fd);
-    descriptor = (*mEnv)->GetFieldID(mEnv, fdCls, "descriptor", "I");
-    ctx->hidden.androidio.fd = (*mEnv)->GetIntField(mEnv, fd, descriptor);
-    ctx->hidden.androidio.assetFileDescriptorRef = (*mEnv)->NewGlobalRef(mEnv, inputStream);
+    mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, inputStream), "getFileDescriptor", "()Ljava/io/FileDescriptor;");
+    fd = (*env)->CallObjectMethod(env, inputStream, mid);
+    fdCls = (*env)->GetObjectClass(env, fd);
+    descriptor = (*env)->GetFieldID(env, fdCls, "descriptor", "I");
+    ctx->hidden.androidio.fd = (*env)->GetIntField(env, fd, descriptor);
+    ctx->hidden.androidio.assetFileDescriptorRef = (*env)->NewGlobalRef(env, inputStream);
 
     /* Seek to the correct offset in the file. */
     lseek(ctx->hidden.androidio.fd, (off_t)ctx->hidden.androidio.offset, SEEK_SET);
@@ -1639,12 +1639,12 @@ fallback:
         ctx->hidden.androidio.assetFileDescriptorRef = NULL;
 
         /* inputStream = assetManager.open(<filename>); */
-        mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, assetManager),
+        mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, assetManager),
                 "open", "(Ljava/lang/String;I)Ljava/io/InputStream;");
-        inputStream = (*mEnv)->CallObjectMethod(mEnv, assetManager, mid, fileNameJString, 1 /* ACCESS_RANDOM */);
+        inputStream = (*env)->CallObjectMethod(env, assetManager, mid, fileNameJString, 1 /* ACCESS_RANDOM */);
         if (Android_JNI_ExceptionOccurred(SDL_FALSE)) {
             /* Try fallback to APK expansion files */
-            inputStream = (*mEnv)->CallStaticObjectMethod(mEnv, mActivityClass, midOpenAPKExpansionInputStream, fileNameJString);
+            inputStream = (*env)->CallStaticObjectMethod(env, mActivityClass, midOpenAPKExpansionInputStream, fileNameJString);
 
             /* Exception is checked first because it always needs to be cleared.
              * If no exception occurred then the last SDL error message is kept.
@@ -1654,7 +1654,7 @@ fallback:
             }
         }
 
-        ctx->hidden.androidio.inputStreamRef = (*mEnv)->NewGlobalRef(mEnv, inputStream);
+        ctx->hidden.androidio.inputStreamRef = (*env)->NewGlobalRef(env, inputStream);
 
         /* Despite all the visible documentation on [Asset]InputStream claiming
          * that the .available() method is not guaranteed to return the entire file
@@ -1664,29 +1664,29 @@ fallback:
         */
 
         /* size = inputStream.available(); */
-        mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, inputStream),
+        mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, inputStream),
                 "available", "()I");
-        ctx->hidden.androidio.size = (long)(*mEnv)->CallIntMethod(mEnv, inputStream, mid);
+        ctx->hidden.androidio.size = (long)(*env)->CallIntMethod(env, inputStream, mid);
         if (Android_JNI_ExceptionOccurred(SDL_FALSE)) {
             goto failure;
         }
 
         /* readableByteChannel = Channels.newChannel(inputStream); */
-        channels = (*mEnv)->FindClass(mEnv, "java/nio/channels/Channels");
-        mid = (*mEnv)->GetStaticMethodID(mEnv, channels,
+        channels = (*env)->FindClass(env, "java/nio/channels/Channels");
+        mid = (*env)->GetStaticMethodID(env, channels,
                 "newChannel",
                 "(Ljava/io/InputStream;)Ljava/nio/channels/ReadableByteChannel;");
-        readableByteChannel = (*mEnv)->CallStaticObjectMethod(
-                mEnv, channels, mid, inputStream);
+        readableByteChannel = (*env)->CallStaticObjectMethod(
+                env, channels, mid, inputStream);
         if (Android_JNI_ExceptionOccurred(SDL_FALSE)) {
             goto failure;
         }
 
         ctx->hidden.androidio.readableByteChannelRef =
-            (*mEnv)->NewGlobalRef(mEnv, readableByteChannel);
+            (*env)->NewGlobalRef(env, readableByteChannel);
 
         /* Store .read id for reading purposes */
-        mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, readableByteChannel),
+        mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, readableByteChannel),
                 "read", "(Ljava/nio/ByteBuffer;)I");
         ctx->hidden.androidio.readMethod = mid;
     }
@@ -1695,18 +1695,18 @@ fallback:
 failure:
         result = -1;
 
-        (*mEnv)->DeleteGlobalRef(mEnv, (jobject)ctx->hidden.androidio.fileNameRef);
+        (*env)->DeleteGlobalRef(env, (jobject)ctx->hidden.androidio.fileNameRef);
 
         if(ctx->hidden.androidio.inputStreamRef != NULL) {
-            (*mEnv)->DeleteGlobalRef(mEnv, (jobject)ctx->hidden.androidio.inputStreamRef);
+            (*env)->DeleteGlobalRef(env, (jobject)ctx->hidden.androidio.inputStreamRef);
         }
 
         if(ctx->hidden.androidio.readableByteChannelRef != NULL) {
-            (*mEnv)->DeleteGlobalRef(mEnv, (jobject)ctx->hidden.androidio.readableByteChannelRef);
+            (*env)->DeleteGlobalRef(env, (jobject)ctx->hidden.androidio.readableByteChannelRef);
         }
 
         if(ctx->hidden.androidio.assetFileDescriptorRef != NULL) {
-            (*mEnv)->DeleteGlobalRef(mEnv, (jobject)ctx->hidden.androidio.assetFileDescriptorRef);
+            (*env)->DeleteGlobalRef(env, (jobject)ctx->hidden.androidio.assetFileDescriptorRef);
         }
 
     }
@@ -1719,11 +1719,11 @@ int Android_JNI_FileOpen(SDL_RWops *ctx,
         const char *fileName, const char *mode)
 {
     struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__);
-    JNIEnv *mEnv = Android_JNI_GetEnv();
+    JNIEnv *env = Android_JNI_GetEnv();
     int retval;
     jstring fileNameJString;
 
-    if (!LocalReferenceHolder_Init(&refs, mEnv)) {
+    if (!LocalReferenceHolder_Init(&refs, env)) {
         LocalReferenceHolder_Cleanup(&refs);
         return -1;
     }
@@ -1733,8 +1733,8 @@ int Android_JNI_FileOpen(SDL_RWops *ctx,
         return -1;
     }
 
-    fileNameJString = (*mEnv)->NewStringUTF(mEnv, fileName);
-    ctx->hidden.androidio.fileNameRef = (*mEnv)->NewGlobalRef(mEnv, fileNameJString);
+    fileNameJString = (*env)->NewStringUTF(env, fileName);
+    ctx->hidden.androidio.fileNameRef = (*env)->NewGlobalRef(env, fileNameJString);
     ctx->hidden.androidio.inputStreamRef = NULL;
     ctx->hidden.androidio.readableByteChannelRef = NULL;
     ctx->hidden.androidio.readMethod = NULL;
@@ -1768,7 +1768,7 @@ size_t Android_JNI_FileRead(SDL_RWops *ctx, void *buffer,
         jlong bytesRemaining = (jlong) (size * maxnum);
         jlong bytesMax = (jlong) (ctx->hidden.androidio.size -  ctx->hidden.androidio.position);
         int bytesRead = 0;
-        JNIEnv *mEnv;
+        JNIEnv *env;
         jobject readableByteChannel;
         jmethodID readMethod;
         jobject byteBuffer;
@@ -1776,19 +1776,19 @@ size_t Android_JNI_FileRead(SDL_RWops *ctx, void *buffer,
         /* Don't read more bytes than those that remain in the file, otherwise we get an exception */
         if (bytesRemaining >  bytesMax) bytesRemaining = bytesMax;
 
-        mEnv = Android_JNI_GetEnv();
-        if (!LocalReferenceHolder_Init(&refs, mEnv)) {
+        env = Android_JNI_GetEnv();
+        if (!LocalReferenceHolder_Init(&refs, env)) {
             LocalReferenceHolder_Cleanup(&refs);
             return 0;
         }
 
         readableByteChannel = (jobject)ctx->hidden.androidio.readableByteChannelRef;
         readMethod = (jmethodID)ctx->hidden.androidio.readMethod;
-        byteBuffer = (*mEnv)->NewDirectByteBuffer(mEnv, buffer, bytesRemaining);
+        byteBuffer = (*env)->NewDirectByteBuffer(env, buffer, bytesRemaining);
 
         while (bytesRemaining > 0) {
             /* result = readableByteChannel.read(...); */
-            int result = (*mEnv)->CallIntMethod(mEnv, readableByteChannel, readMethod, byteBuffer);
+            int result = (*env)->CallIntMethod(env, readableByteChannel, readMethod, byteBuffer);
 
             if (Android_JNI_ExceptionOccurred(SDL_FALSE)) {
                 LocalReferenceHolder_Cleanup(&refs);
@@ -1820,24 +1820,24 @@ static int Internal_Android_JNI_FileClose(SDL_RWops *ctx, SDL_bool release)
     struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__);
 
     int result = 0;
-    JNIEnv *mEnv = Android_JNI_GetEnv();
+    JNIEnv *env = Android_JNI_GetEnv();
 
-    if (!LocalReferenceHolder_Init(&refs, mEnv)) {
+    if (!LocalReferenceHolder_Init(&refs, env)) {
         LocalReferenceHolder_Cleanup(&refs);
         return SDL_SetError("Failed to allocate enough JVM local references");
     }
 
     if (ctx) {
         if (release) {
-            (*mEnv)->DeleteGlobalRef(mEnv, (jobject)ctx->hidden.androidio.fileNameRef);
+            (*env)->DeleteGlobalRef(env, (jobject)ctx->hidden.androidio.fileNameRef);
         }
 
         if (ctx->hidden.androidio.assetFileDescriptorRef) {
             jobject inputStream = (jobject)ctx->hidden.androidio.assetFileDescriptorRef;
-            jmethodID mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, inputStream),
+            jmethodID mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, inputStream),
                     "close", "()V");
-            (*mEnv)->CallVoidMethod(mEnv, inputStream, mid);
-            (*mEnv)->DeleteGlobalRef(mEnv, (jobject)ctx->hidden.androidio.assetFileDescriptorRef);
+            (*env)->CallVoidMethod(env, inputStream, mid);
+            (*env)->DeleteGlobalRef(env, (jobject)ctx->hidden.androidio.assetFileDescriptorRef);
             if (Android_JNI_ExceptionOccurred(SDL_FALSE)) {
                 result = -1;
             }
@@ -1846,11 +1846,11 @@ static int Internal_Android_JNI_FileClose(SDL_RWops *ctx, SDL_bool release)
             jobject inputStream = (jobject)ctx->hidden.androidio.inputStreamRef;
 
             /* inputStream.close(); */
-            jmethodID mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, inputStream),
+            jmethodID mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, inputStream),
                     "close", "()V");
-            (*mEnv)->CallVoidMethod(mEnv, inputStream, mid);
-            (*mEnv)->DeleteGlobalRef(mEnv, (jobject)ctx->hidden.androidio.inputStreamRef);
-            (*mEnv)->DeleteGlobalRef(mEnv, (jobject)ctx->hidden.androidio.readableByteChannelRef);
+            (*env)->CallVoidMethod(env, inputStream, mid);
+            (*env)->DeleteGlobalRef(env, (jobject)ctx->hidden.androidio.inputStreamRef);
+            (*env)->DeleteGlobalRef(env, (jobject)ctx->hidden.androidio.readableByteChannelRef);
             if (Android_JNI_ExceptionOccurred(SDL_FALSE)) {
                 result = -1;
             }
@@ -2189,9 +2189,9 @@ void Android_JNI_HideTextInput(void)
 
 SDL_bool Android_JNI_IsScreenKeyboardShown()
 {
-    JNIEnv *mEnv = Android_JNI_GetEnv();
+    JNIEnv *env = Android_JNI_GetEnv();
     jboolean is_shown = 0;
-    is_shown = (*mEnv)->CallStaticBooleanMethod(mEnv, mActivityClass, midIsScreenKeyboardShown);
+    is_shown = (*env)->CallStaticBooleanMethod(env, mActivityClass, midIsScreenKeyboardShown);
     return is_shown;
 }
 
@@ -2492,14 +2492,14 @@ void Android_JNI_GetManifestEnvironmentVariables(void)
 
 int Android_JNI_CreateCustomCursor(SDL_Surface *surface, int hot_x, int hot_y)
 {
-    JNIEnv *mEnv = Android_JNI_GetEnv();
+    JNIEnv *env = Android_JNI_GetEnv();
     int custom_cursor = 0;
     jintArray pixels;
-    pixels = (*mEnv)->NewIntArray(mEnv, surface->w * surface->h);
+    pixels = (*env)->NewIntArray(env, surface->w * surface->h);
     if (pixels) {
-        (*mEnv)->SetIntArrayRegion(mEnv, pixels, 0, surface->w * surface->h, (int *)surface->pixels);
-        custom_cursor = (*mEnv)->CallStaticIntMethod(mEnv, mActivityClass, midCreateCustomCursor, pixels, surface->w, surface->h, hot_x, hot_y);
-        (*mEnv)->DeleteLocalRef(mEnv, pixels);
+        (*env)->SetIntArrayRegion(env, pixels, 0, surface->w * surface->h, (int *)surface->pixels);
+        custom_cursor = (*env)->CallStaticIntMethod(env, mActivityClass, midCreateCustomCursor, pixels, surface->w, surface->h, hot_x, hot_y);
+        (*env)->DeleteLocalRef(env, pixels);
     } else {
         SDL_OutOfMemory();
     }
@@ -2509,26 +2509,26 @@ int Android_JNI_CreateCustomCursor(SDL_Surface *surface, int hot_x, int hot_y)
 
 SDL_bool Android_JNI_SetCustomCursor(int cursorID)
 {
-    JNIEnv *mEnv = Android_JNI_GetEnv();
-    return (*mEnv)->CallStaticBooleanMethod(mEnv, mActivityClass, midSetCustomCursor, cursorID);
+    JNIEnv *env = Android_JNI_GetEnv();
+    return (*env)->CallStaticBooleanMethod(env, mActivityClass, midSetCustomCursor, cursorID);
 }
 
 SDL_bool Android_JNI_SetSystemCursor(int cursorID)
 {
-    JNIEnv *mEnv = Android_JNI_GetEnv();
-    return (*mEnv)->CallStaticBooleanMethod(mEnv, mActivityClass, midSetSystemCursor, cursorID);
+    JNIEnv *env = Android_JNI_GetEnv();
+    return (*env)->CallStaticBooleanMethod(env, mActivityClass, midSetSystemCursor, cursorID);
 }
 
 SDL_bool Android_JNI_SupportsRelativeMouse()
 {
-    JNIEnv *mEnv = Android_JNI_GetEnv();
-    return (*mEnv)->CallStaticBooleanMethod(mEnv, mActivityClass, midSupportsRelativeMouse);
+    JNIEnv *env = Android_JNI_GetEnv();
+    return (*env)->CallStaticBooleanMethod(env, mActivityClass, midSupportsRelativeMouse);
 }
 
 SDL_bool Android_JNI_SetRelativeMouseEnabled(SDL_bool enabled)
 {
-    JNIEnv *mEnv = Android_JNI_GetEnv();
-    return (*mEnv)->CallStaticBooleanMethod(mEnv, mActivityClass, midSetRelativeMouseEnabled, (enabled == 1));
+    JNIEnv *env = Android_JNI_GetEnv();
+    return (*env)->CallStaticBooleanMethod(env, mActivityClass, midSetRelativeMouseEnabled, (enabled == 1));
 }