Merge "Fix SurfaceControl.setDisplaySurface() such that it accepts a null Surface" into jb-mr2-dev
diff --git a/api/current.txt b/api/current.txt
index b510704..86353d1 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -15849,7 +15849,7 @@
     field public static final int ICE_CREAM_SANDWICH_MR1 = 15; // 0xf
     field public static final int JELLY_BEAN = 16; // 0x10
     field public static final int JELLY_BEAN_MR1 = 17; // 0x11
-    field public static final int K = 10000; // 0x2710
+    field public static final int JELLY_BEAN_MR2 = 10000; // 0x2710
   }
 
   public final class Bundle implements java.lang.Cloneable android.os.Parcelable {
diff --git a/core/java/android/app/LoadedApk.java b/core/java/android/app/LoadedApk.java
index 0a9ed58..2224490 100644
--- a/core/java/android/app/LoadedApk.java
+++ b/core/java/android/app/LoadedApk.java
@@ -362,7 +362,12 @@
         try {
             pi = pm.getPackageInfo(mPackageName, 0, UserHandle.myUserId());
         } catch (RemoteException e) {
-            throw new AssertionError(e);
+            throw new IllegalStateException("Unable to get package info for "
+                    + mPackageName + "; is system dying?", e);
+        }
+        if (pi == null) {
+            throw new IllegalStateException("Unable to get package info for "
+                    + mPackageName + "; is package not installed?");
         }
         /*
          * Two possible indications that this package could be
diff --git a/core/java/android/net/TrafficStats.java b/core/java/android/net/TrafficStats.java
index a282910..ce1276f 100644
--- a/core/java/android/net/TrafficStats.java
+++ b/core/java/android/net/TrafficStats.java
@@ -429,7 +429,7 @@
      * monotonically since device boot. Statistics are measured at the network
      * layer, so they include both TCP and UDP usage.
      * <p>
-     * Before {@link android.os.Build.VERSION_CODES#K}, this may return
+     * Before {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR2}, this may return
      * {@link #UNSUPPORTED} on devices where statistics aren't available.
      *
      * @see android.os.Process#myUid()
@@ -445,7 +445,7 @@
      * monotonically since device boot. Statistics are measured at the network
      * layer, so they include both TCP and UDP usage.
      * <p>
-     * Before {@link android.os.Build.VERSION_CODES#K}, this may return
+     * Before {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR2}, this may return
      * {@link #UNSUPPORTED} on devices where statistics aren't available.
      *
      * @see android.os.Process#myUid()
@@ -461,7 +461,7 @@
      * monotonically since device boot. Statistics are measured at the network
      * layer, so they include both TCP and UDP usage.
      * <p>
-     * Before {@link android.os.Build.VERSION_CODES#K}, this may return
+     * Before {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR2}, this may return
      * {@link #UNSUPPORTED} on devices where statistics aren't available.
      *
      * @see android.os.Process#myUid()
@@ -477,7 +477,7 @@
      * monotonically since device boot. Statistics are measured at the network
      * layer, so they include both TCP and UDP usage.
      * <p>
-     * Before {@link android.os.Build.VERSION_CODES#K}, this may return
+     * Before {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR2}, this may return
      * {@link #UNSUPPORTED} on devices where statistics aren't available.
      *
      * @see android.os.Process#myUid()
@@ -488,7 +488,7 @@
     }
 
     /**
-     * @deprecated Starting in {@link android.os.Build.VERSION_CODES#K},
+     * @deprecated Starting in {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR2},
      *             transport layer statistics are no longer available, and will
      *             always return {@link #UNSUPPORTED}.
      * @see #getUidTxBytes(int)
@@ -499,7 +499,7 @@
     }
 
     /**
-     * @deprecated Starting in {@link android.os.Build.VERSION_CODES#K},
+     * @deprecated Starting in {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR2},
      *             transport layer statistics are no longer available, and will
      *             always return {@link #UNSUPPORTED}.
      * @see #getUidRxBytes(int)
@@ -510,7 +510,7 @@
     }
 
     /**
-     * @deprecated Starting in {@link android.os.Build.VERSION_CODES#K},
+     * @deprecated Starting in {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR2},
      *             transport layer statistics are no longer available, and will
      *             always return {@link #UNSUPPORTED}.
      * @see #getUidTxBytes(int)
@@ -521,7 +521,7 @@
     }
 
     /**
-     * @deprecated Starting in {@link android.os.Build.VERSION_CODES#K},
+     * @deprecated Starting in {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR2},
      *             transport layer statistics are no longer available, and will
      *             always return {@link #UNSUPPORTED}.
      * @see #getUidRxBytes(int)
@@ -532,7 +532,7 @@
     }
 
     /**
-     * @deprecated Starting in {@link android.os.Build.VERSION_CODES#K},
+     * @deprecated Starting in {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR2},
      *             transport layer statistics are no longer available, and will
      *             always return {@link #UNSUPPORTED}.
      * @see #getUidTxPackets(int)
@@ -543,7 +543,7 @@
     }
 
     /**
-     * @deprecated Starting in {@link android.os.Build.VERSION_CODES#K},
+     * @deprecated Starting in {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR2},
      *             transport layer statistics are no longer available, and will
      *             always return {@link #UNSUPPORTED}.
      * @see #getUidRxPackets(int)
@@ -554,7 +554,7 @@
     }
 
     /**
-     * @deprecated Starting in {@link android.os.Build.VERSION_CODES#K},
+     * @deprecated Starting in {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR2},
      *             transport layer statistics are no longer available, and will
      *             always return {@link #UNSUPPORTED}.
      * @see #getUidTxPackets(int)
@@ -565,7 +565,7 @@
     }
 
     /**
-     * @deprecated Starting in {@link android.os.Build.VERSION_CODES#K},
+     * @deprecated Starting in {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR2},
      *             transport layer statistics are no longer available, and will
      *             always return {@link #UNSUPPORTED}.
      * @see #getUidRxPackets(int)
diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java
index 52c89e8..97ac862 100644
--- a/core/java/android/os/Build.java
+++ b/core/java/android/os/Build.java
@@ -433,9 +433,9 @@
         public static final int JELLY_BEAN_MR1 = 17;
 
         /**
-         * Android X.X: "K".  Just "K"
+         * Android 4.X: Jelly Bean MR2, the revenge of the beans.
          */
-        public static final int K = CUR_DEVELOPMENT;
+        public static final int JELLY_BEAN_MR2 = CUR_DEVELOPMENT;
     }
     
     /** The type of build, like "user" or "eng". */
diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java
index e4a5e7f..51e3e7c 100644
--- a/core/java/android/os/UserManager.java
+++ b/core/java/android/os/UserManager.java
@@ -15,15 +15,15 @@
  */
 package android.os;
 
-import com.android.internal.R;
-
 import android.app.ActivityManagerNative;
 import android.content.Context;
 import android.content.pm.UserInfo;
-import android.graphics.Bitmap;
 import android.content.res.Resources;
+import android.graphics.Bitmap;
 import android.util.Log;
 
+import com.android.internal.R;
+
 import java.util.List;
 
 /**
@@ -71,6 +71,14 @@
      */
     public static final String ALLOW_UNINSTALL_APPS = "uninstall_apps";
 
+    /** @hide *
+     * Key for user restrictions. Specifies if a user is allowed to toggle location sharing.
+     * Type: Boolean
+     * @see #setUserRestrictions(Bundle)
+     * @see #getUserRestrictions()
+     */
+    public static final String ALLOW_CONFIG_LOCATION_ACCESS = "config_location_access";
+
     /** @hide */
     public UserManager(Context context, IUserManager service) {
         mService = service;
@@ -86,11 +94,11 @@
         return getMaxSupportedUsers() > 1;
     }
 
-    /** 
+    /**
      * Returns the user handle for the user that this application is running for.
      * @return the user handle of the user making this call.
      * @hide
-     * */
+     */
     public int getUserHandle() {
         return UserHandle.myUserId();
     }
@@ -197,6 +205,13 @@
         }
     }
 
+    /** @hide */
+    public void setUserRestriction(String key, boolean value, UserHandle userHandle) {
+        Bundle bundle = getUserRestrictions(userHandle);
+        bundle.putBoolean(key, value);
+        setUserRestrictions(bundle, userHandle);
+    }
+
     /**
      * Return the serial number for a user.  This is a device-unique
      * number assigned to that user; if the user is deleted and then a new
@@ -433,4 +448,12 @@
         }
         return -1;
     }
+
+    /**
+     * Returns whether the current user is allow to toggle location sharing settings.
+     * @hide
+     */
+    public boolean isLocationSharingToggleAllowed() {
+        return getUserRestrictions().getBoolean(ALLOW_CONFIG_LOCATION_ACCESS);
+    }
 }
diff --git a/core/java/android/view/HardwareRenderer.java b/core/java/android/view/HardwareRenderer.java
index 7929112..e086f5a 100644
--- a/core/java/android/view/HardwareRenderer.java
+++ b/core/java/android/view/HardwareRenderer.java
@@ -173,6 +173,19 @@
     public static final String DEBUG_SHOW_OVERDRAW_PROPERTY = "debug.hwui.show_overdraw";
 
     /**
+     * Turn on to debug non-rectangular clip operations.
+     *
+     * Possible values:
+     * "hide", to disable this debug mode
+     * "highlight", highlight drawing commands tested against a non-rectangular clip
+     * "stencil", renders the clip region on screen when set
+     *
+     * @hide
+     */
+    public static final String DEBUG_SHOW_NON_RECTANGULAR_CLIP_PROPERTY =
+            "debug.hwui.show_non_rect_clip";
+
+    /**
      * A process can set this flag to false to prevent the use of hardware
      * rendering.
      * 
diff --git a/core/java/android/widget/ListView.java b/core/java/android/widget/ListView.java
index 4436fbb..69e3177 100644
--- a/core/java/android/widget/ListView.java
+++ b/core/java/android/widget/ListView.java
@@ -2429,9 +2429,7 @@
         View selectedView = getSelectedView();
         int selectedPos = mSelectedPosition;
 
-        int nextSelectedPosition = (direction == View.FOCUS_DOWN) ?
-                lookForSelectablePosition(selectedPos + 1, true) :
-                lookForSelectablePosition(selectedPos - 1, false);
+        int nextSelectedPosition = lookForSelectablePositionOnScreen(direction);
         int amountToScroll = amountToScroll(direction, nextSelectedPosition);
 
         // if we are moving focus, we may OVERRIDE the default behavior
@@ -2643,18 +2641,14 @@
         final int listBottom = getHeight() - mListPadding.bottom;
         final int listTop = mListPadding.top;
 
-        int numChildren = getChildCount();
+        final int numChildren = getChildCount();
 
         if (direction == View.FOCUS_DOWN) {
             int indexToMakeVisible = numChildren - 1;
             if (nextSelectedPosition != INVALID_POSITION) {
                 indexToMakeVisible = nextSelectedPosition - mFirstPosition;
             }
-            while (numChildren <= indexToMakeVisible) {
-                // Child to view is not attached yet.
-                addViewBelow(getChildAt(numChildren - 1), mFirstPosition + numChildren - 1);
-                numChildren++;
-            }
+
             final int positionToMakeVisible = mFirstPosition + indexToMakeVisible;
             final View viewToMakeVisible = getChildAt(indexToMakeVisible);
 
@@ -2688,12 +2682,6 @@
             if (nextSelectedPosition != INVALID_POSITION) {
                 indexToMakeVisible = nextSelectedPosition - mFirstPosition;
             }
-            while (indexToMakeVisible < 0) {
-                // Child to view is not attached yet.
-                addViewAbove(getChildAt(0), mFirstPosition);
-                mFirstPosition--;
-                indexToMakeVisible = nextSelectedPosition - mFirstPosition;
-            }
             final int positionToMakeVisible = mFirstPosition + indexToMakeVisible;
             final View viewToMakeVisible = getChildAt(indexToMakeVisible);
             int goalTop = listTop;
diff --git a/core/jni/android_opengl_EGL14.cpp b/core/jni/android_opengl_EGL14.cpp
index 196004a5..664af07 100644
--- a/core/jni/android_opengl_EGL14.cpp
+++ b/core/jni/android_opengl_EGL14.cpp
@@ -155,8 +155,8 @@
 android_eglInitialize
   (JNIEnv *_env, jobject _this, jobject dpy, jintArray major_ref, jint majorOffset, jintArray minor_ref, jint minorOffset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     EGLBoolean _returnValue = (EGLBoolean) 0;
     EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
     EGLint *major_base = (EGLint *) 0;
@@ -261,8 +261,8 @@
 android_eglGetConfigs
   (JNIEnv *_env, jobject _this, jobject dpy, jobjectArray configs_ref, jint configsOffset, jint config_size, jintArray num_config_ref, jint num_configOffset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     EGLBoolean _returnValue = (EGLBoolean) 0;
     EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
     jint _configsRemaining;
@@ -339,8 +339,8 @@
 android_eglChooseConfig
   (JNIEnv *_env, jobject _this, jobject dpy, jintArray attrib_list_ref, jint attrib_listOffset, jobjectArray configs_ref, jint configsOffset, jint config_size, jintArray num_config_ref, jint num_configOffset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     EGLBoolean _returnValue = (EGLBoolean) 0;
     EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
     bool attrib_list_sentinel = false;
@@ -462,8 +462,8 @@
 android_eglGetConfigAttrib
   (JNIEnv *_env, jobject _this, jobject dpy, jobject config, jint attribute, jintArray value_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     EGLBoolean _returnValue = (EGLBoolean) 0;
     EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
     EGLConfig config_native = (EGLConfig) fromEGLHandle(_env, eglconfigGetHandleID, config);
@@ -675,8 +675,8 @@
 android_eglCreatePbufferSurface
   (JNIEnv *_env, jobject _this, jobject dpy, jobject config, jintArray attrib_list_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     EGLSurface _returnValue = (EGLSurface) 0;
     EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
     EGLConfig config_native = (EGLConfig) fromEGLHandle(_env, eglconfigGetHandleID, config);
@@ -761,8 +761,8 @@
 android_eglQuerySurface
   (JNIEnv *_env, jobject _this, jobject dpy, jobject surface, jint attribute, jintArray value_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     EGLBoolean _returnValue = (EGLBoolean) 0;
     EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
     EGLSurface surface_native = (EGLSurface) fromEGLHandle(_env, eglsurfaceGetHandleID, surface);
@@ -854,8 +854,8 @@
 android_eglCreatePbufferFromClientBuffer
   (JNIEnv *_env, jobject _this, jobject dpy, jint buftype, jint buffer, jobject config, jintArray attrib_list_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     EGLSurface _returnValue = (EGLSurface) 0;
     EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
     EGLConfig config_native = (EGLConfig) fromEGLHandle(_env, eglconfigGetHandleID, config);
@@ -981,8 +981,8 @@
 android_eglCreateContext
   (JNIEnv *_env, jobject _this, jobject dpy, jobject config, jobject share_context, jintArray attrib_list_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     EGLContext _returnValue = (EGLContext) 0;
     EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
     EGLConfig config_native = (EGLConfig) fromEGLHandle(_env, eglconfigGetHandleID, config);
@@ -1108,8 +1108,8 @@
 android_eglQueryContext
   (JNIEnv *_env, jobject _this, jobject dpy, jobject ctx, jint attribute, jintArray value_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     EGLBoolean _returnValue = (EGLBoolean) 0;
     EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
     EGLContext ctx_native = (EGLContext) fromEGLHandle(_env, eglcontextGetHandleID, ctx);
diff --git a/core/jni/android_opengl_GLES10.cpp b/core/jni/android_opengl_GLES10.cpp
index 571f579..336c0ec 100644
--- a/core/jni/android_opengl_GLES10.cpp
+++ b/core/jni/android_opengl_GLES10.cpp
@@ -17,27 +17,14 @@
 
 // This source file is automatically generated
 
+#include <GLES/gl.h>
+#include <GLES/glext.h>
+
 #include "jni.h"
 #include "JNIHelp.h"
 #include <android_runtime/AndroidRuntime.h>
 #include <utils/misc.h>
-
 #include <assert.h>
-#include <GLES/gl.h>
-#include <GLES/glext.h>
-
-/* special calls implemented in Android's GLES wrapper used to more
- * efficiently bound-check passed arrays */
-extern "C" {
-GL_API void GL_APIENTRY glColorPointerBounds(GLint size, GLenum type, GLsizei stride,
-        const GLvoid *ptr, GLsizei count);
-GL_API void GL_APIENTRY glNormalPointerBounds(GLenum type, GLsizei stride,
-        const GLvoid *pointer, GLsizei count);
-GL_API void GL_APIENTRY glTexCoordPointerBounds(GLint size, GLenum type,
-        GLsizei stride, const GLvoid *pointer, GLsizei count);
-GL_API void GL_APIENTRY glVertexPointerBounds(GLint size, GLenum type,
-        GLsizei stride, const GLvoid *pointer, GLsizei count);
-}
 
 static int initialized = 0;
 
@@ -50,6 +37,34 @@
 static jfieldID limitID;
 static jfieldID elementSizeShiftID;
 
+
+/* special calls implemented in Android's GLES wrapper used to more
+ * efficiently bound-check passed arrays */
+extern "C" {
+#ifdef GL_VERSION_ES_CM_1_1
+GL_API void GL_APIENTRY glColorPointerBounds(GLint size, GLenum type, GLsizei stride,
+        const GLvoid *ptr, GLsizei count);
+GL_API void GL_APIENTRY glNormalPointerBounds(GLenum type, GLsizei stride,
+        const GLvoid *pointer, GLsizei count);
+GL_API void GL_APIENTRY glTexCoordPointerBounds(GLint size, GLenum type,
+        GLsizei stride, const GLvoid *pointer, GLsizei count);
+GL_API void GL_APIENTRY glVertexPointerBounds(GLint size, GLenum type,
+        GLsizei stride, const GLvoid *pointer, GLsizei count);
+GL_API void GL_APIENTRY glPointSizePointerOESBounds(GLenum type,
+        GLsizei stride, const GLvoid *pointer, GLsizei count);
+GL_API void GL_APIENTRY glMatrixIndexPointerOESBounds(GLint size, GLenum type,
+        GLsizei stride, const GLvoid *pointer, GLsizei count);
+GL_API void GL_APIENTRY glWeightPointerOESBounds(GLint size, GLenum type,
+        GLsizei stride, const GLvoid *pointer, GLsizei count);
+#endif
+#ifdef GL_ES_VERSION_2_0
+static void glVertexAttribPointerBounds(GLuint indx, GLint size, GLenum type,
+        GLboolean normalized, GLsizei stride, const GLvoid *pointer, GLsizei count) {
+    glVertexAttribPointer(indx, size, type, normalized, stride, pointer);
+}
+#endif
+}
+
 /* Cache method IDs each time the class is loaded. */
 
 static void
@@ -105,7 +120,7 @@
 releasePointer(JNIEnv *_env, jarray array, void *data, jboolean commit)
 {
     _env->ReleasePrimitiveArrayCritical(array, data,
-					   commit ? 0 : JNI_ABORT);
+                       commit ? 0 : JNI_ABORT);
 }
 
 static void *
@@ -122,11 +137,183 @@
     return (void*) buf;
 }
 
-static int
-getNumCompressedTextureFormats() {
-    int numCompressedTextureFormats = 0;
-    glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &numCompressedTextureFormats);
-    return numCompressedTextureFormats;
+// --------------------------------------------------------------------------
+
+/*
+ * returns the number of values glGet returns for a given pname.
+ *
+ * The code below is written such that pnames requiring only one values
+ * are the default (and are not explicitely tested for). This makes the
+ * checking code much shorter/readable/efficient.
+ *
+ * This means that unknown pnames (e.g.: extensions) will default to 1. If
+ * that unknown pname needs more than 1 value, then the validation check
+ * is incomplete and the app may crash if it passed the wrong number params.
+ */
+static int getNeededCount(GLint pname) {
+    int needed = 1;
+#ifdef GL_ES_VERSION_2_0
+    // GLES 2.x pnames
+    switch (pname) {
+        case GL_ALIASED_LINE_WIDTH_RANGE:
+        case GL_ALIASED_POINT_SIZE_RANGE:
+            needed = 2;
+            break;
+
+        case GL_BLEND_COLOR:
+        case GL_COLOR_CLEAR_VALUE:
+        case GL_COLOR_WRITEMASK:
+        case GL_SCISSOR_BOX:
+        case GL_VIEWPORT:
+            needed = 4;
+            break;
+
+        case GL_COMPRESSED_TEXTURE_FORMATS:
+            glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &needed);
+            break;
+
+        case GL_SHADER_BINARY_FORMATS:
+            glGetIntegerv(GL_NUM_SHADER_BINARY_FORMATS, &needed);
+            break;
+    }
+#endif
+
+#ifdef GL_VERSION_ES_CM_1_1
+    // GLES 1.x pnames
+    switch (pname) {
+        case GL_ALIASED_LINE_WIDTH_RANGE:
+        case GL_ALIASED_POINT_SIZE_RANGE:
+        case GL_DEPTH_RANGE:
+        case GL_SMOOTH_LINE_WIDTH_RANGE:
+        case GL_SMOOTH_POINT_SIZE_RANGE:
+            needed = 2;
+            break;
+
+        case GL_CURRENT_NORMAL:
+        case GL_POINT_DISTANCE_ATTENUATION:
+            needed = 3;
+            break;
+
+        case GL_COLOR_CLEAR_VALUE:
+        case GL_COLOR_WRITEMASK:
+        case GL_CURRENT_COLOR:
+        case GL_CURRENT_TEXTURE_COORDS:
+        case GL_FOG_COLOR:
+        case GL_LIGHT_MODEL_AMBIENT:
+        case GL_SCISSOR_BOX:
+        case GL_VIEWPORT:
+            needed = 4;
+            break;
+
+        case GL_MODELVIEW_MATRIX:
+        case GL_PROJECTION_MATRIX:
+        case GL_TEXTURE_MATRIX:
+            needed = 16;
+            break;
+
+        case GL_COMPRESSED_TEXTURE_FORMATS:
+            glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &needed);
+            break;
+    }
+#endif
+    return needed;
+}
+
+template <typename JTYPEARRAY, typename CTYPE, void GET(GLenum, CTYPE*)>
+static void
+get
+  (JNIEnv *_env, jobject _this, jint pname, JTYPEARRAY params_ref, jint offset) {
+    jint _exception = 0;
+    const char * _exceptionType;
+    const char * _exceptionMessage;
+    CTYPE *params_base = (CTYPE *) 0;
+    jint _remaining;
+    CTYPE *params = (CTYPE *) 0;
+    int _needed = 0;
+
+    if (!params_ref) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "params == null";
+        goto exit;
+    }
+    if (offset < 0) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "offset < 0";
+        goto exit;
+    }
+    _remaining = _env->GetArrayLength(params_ref) - offset;
+    _needed = getNeededCount(pname);
+    // if we didn't find this pname, we just assume the user passed
+    // an array of the right size -- this might happen with extensions
+    // or if we forget an enum here.
+    if (_remaining < _needed) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "length - offset < needed";
+        goto exit;
+    }
+    params_base = (CTYPE *)
+        _env->GetPrimitiveArrayCritical(params_ref, (jboolean *)0);
+    params = params_base + offset;
+
+    GET(
+        (GLenum)pname,
+        (CTYPE *)params
+    );
+
+exit:
+    if (params_base) {
+        _env->ReleasePrimitiveArrayCritical(params_ref, params_base,
+            _exception ? JNI_ABORT: 0);
+    }
+    if (_exception) {
+        jniThrowException(_env, _exceptionType, _exceptionMessage);
+    }
+}
+
+
+template <typename CTYPE, void GET(GLenum, CTYPE*)>
+static void
+getarray
+  (JNIEnv *_env, jobject _this, jint pname, jobject params_buf) {
+    jint _exception = 0;
+    const char * _exceptionType;
+    const char * _exceptionMessage;
+    jarray _array = (jarray) 0;
+    jint _bufferOffset = (jint) 0;
+    jint _remaining;
+    CTYPE *params = (CTYPE *) 0;
+    int _needed = 0;
+
+    params = (CTYPE *)getPointer(_env, params_buf, &_array, &_remaining, &_bufferOffset);
+    _needed = getNeededCount(pname);
+    // if we didn't find this pname, we just assume the user passed
+    // an array of the right size -- this might happen with extensions
+    // or if we forget an enum here.
+    if (_needed>0 && _remaining < _needed) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "remaining() < needed";
+        goto exit;
+    }
+    if (params == NULL) {
+        char * _paramsBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
+        params = (CTYPE *) (_paramsBase + _bufferOffset);
+    }
+    GET(
+        (GLenum)pname,
+        (CTYPE *)params
+    );
+
+exit:
+    if (_array) {
+        releasePointer(_env, _array, params, _exception ? JNI_FALSE : JNI_TRUE);
+    }
+    if (_exception) {
+        jniThrowException(_env, _exceptionType, _exceptionMessage);
+    }
 }
 
 // --------------------------------------------------------------------------
@@ -413,8 +600,8 @@
 android_glDeleteTextures__I_3II
   (JNIEnv *_env, jobject _this, jint n, jintArray textures_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLuint *textures_base = (GLuint *) 0;
     jint _remaining;
     GLuint *textures = (GLuint *) 0;
@@ -462,8 +649,8 @@
 android_glDeleteTextures__ILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint n, jobject textures_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -566,8 +753,8 @@
 android_glDrawElements__IIILjava_nio_Buffer_2
   (JNIEnv *_env, jobject _this, jint mode, jint count, jint type, jobject indices_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -647,8 +834,8 @@
 android_glFogfv__I_3FI
   (JNIEnv *_env, jobject _this, jint pname, jfloatArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *params_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *params = (GLfloat *) 0;
@@ -668,27 +855,13 @@
     _remaining = _env->GetArrayLength(params_ref) - offset;
     int _needed;
     switch (pname) {
-#if defined(GL_FOG_MODE)
-        case GL_FOG_MODE:
-#endif // defined(GL_FOG_MODE)
-#if defined(GL_FOG_DENSITY)
-        case GL_FOG_DENSITY:
-#endif // defined(GL_FOG_DENSITY)
-#if defined(GL_FOG_START)
-        case GL_FOG_START:
-#endif // defined(GL_FOG_START)
-#if defined(GL_FOG_END)
-        case GL_FOG_END:
-#endif // defined(GL_FOG_END)
-            _needed = 1;
-            break;
 #if defined(GL_FOG_COLOR)
         case GL_FOG_COLOR:
 #endif // defined(GL_FOG_COLOR)
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -721,8 +894,8 @@
 android_glFogfv__ILjava_nio_FloatBuffer_2
   (JNIEnv *_env, jobject _this, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -731,27 +904,13 @@
     params = (GLfloat *)getPointer(_env, params_buf, &_array, &_remaining, &_bufferOffset);
     int _needed;
     switch (pname) {
-#if defined(GL_FOG_MODE)
-        case GL_FOG_MODE:
-#endif // defined(GL_FOG_MODE)
-#if defined(GL_FOG_DENSITY)
-        case GL_FOG_DENSITY:
-#endif // defined(GL_FOG_DENSITY)
-#if defined(GL_FOG_START)
-        case GL_FOG_START:
-#endif // defined(GL_FOG_START)
-#if defined(GL_FOG_END)
-        case GL_FOG_END:
-#endif // defined(GL_FOG_END)
-            _needed = 1;
-            break;
 #if defined(GL_FOG_COLOR)
         case GL_FOG_COLOR:
 #endif // defined(GL_FOG_COLOR)
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -793,8 +952,8 @@
 android_glFogxv__I_3II
   (JNIEnv *_env, jobject _this, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *params_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *params = (GLfixed *) 0;
@@ -814,27 +973,13 @@
     _remaining = _env->GetArrayLength(params_ref) - offset;
     int _needed;
     switch (pname) {
-#if defined(GL_FOG_MODE)
-        case GL_FOG_MODE:
-#endif // defined(GL_FOG_MODE)
-#if defined(GL_FOG_DENSITY)
-        case GL_FOG_DENSITY:
-#endif // defined(GL_FOG_DENSITY)
-#if defined(GL_FOG_START)
-        case GL_FOG_START:
-#endif // defined(GL_FOG_START)
-#if defined(GL_FOG_END)
-        case GL_FOG_END:
-#endif // defined(GL_FOG_END)
-            _needed = 1;
-            break;
 #if defined(GL_FOG_COLOR)
         case GL_FOG_COLOR:
 #endif // defined(GL_FOG_COLOR)
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -867,8 +1012,8 @@
 android_glFogxv__ILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -877,27 +1022,13 @@
     params = (GLfixed *)getPointer(_env, params_buf, &_array, &_remaining, &_bufferOffset);
     int _needed;
     switch (pname) {
-#if defined(GL_FOG_MODE)
-        case GL_FOG_MODE:
-#endif // defined(GL_FOG_MODE)
-#if defined(GL_FOG_DENSITY)
-        case GL_FOG_DENSITY:
-#endif // defined(GL_FOG_DENSITY)
-#if defined(GL_FOG_START)
-        case GL_FOG_START:
-#endif // defined(GL_FOG_START)
-#if defined(GL_FOG_END)
-        case GL_FOG_END:
-#endif // defined(GL_FOG_END)
-            _needed = 1;
-            break;
 #if defined(GL_FOG_COLOR)
         case GL_FOG_COLOR:
 #endif // defined(GL_FOG_COLOR)
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -966,8 +1097,8 @@
 android_glGenTextures__I_3II
   (JNIEnv *_env, jobject _this, jint n, jintArray textures_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLuint *textures_base = (GLuint *) 0;
     jint _remaining;
     GLuint *textures = (GLuint *) 0;
@@ -1015,8 +1146,8 @@
 android_glGenTextures__ILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint n, jobject textures_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -1060,748 +1191,14 @@
 static void
 android_glGetIntegerv__I_3II
   (JNIEnv *_env, jobject _this, jint pname, jintArray params_ref, jint offset) {
-    jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
-    GLint *params_base = (GLint *) 0;
-    jint _remaining;
-    GLint *params = (GLint *) 0;
-
-    if (!params_ref) {
-        _exception = 1;
-        _exceptionType = "java/lang/IllegalArgumentException";
-        _exceptionMessage = "params == null";
-        goto exit;
-    }
-    if (offset < 0) {
-        _exception = 1;
-        _exceptionType = "java/lang/IllegalArgumentException";
-        _exceptionMessage = "offset < 0";
-        goto exit;
-    }
-    _remaining = _env->GetArrayLength(params_ref) - offset;
-    int _needed;
-    switch (pname) {
-#if defined(GL_ALPHA_BITS)
-        case GL_ALPHA_BITS:
-#endif // defined(GL_ALPHA_BITS)
-#if defined(GL_ALPHA_TEST_FUNC)
-        case GL_ALPHA_TEST_FUNC:
-#endif // defined(GL_ALPHA_TEST_FUNC)
-#if defined(GL_ALPHA_TEST_REF)
-        case GL_ALPHA_TEST_REF:
-#endif // defined(GL_ALPHA_TEST_REF)
-#if defined(GL_BLEND_DST)
-        case GL_BLEND_DST:
-#endif // defined(GL_BLEND_DST)
-#if defined(GL_BLUE_BITS)
-        case GL_BLUE_BITS:
-#endif // defined(GL_BLUE_BITS)
-#if defined(GL_COLOR_ARRAY_BUFFER_BINDING)
-        case GL_COLOR_ARRAY_BUFFER_BINDING:
-#endif // defined(GL_COLOR_ARRAY_BUFFER_BINDING)
-#if defined(GL_COLOR_ARRAY_SIZE)
-        case GL_COLOR_ARRAY_SIZE:
-#endif // defined(GL_COLOR_ARRAY_SIZE)
-#if defined(GL_COLOR_ARRAY_STRIDE)
-        case GL_COLOR_ARRAY_STRIDE:
-#endif // defined(GL_COLOR_ARRAY_STRIDE)
-#if defined(GL_COLOR_ARRAY_TYPE)
-        case GL_COLOR_ARRAY_TYPE:
-#endif // defined(GL_COLOR_ARRAY_TYPE)
-#if defined(GL_CULL_FACE)
-        case GL_CULL_FACE:
-#endif // defined(GL_CULL_FACE)
-#if defined(GL_DEPTH_BITS)
-        case GL_DEPTH_BITS:
-#endif // defined(GL_DEPTH_BITS)
-#if defined(GL_DEPTH_CLEAR_VALUE)
-        case GL_DEPTH_CLEAR_VALUE:
-#endif // defined(GL_DEPTH_CLEAR_VALUE)
-#if defined(GL_DEPTH_FUNC)
-        case GL_DEPTH_FUNC:
-#endif // defined(GL_DEPTH_FUNC)
-#if defined(GL_DEPTH_WRITEMASK)
-        case GL_DEPTH_WRITEMASK:
-#endif // defined(GL_DEPTH_WRITEMASK)
-#if defined(GL_FOG_DENSITY)
-        case GL_FOG_DENSITY:
-#endif // defined(GL_FOG_DENSITY)
-#if defined(GL_FOG_END)
-        case GL_FOG_END:
-#endif // defined(GL_FOG_END)
-#if defined(GL_FOG_MODE)
-        case GL_FOG_MODE:
-#endif // defined(GL_FOG_MODE)
-#if defined(GL_FOG_START)
-        case GL_FOG_START:
-#endif // defined(GL_FOG_START)
-#if defined(GL_FRONT_FACE)
-        case GL_FRONT_FACE:
-#endif // defined(GL_FRONT_FACE)
-#if defined(GL_GREEN_BITS)
-        case GL_GREEN_BITS:
-#endif // defined(GL_GREEN_BITS)
-#if defined(GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES)
-        case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES:
-#endif // defined(GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES)
-#if defined(GL_IMPLEMENTATION_COLOR_READ_TYPE_OES)
-        case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES:
-#endif // defined(GL_IMPLEMENTATION_COLOR_READ_TYPE_OES)
-#if defined(GL_LIGHT_MODEL_COLOR_CONTROL)
-        case GL_LIGHT_MODEL_COLOR_CONTROL:
-#endif // defined(GL_LIGHT_MODEL_COLOR_CONTROL)
-#if defined(GL_LIGHT_MODEL_LOCAL_VIEWER)
-        case GL_LIGHT_MODEL_LOCAL_VIEWER:
-#endif // defined(GL_LIGHT_MODEL_LOCAL_VIEWER)
-#if defined(GL_LIGHT_MODEL_TWO_SIDE)
-        case GL_LIGHT_MODEL_TWO_SIDE:
-#endif // defined(GL_LIGHT_MODEL_TWO_SIDE)
-#if defined(GL_LINE_SMOOTH_HINT)
-        case GL_LINE_SMOOTH_HINT:
-#endif // defined(GL_LINE_SMOOTH_HINT)
-#if defined(GL_LINE_WIDTH)
-        case GL_LINE_WIDTH:
-#endif // defined(GL_LINE_WIDTH)
-#if defined(GL_LOGIC_OP_MODE)
-        case GL_LOGIC_OP_MODE:
-#endif // defined(GL_LOGIC_OP_MODE)
-#if defined(GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES)
-        case GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES:
-#endif // defined(GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES)
-#if defined(GL_MATRIX_INDEX_ARRAY_SIZE_OES)
-        case GL_MATRIX_INDEX_ARRAY_SIZE_OES:
-#endif // defined(GL_MATRIX_INDEX_ARRAY_SIZE_OES)
-#if defined(GL_MATRIX_INDEX_ARRAY_STRIDE_OES)
-        case GL_MATRIX_INDEX_ARRAY_STRIDE_OES:
-#endif // defined(GL_MATRIX_INDEX_ARRAY_STRIDE_OES)
-#if defined(GL_MATRIX_INDEX_ARRAY_TYPE_OES)
-        case GL_MATRIX_INDEX_ARRAY_TYPE_OES:
-#endif // defined(GL_MATRIX_INDEX_ARRAY_TYPE_OES)
-#if defined(GL_MATRIX_MODE)
-        case GL_MATRIX_MODE:
-#endif // defined(GL_MATRIX_MODE)
-#if defined(GL_MAX_CLIP_PLANES)
-        case GL_MAX_CLIP_PLANES:
-#endif // defined(GL_MAX_CLIP_PLANES)
-#if defined(GL_MAX_ELEMENTS_INDICES)
-        case GL_MAX_ELEMENTS_INDICES:
-#endif // defined(GL_MAX_ELEMENTS_INDICES)
-#if defined(GL_MAX_ELEMENTS_VERTICES)
-        case GL_MAX_ELEMENTS_VERTICES:
-#endif // defined(GL_MAX_ELEMENTS_VERTICES)
-#if defined(GL_MAX_LIGHTS)
-        case GL_MAX_LIGHTS:
-#endif // defined(GL_MAX_LIGHTS)
-#if defined(GL_MAX_MODELVIEW_STACK_DEPTH)
-        case GL_MAX_MODELVIEW_STACK_DEPTH:
-#endif // defined(GL_MAX_MODELVIEW_STACK_DEPTH)
-#if defined(GL_MAX_PALETTE_MATRICES_OES)
-        case GL_MAX_PALETTE_MATRICES_OES:
-#endif // defined(GL_MAX_PALETTE_MATRICES_OES)
-#if defined(GL_MAX_PROJECTION_STACK_DEPTH)
-        case GL_MAX_PROJECTION_STACK_DEPTH:
-#endif // defined(GL_MAX_PROJECTION_STACK_DEPTH)
-#if defined(GL_MAX_TEXTURE_SIZE)
-        case GL_MAX_TEXTURE_SIZE:
-#endif // defined(GL_MAX_TEXTURE_SIZE)
-#if defined(GL_MAX_TEXTURE_STACK_DEPTH)
-        case GL_MAX_TEXTURE_STACK_DEPTH:
-#endif // defined(GL_MAX_TEXTURE_STACK_DEPTH)
-#if defined(GL_MAX_TEXTURE_UNITS)
-        case GL_MAX_TEXTURE_UNITS:
-#endif // defined(GL_MAX_TEXTURE_UNITS)
-#if defined(GL_MAX_VERTEX_UNITS_OES)
-        case GL_MAX_VERTEX_UNITS_OES:
-#endif // defined(GL_MAX_VERTEX_UNITS_OES)
-#if defined(GL_MODELVIEW_STACK_DEPTH)
-        case GL_MODELVIEW_STACK_DEPTH:
-#endif // defined(GL_MODELVIEW_STACK_DEPTH)
-#if defined(GL_NORMAL_ARRAY_BUFFER_BINDING)
-        case GL_NORMAL_ARRAY_BUFFER_BINDING:
-#endif // defined(GL_NORMAL_ARRAY_BUFFER_BINDING)
-#if defined(GL_NORMAL_ARRAY_STRIDE)
-        case GL_NORMAL_ARRAY_STRIDE:
-#endif // defined(GL_NORMAL_ARRAY_STRIDE)
-#if defined(GL_NORMAL_ARRAY_TYPE)
-        case GL_NORMAL_ARRAY_TYPE:
-#endif // defined(GL_NORMAL_ARRAY_TYPE)
-#if defined(GL_NUM_COMPRESSED_TEXTURE_FORMATS)
-        case GL_NUM_COMPRESSED_TEXTURE_FORMATS:
-#endif // defined(GL_NUM_COMPRESSED_TEXTURE_FORMATS)
-#if defined(GL_PACK_ALIGNMENT)
-        case GL_PACK_ALIGNMENT:
-#endif // defined(GL_PACK_ALIGNMENT)
-#if defined(GL_PERSPECTIVE_CORRECTION_HINT)
-        case GL_PERSPECTIVE_CORRECTION_HINT:
-#endif // defined(GL_PERSPECTIVE_CORRECTION_HINT)
-#if defined(GL_POINT_SIZE)
-        case GL_POINT_SIZE:
-#endif // defined(GL_POINT_SIZE)
-#if defined(GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES)
-        case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES:
-#endif // defined(GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES)
-#if defined(GL_POINT_SIZE_ARRAY_STRIDE_OES)
-        case GL_POINT_SIZE_ARRAY_STRIDE_OES:
-#endif // defined(GL_POINT_SIZE_ARRAY_STRIDE_OES)
-#if defined(GL_POINT_SIZE_ARRAY_TYPE_OES)
-        case GL_POINT_SIZE_ARRAY_TYPE_OES:
-#endif // defined(GL_POINT_SIZE_ARRAY_TYPE_OES)
-#if defined(GL_POINT_SMOOTH_HINT)
-        case GL_POINT_SMOOTH_HINT:
-#endif // defined(GL_POINT_SMOOTH_HINT)
-#if defined(GL_POLYGON_OFFSET_FACTOR)
-        case GL_POLYGON_OFFSET_FACTOR:
-#endif // defined(GL_POLYGON_OFFSET_FACTOR)
-#if defined(GL_POLYGON_OFFSET_UNITS)
-        case GL_POLYGON_OFFSET_UNITS:
-#endif // defined(GL_POLYGON_OFFSET_UNITS)
-#if defined(GL_PROJECTION_STACK_DEPTH)
-        case GL_PROJECTION_STACK_DEPTH:
-#endif // defined(GL_PROJECTION_STACK_DEPTH)
-#if defined(GL_RED_BITS)
-        case GL_RED_BITS:
-#endif // defined(GL_RED_BITS)
-#if defined(GL_SHADE_MODEL)
-        case GL_SHADE_MODEL:
-#endif // defined(GL_SHADE_MODEL)
-#if defined(GL_STENCIL_BITS)
-        case GL_STENCIL_BITS:
-#endif // defined(GL_STENCIL_BITS)
-#if defined(GL_STENCIL_CLEAR_VALUE)
-        case GL_STENCIL_CLEAR_VALUE:
-#endif // defined(GL_STENCIL_CLEAR_VALUE)
-#if defined(GL_STENCIL_FAIL)
-        case GL_STENCIL_FAIL:
-#endif // defined(GL_STENCIL_FAIL)
-#if defined(GL_STENCIL_FUNC)
-        case GL_STENCIL_FUNC:
-#endif // defined(GL_STENCIL_FUNC)
-#if defined(GL_STENCIL_PASS_DEPTH_FAIL)
-        case GL_STENCIL_PASS_DEPTH_FAIL:
-#endif // defined(GL_STENCIL_PASS_DEPTH_FAIL)
-#if defined(GL_STENCIL_PASS_DEPTH_PASS)
-        case GL_STENCIL_PASS_DEPTH_PASS:
-#endif // defined(GL_STENCIL_PASS_DEPTH_PASS)
-#if defined(GL_STENCIL_REF)
-        case GL_STENCIL_REF:
-#endif // defined(GL_STENCIL_REF)
-#if defined(GL_STENCIL_VALUE_MASK)
-        case GL_STENCIL_VALUE_MASK:
-#endif // defined(GL_STENCIL_VALUE_MASK)
-#if defined(GL_STENCIL_WRITEMASK)
-        case GL_STENCIL_WRITEMASK:
-#endif // defined(GL_STENCIL_WRITEMASK)
-#if defined(GL_SUBPIXEL_BITS)
-        case GL_SUBPIXEL_BITS:
-#endif // defined(GL_SUBPIXEL_BITS)
-#if defined(GL_TEXTURE_BINDING_2D)
-        case GL_TEXTURE_BINDING_2D:
-#endif // defined(GL_TEXTURE_BINDING_2D)
-#if defined(GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING)
-        case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING:
-#endif // defined(GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING)
-#if defined(GL_TEXTURE_COORD_ARRAY_SIZE)
-        case GL_TEXTURE_COORD_ARRAY_SIZE:
-#endif // defined(GL_TEXTURE_COORD_ARRAY_SIZE)
-#if defined(GL_TEXTURE_COORD_ARRAY_STRIDE)
-        case GL_TEXTURE_COORD_ARRAY_STRIDE:
-#endif // defined(GL_TEXTURE_COORD_ARRAY_STRIDE)
-#if defined(GL_TEXTURE_COORD_ARRAY_TYPE)
-        case GL_TEXTURE_COORD_ARRAY_TYPE:
-#endif // defined(GL_TEXTURE_COORD_ARRAY_TYPE)
-#if defined(GL_TEXTURE_STACK_DEPTH)
-        case GL_TEXTURE_STACK_DEPTH:
-#endif // defined(GL_TEXTURE_STACK_DEPTH)
-#if defined(GL_UNPACK_ALIGNMENT)
-        case GL_UNPACK_ALIGNMENT:
-#endif // defined(GL_UNPACK_ALIGNMENT)
-#if defined(GL_VERTEX_ARRAY_BUFFER_BINDING)
-        case GL_VERTEX_ARRAY_BUFFER_BINDING:
-#endif // defined(GL_VERTEX_ARRAY_BUFFER_BINDING)
-#if defined(GL_VERTEX_ARRAY_SIZE)
-        case GL_VERTEX_ARRAY_SIZE:
-#endif // defined(GL_VERTEX_ARRAY_SIZE)
-#if defined(GL_VERTEX_ARRAY_STRIDE)
-        case GL_VERTEX_ARRAY_STRIDE:
-#endif // defined(GL_VERTEX_ARRAY_STRIDE)
-#if defined(GL_VERTEX_ARRAY_TYPE)
-        case GL_VERTEX_ARRAY_TYPE:
-#endif // defined(GL_VERTEX_ARRAY_TYPE)
-#if defined(GL_WEIGHT_ARRAY_BUFFER_BINDING_OES)
-        case GL_WEIGHT_ARRAY_BUFFER_BINDING_OES:
-#endif // defined(GL_WEIGHT_ARRAY_BUFFER_BINDING_OES)
-#if defined(GL_WEIGHT_ARRAY_SIZE_OES)
-        case GL_WEIGHT_ARRAY_SIZE_OES:
-#endif // defined(GL_WEIGHT_ARRAY_SIZE_OES)
-#if defined(GL_WEIGHT_ARRAY_STRIDE_OES)
-        case GL_WEIGHT_ARRAY_STRIDE_OES:
-#endif // defined(GL_WEIGHT_ARRAY_STRIDE_OES)
-#if defined(GL_WEIGHT_ARRAY_TYPE_OES)
-        case GL_WEIGHT_ARRAY_TYPE_OES:
-#endif // defined(GL_WEIGHT_ARRAY_TYPE_OES)
-            _needed = 1;
-            break;
-#if defined(GL_ALIASED_POINT_SIZE_RANGE)
-        case GL_ALIASED_POINT_SIZE_RANGE:
-#endif // defined(GL_ALIASED_POINT_SIZE_RANGE)
-#if defined(GL_ALIASED_LINE_WIDTH_RANGE)
-        case GL_ALIASED_LINE_WIDTH_RANGE:
-#endif // defined(GL_ALIASED_LINE_WIDTH_RANGE)
-#if defined(GL_DEPTH_RANGE)
-        case GL_DEPTH_RANGE:
-#endif // defined(GL_DEPTH_RANGE)
-#if defined(GL_MAX_VIEWPORT_DIMS)
-        case GL_MAX_VIEWPORT_DIMS:
-#endif // defined(GL_MAX_VIEWPORT_DIMS)
-#if defined(GL_SMOOTH_LINE_WIDTH_RANGE)
-        case GL_SMOOTH_LINE_WIDTH_RANGE:
-#endif // defined(GL_SMOOTH_LINE_WIDTH_RANGE)
-#if defined(GL_SMOOTH_POINT_SIZE_RANGE)
-        case GL_SMOOTH_POINT_SIZE_RANGE:
-#endif // defined(GL_SMOOTH_POINT_SIZE_RANGE)
-            _needed = 2;
-            break;
-#if defined(GL_COLOR_CLEAR_VALUE)
-        case GL_COLOR_CLEAR_VALUE:
-#endif // defined(GL_COLOR_CLEAR_VALUE)
-#if defined(GL_COLOR_WRITEMASK)
-        case GL_COLOR_WRITEMASK:
-#endif // defined(GL_COLOR_WRITEMASK)
-#if defined(GL_FOG_COLOR)
-        case GL_FOG_COLOR:
-#endif // defined(GL_FOG_COLOR)
-#if defined(GL_LIGHT_MODEL_AMBIENT)
-        case GL_LIGHT_MODEL_AMBIENT:
-#endif // defined(GL_LIGHT_MODEL_AMBIENT)
-#if defined(GL_SCISSOR_BOX)
-        case GL_SCISSOR_BOX:
-#endif // defined(GL_SCISSOR_BOX)
-#if defined(GL_VIEWPORT)
-        case GL_VIEWPORT:
-#endif // defined(GL_VIEWPORT)
-            _needed = 4;
-            break;
-#if defined(GL_MODELVIEW_MATRIX)
-        case GL_MODELVIEW_MATRIX:
-#endif // defined(GL_MODELVIEW_MATRIX)
-#if defined(GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES)
-        case GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES:
-#endif // defined(GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES)
-#if defined(GL_PROJECTION_MATRIX)
-        case GL_PROJECTION_MATRIX:
-#endif // defined(GL_PROJECTION_MATRIX)
-#if defined(GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES)
-        case GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES:
-#endif // defined(GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES)
-#if defined(GL_TEXTURE_MATRIX)
-        case GL_TEXTURE_MATRIX:
-#endif // defined(GL_TEXTURE_MATRIX)
-#if defined(GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES)
-        case GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES:
-#endif // defined(GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES)
-            _needed = 16;
-            break;
-#if defined(GL_COMPRESSED_TEXTURE_FORMATS)
-        case GL_COMPRESSED_TEXTURE_FORMATS:
-#endif // defined(GL_COMPRESSED_TEXTURE_FORMATS)
-            _needed = getNumCompressedTextureFormats();
-            break;
-        default:
-            _needed = 0;
-            break;
-    }
-    if (_remaining < _needed) {
-        _exception = 1;
-        _exceptionType = "java/lang/IllegalArgumentException";
-        _exceptionMessage = "length - offset < needed";
-        goto exit;
-    }
-    params_base = (GLint *)
-        _env->GetPrimitiveArrayCritical(params_ref, (jboolean *)0);
-    params = params_base + offset;
-
-    glGetIntegerv(
-        (GLenum)pname,
-        (GLint *)params
-    );
-
-exit:
-    if (params_base) {
-        _env->ReleasePrimitiveArrayCritical(params_ref, params_base,
-            _exception ? JNI_ABORT: 0);
-    }
-    if (_exception) {
-        jniThrowException(_env, _exceptionType, _exceptionMessage);
-    }
+    get<jintArray, GLint, glGetIntegerv>(_env, _this, pname, params_ref, offset);
 }
 
 /* void glGetIntegerv ( GLenum pname, GLint *params ) */
 static void
 android_glGetIntegerv__ILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint pname, jobject params_buf) {
-    jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
-    jarray _array = (jarray) 0;
-    jint _bufferOffset = (jint) 0;
-    jint _remaining;
-    GLint *params = (GLint *) 0;
-
-    params = (GLint *)getPointer(_env, params_buf, &_array, &_remaining, &_bufferOffset);
-    int _needed;
-    switch (pname) {
-#if defined(GL_ALPHA_BITS)
-        case GL_ALPHA_BITS:
-#endif // defined(GL_ALPHA_BITS)
-#if defined(GL_ALPHA_TEST_FUNC)
-        case GL_ALPHA_TEST_FUNC:
-#endif // defined(GL_ALPHA_TEST_FUNC)
-#if defined(GL_ALPHA_TEST_REF)
-        case GL_ALPHA_TEST_REF:
-#endif // defined(GL_ALPHA_TEST_REF)
-#if defined(GL_BLEND_DST)
-        case GL_BLEND_DST:
-#endif // defined(GL_BLEND_DST)
-#if defined(GL_BLUE_BITS)
-        case GL_BLUE_BITS:
-#endif // defined(GL_BLUE_BITS)
-#if defined(GL_COLOR_ARRAY_BUFFER_BINDING)
-        case GL_COLOR_ARRAY_BUFFER_BINDING:
-#endif // defined(GL_COLOR_ARRAY_BUFFER_BINDING)
-#if defined(GL_COLOR_ARRAY_SIZE)
-        case GL_COLOR_ARRAY_SIZE:
-#endif // defined(GL_COLOR_ARRAY_SIZE)
-#if defined(GL_COLOR_ARRAY_STRIDE)
-        case GL_COLOR_ARRAY_STRIDE:
-#endif // defined(GL_COLOR_ARRAY_STRIDE)
-#if defined(GL_COLOR_ARRAY_TYPE)
-        case GL_COLOR_ARRAY_TYPE:
-#endif // defined(GL_COLOR_ARRAY_TYPE)
-#if defined(GL_CULL_FACE)
-        case GL_CULL_FACE:
-#endif // defined(GL_CULL_FACE)
-#if defined(GL_DEPTH_BITS)
-        case GL_DEPTH_BITS:
-#endif // defined(GL_DEPTH_BITS)
-#if defined(GL_DEPTH_CLEAR_VALUE)
-        case GL_DEPTH_CLEAR_VALUE:
-#endif // defined(GL_DEPTH_CLEAR_VALUE)
-#if defined(GL_DEPTH_FUNC)
-        case GL_DEPTH_FUNC:
-#endif // defined(GL_DEPTH_FUNC)
-#if defined(GL_DEPTH_WRITEMASK)
-        case GL_DEPTH_WRITEMASK:
-#endif // defined(GL_DEPTH_WRITEMASK)
-#if defined(GL_FOG_DENSITY)
-        case GL_FOG_DENSITY:
-#endif // defined(GL_FOG_DENSITY)
-#if defined(GL_FOG_END)
-        case GL_FOG_END:
-#endif // defined(GL_FOG_END)
-#if defined(GL_FOG_MODE)
-        case GL_FOG_MODE:
-#endif // defined(GL_FOG_MODE)
-#if defined(GL_FOG_START)
-        case GL_FOG_START:
-#endif // defined(GL_FOG_START)
-#if defined(GL_FRONT_FACE)
-        case GL_FRONT_FACE:
-#endif // defined(GL_FRONT_FACE)
-#if defined(GL_GREEN_BITS)
-        case GL_GREEN_BITS:
-#endif // defined(GL_GREEN_BITS)
-#if defined(GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES)
-        case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES:
-#endif // defined(GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES)
-#if defined(GL_IMPLEMENTATION_COLOR_READ_TYPE_OES)
-        case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES:
-#endif // defined(GL_IMPLEMENTATION_COLOR_READ_TYPE_OES)
-#if defined(GL_LIGHT_MODEL_COLOR_CONTROL)
-        case GL_LIGHT_MODEL_COLOR_CONTROL:
-#endif // defined(GL_LIGHT_MODEL_COLOR_CONTROL)
-#if defined(GL_LIGHT_MODEL_LOCAL_VIEWER)
-        case GL_LIGHT_MODEL_LOCAL_VIEWER:
-#endif // defined(GL_LIGHT_MODEL_LOCAL_VIEWER)
-#if defined(GL_LIGHT_MODEL_TWO_SIDE)
-        case GL_LIGHT_MODEL_TWO_SIDE:
-#endif // defined(GL_LIGHT_MODEL_TWO_SIDE)
-#if defined(GL_LINE_SMOOTH_HINT)
-        case GL_LINE_SMOOTH_HINT:
-#endif // defined(GL_LINE_SMOOTH_HINT)
-#if defined(GL_LINE_WIDTH)
-        case GL_LINE_WIDTH:
-#endif // defined(GL_LINE_WIDTH)
-#if defined(GL_LOGIC_OP_MODE)
-        case GL_LOGIC_OP_MODE:
-#endif // defined(GL_LOGIC_OP_MODE)
-#if defined(GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES)
-        case GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES:
-#endif // defined(GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES)
-#if defined(GL_MATRIX_INDEX_ARRAY_SIZE_OES)
-        case GL_MATRIX_INDEX_ARRAY_SIZE_OES:
-#endif // defined(GL_MATRIX_INDEX_ARRAY_SIZE_OES)
-#if defined(GL_MATRIX_INDEX_ARRAY_STRIDE_OES)
-        case GL_MATRIX_INDEX_ARRAY_STRIDE_OES:
-#endif // defined(GL_MATRIX_INDEX_ARRAY_STRIDE_OES)
-#if defined(GL_MATRIX_INDEX_ARRAY_TYPE_OES)
-        case GL_MATRIX_INDEX_ARRAY_TYPE_OES:
-#endif // defined(GL_MATRIX_INDEX_ARRAY_TYPE_OES)
-#if defined(GL_MATRIX_MODE)
-        case GL_MATRIX_MODE:
-#endif // defined(GL_MATRIX_MODE)
-#if defined(GL_MAX_CLIP_PLANES)
-        case GL_MAX_CLIP_PLANES:
-#endif // defined(GL_MAX_CLIP_PLANES)
-#if defined(GL_MAX_ELEMENTS_INDICES)
-        case GL_MAX_ELEMENTS_INDICES:
-#endif // defined(GL_MAX_ELEMENTS_INDICES)
-#if defined(GL_MAX_ELEMENTS_VERTICES)
-        case GL_MAX_ELEMENTS_VERTICES:
-#endif // defined(GL_MAX_ELEMENTS_VERTICES)
-#if defined(GL_MAX_LIGHTS)
-        case GL_MAX_LIGHTS:
-#endif // defined(GL_MAX_LIGHTS)
-#if defined(GL_MAX_MODELVIEW_STACK_DEPTH)
-        case GL_MAX_MODELVIEW_STACK_DEPTH:
-#endif // defined(GL_MAX_MODELVIEW_STACK_DEPTH)
-#if defined(GL_MAX_PALETTE_MATRICES_OES)
-        case GL_MAX_PALETTE_MATRICES_OES:
-#endif // defined(GL_MAX_PALETTE_MATRICES_OES)
-#if defined(GL_MAX_PROJECTION_STACK_DEPTH)
-        case GL_MAX_PROJECTION_STACK_DEPTH:
-#endif // defined(GL_MAX_PROJECTION_STACK_DEPTH)
-#if defined(GL_MAX_TEXTURE_SIZE)
-        case GL_MAX_TEXTURE_SIZE:
-#endif // defined(GL_MAX_TEXTURE_SIZE)
-#if defined(GL_MAX_TEXTURE_STACK_DEPTH)
-        case GL_MAX_TEXTURE_STACK_DEPTH:
-#endif // defined(GL_MAX_TEXTURE_STACK_DEPTH)
-#if defined(GL_MAX_TEXTURE_UNITS)
-        case GL_MAX_TEXTURE_UNITS:
-#endif // defined(GL_MAX_TEXTURE_UNITS)
-#if defined(GL_MAX_VERTEX_UNITS_OES)
-        case GL_MAX_VERTEX_UNITS_OES:
-#endif // defined(GL_MAX_VERTEX_UNITS_OES)
-#if defined(GL_MODELVIEW_STACK_DEPTH)
-        case GL_MODELVIEW_STACK_DEPTH:
-#endif // defined(GL_MODELVIEW_STACK_DEPTH)
-#if defined(GL_NORMAL_ARRAY_BUFFER_BINDING)
-        case GL_NORMAL_ARRAY_BUFFER_BINDING:
-#endif // defined(GL_NORMAL_ARRAY_BUFFER_BINDING)
-#if defined(GL_NORMAL_ARRAY_STRIDE)
-        case GL_NORMAL_ARRAY_STRIDE:
-#endif // defined(GL_NORMAL_ARRAY_STRIDE)
-#if defined(GL_NORMAL_ARRAY_TYPE)
-        case GL_NORMAL_ARRAY_TYPE:
-#endif // defined(GL_NORMAL_ARRAY_TYPE)
-#if defined(GL_NUM_COMPRESSED_TEXTURE_FORMATS)
-        case GL_NUM_COMPRESSED_TEXTURE_FORMATS:
-#endif // defined(GL_NUM_COMPRESSED_TEXTURE_FORMATS)
-#if defined(GL_PACK_ALIGNMENT)
-        case GL_PACK_ALIGNMENT:
-#endif // defined(GL_PACK_ALIGNMENT)
-#if defined(GL_PERSPECTIVE_CORRECTION_HINT)
-        case GL_PERSPECTIVE_CORRECTION_HINT:
-#endif // defined(GL_PERSPECTIVE_CORRECTION_HINT)
-#if defined(GL_POINT_SIZE)
-        case GL_POINT_SIZE:
-#endif // defined(GL_POINT_SIZE)
-#if defined(GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES)
-        case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES:
-#endif // defined(GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES)
-#if defined(GL_POINT_SIZE_ARRAY_STRIDE_OES)
-        case GL_POINT_SIZE_ARRAY_STRIDE_OES:
-#endif // defined(GL_POINT_SIZE_ARRAY_STRIDE_OES)
-#if defined(GL_POINT_SIZE_ARRAY_TYPE_OES)
-        case GL_POINT_SIZE_ARRAY_TYPE_OES:
-#endif // defined(GL_POINT_SIZE_ARRAY_TYPE_OES)
-#if defined(GL_POINT_SMOOTH_HINT)
-        case GL_POINT_SMOOTH_HINT:
-#endif // defined(GL_POINT_SMOOTH_HINT)
-#if defined(GL_POLYGON_OFFSET_FACTOR)
-        case GL_POLYGON_OFFSET_FACTOR:
-#endif // defined(GL_POLYGON_OFFSET_FACTOR)
-#if defined(GL_POLYGON_OFFSET_UNITS)
-        case GL_POLYGON_OFFSET_UNITS:
-#endif // defined(GL_POLYGON_OFFSET_UNITS)
-#if defined(GL_PROJECTION_STACK_DEPTH)
-        case GL_PROJECTION_STACK_DEPTH:
-#endif // defined(GL_PROJECTION_STACK_DEPTH)
-#if defined(GL_RED_BITS)
-        case GL_RED_BITS:
-#endif // defined(GL_RED_BITS)
-#if defined(GL_SHADE_MODEL)
-        case GL_SHADE_MODEL:
-#endif // defined(GL_SHADE_MODEL)
-#if defined(GL_STENCIL_BITS)
-        case GL_STENCIL_BITS:
-#endif // defined(GL_STENCIL_BITS)
-#if defined(GL_STENCIL_CLEAR_VALUE)
-        case GL_STENCIL_CLEAR_VALUE:
-#endif // defined(GL_STENCIL_CLEAR_VALUE)
-#if defined(GL_STENCIL_FAIL)
-        case GL_STENCIL_FAIL:
-#endif // defined(GL_STENCIL_FAIL)
-#if defined(GL_STENCIL_FUNC)
-        case GL_STENCIL_FUNC:
-#endif // defined(GL_STENCIL_FUNC)
-#if defined(GL_STENCIL_PASS_DEPTH_FAIL)
-        case GL_STENCIL_PASS_DEPTH_FAIL:
-#endif // defined(GL_STENCIL_PASS_DEPTH_FAIL)
-#if defined(GL_STENCIL_PASS_DEPTH_PASS)
-        case GL_STENCIL_PASS_DEPTH_PASS:
-#endif // defined(GL_STENCIL_PASS_DEPTH_PASS)
-#if defined(GL_STENCIL_REF)
-        case GL_STENCIL_REF:
-#endif // defined(GL_STENCIL_REF)
-#if defined(GL_STENCIL_VALUE_MASK)
-        case GL_STENCIL_VALUE_MASK:
-#endif // defined(GL_STENCIL_VALUE_MASK)
-#if defined(GL_STENCIL_WRITEMASK)
-        case GL_STENCIL_WRITEMASK:
-#endif // defined(GL_STENCIL_WRITEMASK)
-#if defined(GL_SUBPIXEL_BITS)
-        case GL_SUBPIXEL_BITS:
-#endif // defined(GL_SUBPIXEL_BITS)
-#if defined(GL_TEXTURE_BINDING_2D)
-        case GL_TEXTURE_BINDING_2D:
-#endif // defined(GL_TEXTURE_BINDING_2D)
-#if defined(GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING)
-        case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING:
-#endif // defined(GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING)
-#if defined(GL_TEXTURE_COORD_ARRAY_SIZE)
-        case GL_TEXTURE_COORD_ARRAY_SIZE:
-#endif // defined(GL_TEXTURE_COORD_ARRAY_SIZE)
-#if defined(GL_TEXTURE_COORD_ARRAY_STRIDE)
-        case GL_TEXTURE_COORD_ARRAY_STRIDE:
-#endif // defined(GL_TEXTURE_COORD_ARRAY_STRIDE)
-#if defined(GL_TEXTURE_COORD_ARRAY_TYPE)
-        case GL_TEXTURE_COORD_ARRAY_TYPE:
-#endif // defined(GL_TEXTURE_COORD_ARRAY_TYPE)
-#if defined(GL_TEXTURE_STACK_DEPTH)
-        case GL_TEXTURE_STACK_DEPTH:
-#endif // defined(GL_TEXTURE_STACK_DEPTH)
-#if defined(GL_UNPACK_ALIGNMENT)
-        case GL_UNPACK_ALIGNMENT:
-#endif // defined(GL_UNPACK_ALIGNMENT)
-#if defined(GL_VERTEX_ARRAY_BUFFER_BINDING)
-        case GL_VERTEX_ARRAY_BUFFER_BINDING:
-#endif // defined(GL_VERTEX_ARRAY_BUFFER_BINDING)
-#if defined(GL_VERTEX_ARRAY_SIZE)
-        case GL_VERTEX_ARRAY_SIZE:
-#endif // defined(GL_VERTEX_ARRAY_SIZE)
-#if defined(GL_VERTEX_ARRAY_STRIDE)
-        case GL_VERTEX_ARRAY_STRIDE:
-#endif // defined(GL_VERTEX_ARRAY_STRIDE)
-#if defined(GL_VERTEX_ARRAY_TYPE)
-        case GL_VERTEX_ARRAY_TYPE:
-#endif // defined(GL_VERTEX_ARRAY_TYPE)
-#if defined(GL_WEIGHT_ARRAY_BUFFER_BINDING_OES)
-        case GL_WEIGHT_ARRAY_BUFFER_BINDING_OES:
-#endif // defined(GL_WEIGHT_ARRAY_BUFFER_BINDING_OES)
-#if defined(GL_WEIGHT_ARRAY_SIZE_OES)
-        case GL_WEIGHT_ARRAY_SIZE_OES:
-#endif // defined(GL_WEIGHT_ARRAY_SIZE_OES)
-#if defined(GL_WEIGHT_ARRAY_STRIDE_OES)
-        case GL_WEIGHT_ARRAY_STRIDE_OES:
-#endif // defined(GL_WEIGHT_ARRAY_STRIDE_OES)
-#if defined(GL_WEIGHT_ARRAY_TYPE_OES)
-        case GL_WEIGHT_ARRAY_TYPE_OES:
-#endif // defined(GL_WEIGHT_ARRAY_TYPE_OES)
-            _needed = 1;
-            break;
-#if defined(GL_ALIASED_POINT_SIZE_RANGE)
-        case GL_ALIASED_POINT_SIZE_RANGE:
-#endif // defined(GL_ALIASED_POINT_SIZE_RANGE)
-#if defined(GL_ALIASED_LINE_WIDTH_RANGE)
-        case GL_ALIASED_LINE_WIDTH_RANGE:
-#endif // defined(GL_ALIASED_LINE_WIDTH_RANGE)
-#if defined(GL_DEPTH_RANGE)
-        case GL_DEPTH_RANGE:
-#endif // defined(GL_DEPTH_RANGE)
-#if defined(GL_MAX_VIEWPORT_DIMS)
-        case GL_MAX_VIEWPORT_DIMS:
-#endif // defined(GL_MAX_VIEWPORT_DIMS)
-#if defined(GL_SMOOTH_LINE_WIDTH_RANGE)
-        case GL_SMOOTH_LINE_WIDTH_RANGE:
-#endif // defined(GL_SMOOTH_LINE_WIDTH_RANGE)
-#if defined(GL_SMOOTH_POINT_SIZE_RANGE)
-        case GL_SMOOTH_POINT_SIZE_RANGE:
-#endif // defined(GL_SMOOTH_POINT_SIZE_RANGE)
-            _needed = 2;
-            break;
-#if defined(GL_COLOR_CLEAR_VALUE)
-        case GL_COLOR_CLEAR_VALUE:
-#endif // defined(GL_COLOR_CLEAR_VALUE)
-#if defined(GL_COLOR_WRITEMASK)
-        case GL_COLOR_WRITEMASK:
-#endif // defined(GL_COLOR_WRITEMASK)
-#if defined(GL_FOG_COLOR)
-        case GL_FOG_COLOR:
-#endif // defined(GL_FOG_COLOR)
-#if defined(GL_LIGHT_MODEL_AMBIENT)
-        case GL_LIGHT_MODEL_AMBIENT:
-#endif // defined(GL_LIGHT_MODEL_AMBIENT)
-#if defined(GL_SCISSOR_BOX)
-        case GL_SCISSOR_BOX:
-#endif // defined(GL_SCISSOR_BOX)
-#if defined(GL_VIEWPORT)
-        case GL_VIEWPORT:
-#endif // defined(GL_VIEWPORT)
-            _needed = 4;
-            break;
-#if defined(GL_MODELVIEW_MATRIX)
-        case GL_MODELVIEW_MATRIX:
-#endif // defined(GL_MODELVIEW_MATRIX)
-#if defined(GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES)
-        case GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES:
-#endif // defined(GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES)
-#if defined(GL_PROJECTION_MATRIX)
-        case GL_PROJECTION_MATRIX:
-#endif // defined(GL_PROJECTION_MATRIX)
-#if defined(GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES)
-        case GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES:
-#endif // defined(GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES)
-#if defined(GL_TEXTURE_MATRIX)
-        case GL_TEXTURE_MATRIX:
-#endif // defined(GL_TEXTURE_MATRIX)
-#if defined(GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES)
-        case GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES:
-#endif // defined(GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES)
-            _needed = 16;
-            break;
-#if defined(GL_COMPRESSED_TEXTURE_FORMATS)
-        case GL_COMPRESSED_TEXTURE_FORMATS:
-#endif // defined(GL_COMPRESSED_TEXTURE_FORMATS)
-            _needed = getNumCompressedTextureFormats();
-            break;
-        default:
-            _needed = 0;
-            break;
-    }
-    if (_remaining < _needed) {
-        _exception = 1;
-        _exceptionType = "java/lang/IllegalArgumentException";
-        _exceptionMessage = "remaining() < needed";
-        goto exit;
-    }
-    if (params == NULL) {
-        char * _paramsBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
-        params = (GLint *) (_paramsBase + _bufferOffset);
-    }
-    glGetIntegerv(
-        (GLenum)pname,
-        (GLint *)params
-    );
-
-exit:
-    if (_array) {
-        releasePointer(_env, _array, params, _exception ? JNI_FALSE : JNI_TRUE);
-    }
-    if (_exception) {
-        jniThrowException(_env, _exceptionType, _exceptionMessage);
-    }
+    getarray<GLint, glGetIntegerv>(_env, _this, pname, params_buf);
 }
 
 /* const GLubyte * glGetString ( GLenum name ) */
@@ -1834,8 +1231,8 @@
 android_glLightModelfv__I_3FI
   (JNIEnv *_env, jobject _this, jint pname, jfloatArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *params_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *params = (GLfloat *) 0;
@@ -1855,18 +1252,13 @@
     _remaining = _env->GetArrayLength(params_ref) - offset;
     int _needed;
     switch (pname) {
-#if defined(GL_LIGHT_MODEL_TWO_SIDE)
-        case GL_LIGHT_MODEL_TWO_SIDE:
-#endif // defined(GL_LIGHT_MODEL_TWO_SIDE)
-            _needed = 1;
-            break;
 #if defined(GL_LIGHT_MODEL_AMBIENT)
         case GL_LIGHT_MODEL_AMBIENT:
 #endif // defined(GL_LIGHT_MODEL_AMBIENT)
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -1899,8 +1291,8 @@
 android_glLightModelfv__ILjava_nio_FloatBuffer_2
   (JNIEnv *_env, jobject _this, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -1909,18 +1301,13 @@
     params = (GLfloat *)getPointer(_env, params_buf, &_array, &_remaining, &_bufferOffset);
     int _needed;
     switch (pname) {
-#if defined(GL_LIGHT_MODEL_TWO_SIDE)
-        case GL_LIGHT_MODEL_TWO_SIDE:
-#endif // defined(GL_LIGHT_MODEL_TWO_SIDE)
-            _needed = 1;
-            break;
 #if defined(GL_LIGHT_MODEL_AMBIENT)
         case GL_LIGHT_MODEL_AMBIENT:
 #endif // defined(GL_LIGHT_MODEL_AMBIENT)
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -1962,8 +1349,8 @@
 android_glLightModelxv__I_3II
   (JNIEnv *_env, jobject _this, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *params_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *params = (GLfixed *) 0;
@@ -1983,18 +1370,13 @@
     _remaining = _env->GetArrayLength(params_ref) - offset;
     int _needed;
     switch (pname) {
-#if defined(GL_LIGHT_MODEL_TWO_SIDE)
-        case GL_LIGHT_MODEL_TWO_SIDE:
-#endif // defined(GL_LIGHT_MODEL_TWO_SIDE)
-            _needed = 1;
-            break;
 #if defined(GL_LIGHT_MODEL_AMBIENT)
         case GL_LIGHT_MODEL_AMBIENT:
 #endif // defined(GL_LIGHT_MODEL_AMBIENT)
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -2027,8 +1409,8 @@
 android_glLightModelxv__ILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -2037,18 +1419,13 @@
     params = (GLfixed *)getPointer(_env, params_buf, &_array, &_remaining, &_bufferOffset);
     int _needed;
     switch (pname) {
-#if defined(GL_LIGHT_MODEL_TWO_SIDE)
-        case GL_LIGHT_MODEL_TWO_SIDE:
-#endif // defined(GL_LIGHT_MODEL_TWO_SIDE)
-            _needed = 1;
-            break;
 #if defined(GL_LIGHT_MODEL_AMBIENT)
         case GL_LIGHT_MODEL_AMBIENT:
 #endif // defined(GL_LIGHT_MODEL_AMBIENT)
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -2091,8 +1468,8 @@
 android_glLightfv__II_3FI
   (JNIEnv *_env, jobject _this, jint light, jint pname, jfloatArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *params_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *params = (GLfloat *) 0;
@@ -2112,23 +1489,6 @@
     _remaining = _env->GetArrayLength(params_ref) - offset;
     int _needed;
     switch (pname) {
-#if defined(GL_SPOT_EXPONENT)
-        case GL_SPOT_EXPONENT:
-#endif // defined(GL_SPOT_EXPONENT)
-#if defined(GL_SPOT_CUTOFF)
-        case GL_SPOT_CUTOFF:
-#endif // defined(GL_SPOT_CUTOFF)
-#if defined(GL_CONSTANT_ATTENUATION)
-        case GL_CONSTANT_ATTENUATION:
-#endif // defined(GL_CONSTANT_ATTENUATION)
-#if defined(GL_LINEAR_ATTENUATION)
-        case GL_LINEAR_ATTENUATION:
-#endif // defined(GL_LINEAR_ATTENUATION)
-#if defined(GL_QUADRATIC_ATTENUATION)
-        case GL_QUADRATIC_ATTENUATION:
-#endif // defined(GL_QUADRATIC_ATTENUATION)
-            _needed = 1;
-            break;
 #if defined(GL_SPOT_DIRECTION)
         case GL_SPOT_DIRECTION:
 #endif // defined(GL_SPOT_DIRECTION)
@@ -2149,7 +1509,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -2183,8 +1543,8 @@
 android_glLightfv__IILjava_nio_FloatBuffer_2
   (JNIEnv *_env, jobject _this, jint light, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -2193,23 +1553,6 @@
     params = (GLfloat *)getPointer(_env, params_buf, &_array, &_remaining, &_bufferOffset);
     int _needed;
     switch (pname) {
-#if defined(GL_SPOT_EXPONENT)
-        case GL_SPOT_EXPONENT:
-#endif // defined(GL_SPOT_EXPONENT)
-#if defined(GL_SPOT_CUTOFF)
-        case GL_SPOT_CUTOFF:
-#endif // defined(GL_SPOT_CUTOFF)
-#if defined(GL_CONSTANT_ATTENUATION)
-        case GL_CONSTANT_ATTENUATION:
-#endif // defined(GL_CONSTANT_ATTENUATION)
-#if defined(GL_LINEAR_ATTENUATION)
-        case GL_LINEAR_ATTENUATION:
-#endif // defined(GL_LINEAR_ATTENUATION)
-#if defined(GL_QUADRATIC_ATTENUATION)
-        case GL_QUADRATIC_ATTENUATION:
-#endif // defined(GL_QUADRATIC_ATTENUATION)
-            _needed = 1;
-            break;
 #if defined(GL_SPOT_DIRECTION)
         case GL_SPOT_DIRECTION:
 #endif // defined(GL_SPOT_DIRECTION)
@@ -2230,7 +1573,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -2274,8 +1617,8 @@
 android_glLightxv__II_3II
   (JNIEnv *_env, jobject _this, jint light, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *params_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *params = (GLfixed *) 0;
@@ -2295,23 +1638,6 @@
     _remaining = _env->GetArrayLength(params_ref) - offset;
     int _needed;
     switch (pname) {
-#if defined(GL_SPOT_EXPONENT)
-        case GL_SPOT_EXPONENT:
-#endif // defined(GL_SPOT_EXPONENT)
-#if defined(GL_SPOT_CUTOFF)
-        case GL_SPOT_CUTOFF:
-#endif // defined(GL_SPOT_CUTOFF)
-#if defined(GL_CONSTANT_ATTENUATION)
-        case GL_CONSTANT_ATTENUATION:
-#endif // defined(GL_CONSTANT_ATTENUATION)
-#if defined(GL_LINEAR_ATTENUATION)
-        case GL_LINEAR_ATTENUATION:
-#endif // defined(GL_LINEAR_ATTENUATION)
-#if defined(GL_QUADRATIC_ATTENUATION)
-        case GL_QUADRATIC_ATTENUATION:
-#endif // defined(GL_QUADRATIC_ATTENUATION)
-            _needed = 1;
-            break;
 #if defined(GL_SPOT_DIRECTION)
         case GL_SPOT_DIRECTION:
 #endif // defined(GL_SPOT_DIRECTION)
@@ -2332,7 +1658,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -2366,8 +1692,8 @@
 android_glLightxv__IILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint light, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -2376,23 +1702,6 @@
     params = (GLfixed *)getPointer(_env, params_buf, &_array, &_remaining, &_bufferOffset);
     int _needed;
     switch (pname) {
-#if defined(GL_SPOT_EXPONENT)
-        case GL_SPOT_EXPONENT:
-#endif // defined(GL_SPOT_EXPONENT)
-#if defined(GL_SPOT_CUTOFF)
-        case GL_SPOT_CUTOFF:
-#endif // defined(GL_SPOT_CUTOFF)
-#if defined(GL_CONSTANT_ATTENUATION)
-        case GL_CONSTANT_ATTENUATION:
-#endif // defined(GL_CONSTANT_ATTENUATION)
-#if defined(GL_LINEAR_ATTENUATION)
-        case GL_LINEAR_ATTENUATION:
-#endif // defined(GL_LINEAR_ATTENUATION)
-#if defined(GL_QUADRATIC_ATTENUATION)
-        case GL_QUADRATIC_ATTENUATION:
-#endif // defined(GL_QUADRATIC_ATTENUATION)
-            _needed = 1;
-            break;
 #if defined(GL_SPOT_DIRECTION)
         case GL_SPOT_DIRECTION:
 #endif // defined(GL_SPOT_DIRECTION)
@@ -2413,7 +1722,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -2471,8 +1780,8 @@
 android_glLoadMatrixf___3FI
   (JNIEnv *_env, jobject _this, jfloatArray m_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *m_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *m = (GLfloat *) 0;
@@ -2535,8 +1844,8 @@
 android_glLoadMatrixx___3II
   (JNIEnv *_env, jobject _this, jintArray m_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *m_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *m = (GLfixed *) 0;
@@ -2619,8 +1928,8 @@
 android_glMaterialfv__II_3FI
   (JNIEnv *_env, jobject _this, jint face, jint pname, jfloatArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *params_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *params = (GLfloat *) 0;
@@ -2640,11 +1949,6 @@
     _remaining = _env->GetArrayLength(params_ref) - offset;
     int _needed;
     switch (pname) {
-#if defined(GL_SHININESS)
-        case GL_SHININESS:
-#endif // defined(GL_SHININESS)
-            _needed = 1;
-            break;
 #if defined(GL_AMBIENT)
         case GL_AMBIENT:
 #endif // defined(GL_AMBIENT)
@@ -2663,7 +1967,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -2697,8 +2001,8 @@
 android_glMaterialfv__IILjava_nio_FloatBuffer_2
   (JNIEnv *_env, jobject _this, jint face, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -2707,11 +2011,6 @@
     params = (GLfloat *)getPointer(_env, params_buf, &_array, &_remaining, &_bufferOffset);
     int _needed;
     switch (pname) {
-#if defined(GL_SHININESS)
-        case GL_SHININESS:
-#endif // defined(GL_SHININESS)
-            _needed = 1;
-            break;
 #if defined(GL_AMBIENT)
         case GL_AMBIENT:
 #endif // defined(GL_AMBIENT)
@@ -2730,7 +2029,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -2774,8 +2073,8 @@
 android_glMaterialxv__II_3II
   (JNIEnv *_env, jobject _this, jint face, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *params_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *params = (GLfixed *) 0;
@@ -2795,11 +2094,6 @@
     _remaining = _env->GetArrayLength(params_ref) - offset;
     int _needed;
     switch (pname) {
-#if defined(GL_SHININESS)
-        case GL_SHININESS:
-#endif // defined(GL_SHININESS)
-            _needed = 1;
-            break;
 #if defined(GL_AMBIENT)
         case GL_AMBIENT:
 #endif // defined(GL_AMBIENT)
@@ -2818,7 +2112,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -2852,8 +2146,8 @@
 android_glMaterialxv__IILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint face, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -2862,11 +2156,6 @@
     params = (GLfixed *)getPointer(_env, params_buf, &_array, &_remaining, &_bufferOffset);
     int _needed;
     switch (pname) {
-#if defined(GL_SHININESS)
-        case GL_SHININESS:
-#endif // defined(GL_SHININESS)
-            _needed = 1;
-            break;
 #if defined(GL_AMBIENT)
         case GL_AMBIENT:
 #endif // defined(GL_AMBIENT)
@@ -2885,7 +2174,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -2927,8 +2216,8 @@
 android_glMultMatrixf___3FI
   (JNIEnv *_env, jobject _this, jfloatArray m_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *m_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *m = (GLfloat *) 0;
@@ -2991,8 +2280,8 @@
 android_glMultMatrixx___3II
   (JNIEnv *_env, jobject _this, jintArray m_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *m_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *m = (GLfixed *) 0;
@@ -3397,8 +2686,8 @@
 android_glTexEnvfv__II_3FI
   (JNIEnv *_env, jobject _this, jint target, jint pname, jfloatArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *params_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *params = (GLfloat *) 0;
@@ -3418,24 +2707,13 @@
     _remaining = _env->GetArrayLength(params_ref) - offset;
     int _needed;
     switch (pname) {
-#if defined(GL_TEXTURE_ENV_MODE)
-        case GL_TEXTURE_ENV_MODE:
-#endif // defined(GL_TEXTURE_ENV_MODE)
-#if defined(GL_COMBINE_RGB)
-        case GL_COMBINE_RGB:
-#endif // defined(GL_COMBINE_RGB)
-#if defined(GL_COMBINE_ALPHA)
-        case GL_COMBINE_ALPHA:
-#endif // defined(GL_COMBINE_ALPHA)
-            _needed = 1;
-            break;
 #if defined(GL_TEXTURE_ENV_COLOR)
         case GL_TEXTURE_ENV_COLOR:
 #endif // defined(GL_TEXTURE_ENV_COLOR)
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -3469,8 +2747,8 @@
 android_glTexEnvfv__IILjava_nio_FloatBuffer_2
   (JNIEnv *_env, jobject _this, jint target, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -3479,24 +2757,13 @@
     params = (GLfloat *)getPointer(_env, params_buf, &_array, &_remaining, &_bufferOffset);
     int _needed;
     switch (pname) {
-#if defined(GL_TEXTURE_ENV_MODE)
-        case GL_TEXTURE_ENV_MODE:
-#endif // defined(GL_TEXTURE_ENV_MODE)
-#if defined(GL_COMBINE_RGB)
-        case GL_COMBINE_RGB:
-#endif // defined(GL_COMBINE_RGB)
-#if defined(GL_COMBINE_ALPHA)
-        case GL_COMBINE_ALPHA:
-#endif // defined(GL_COMBINE_ALPHA)
-            _needed = 1;
-            break;
 #if defined(GL_TEXTURE_ENV_COLOR)
         case GL_TEXTURE_ENV_COLOR:
 #endif // defined(GL_TEXTURE_ENV_COLOR)
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -3540,8 +2807,8 @@
 android_glTexEnvxv__II_3II
   (JNIEnv *_env, jobject _this, jint target, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *params_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *params = (GLfixed *) 0;
@@ -3561,24 +2828,13 @@
     _remaining = _env->GetArrayLength(params_ref) - offset;
     int _needed;
     switch (pname) {
-#if defined(GL_TEXTURE_ENV_MODE)
-        case GL_TEXTURE_ENV_MODE:
-#endif // defined(GL_TEXTURE_ENV_MODE)
-#if defined(GL_COMBINE_RGB)
-        case GL_COMBINE_RGB:
-#endif // defined(GL_COMBINE_RGB)
-#if defined(GL_COMBINE_ALPHA)
-        case GL_COMBINE_ALPHA:
-#endif // defined(GL_COMBINE_ALPHA)
-            _needed = 1;
-            break;
 #if defined(GL_TEXTURE_ENV_COLOR)
         case GL_TEXTURE_ENV_COLOR:
 #endif // defined(GL_TEXTURE_ENV_COLOR)
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -3612,8 +2868,8 @@
 android_glTexEnvxv__IILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint target, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -3622,24 +2878,13 @@
     params = (GLfixed *)getPointer(_env, params_buf, &_array, &_remaining, &_bufferOffset);
     int _needed;
     switch (pname) {
-#if defined(GL_TEXTURE_ENV_MODE)
-        case GL_TEXTURE_ENV_MODE:
-#endif // defined(GL_TEXTURE_ENV_MODE)
-#if defined(GL_COMBINE_RGB)
-        case GL_COMBINE_RGB:
-#endif // defined(GL_COMBINE_RGB)
-#if defined(GL_COMBINE_ALPHA)
-        case GL_COMBINE_ALPHA:
-#endif // defined(GL_COMBINE_ALPHA)
-            _needed = 1;
-            break;
 #if defined(GL_TEXTURE_ENV_COLOR)
         case GL_TEXTURE_ENV_COLOR:
 #endif // defined(GL_TEXTURE_ENV_COLOR)
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
diff --git a/core/jni/android_opengl_GLES10Ext.cpp b/core/jni/android_opengl_GLES10Ext.cpp
index 1cd8e44..59e63e1 100644
--- a/core/jni/android_opengl_GLES10Ext.cpp
+++ b/core/jni/android_opengl_GLES10Ext.cpp
@@ -17,14 +17,14 @@
 
 // This source file is automatically generated
 
+#include <GLES/gl.h>
+#include <GLES/glext.h>
+
 #include "jni.h"
 #include "JNIHelp.h"
 #include <android_runtime/AndroidRuntime.h>
 #include <utils/misc.h>
-
 #include <assert.h>
-#include <GLES/gl.h>
-#include <GLES/glext.h>
 
 static int initialized = 0;
 
@@ -37,6 +37,34 @@
 static jfieldID limitID;
 static jfieldID elementSizeShiftID;
 
+
+/* special calls implemented in Android's GLES wrapper used to more
+ * efficiently bound-check passed arrays */
+extern "C" {
+#ifdef GL_VERSION_ES_CM_1_1
+GL_API void GL_APIENTRY glColorPointerBounds(GLint size, GLenum type, GLsizei stride,
+        const GLvoid *ptr, GLsizei count);
+GL_API void GL_APIENTRY glNormalPointerBounds(GLenum type, GLsizei stride,
+        const GLvoid *pointer, GLsizei count);
+GL_API void GL_APIENTRY glTexCoordPointerBounds(GLint size, GLenum type,
+        GLsizei stride, const GLvoid *pointer, GLsizei count);
+GL_API void GL_APIENTRY glVertexPointerBounds(GLint size, GLenum type,
+        GLsizei stride, const GLvoid *pointer, GLsizei count);
+GL_API void GL_APIENTRY glPointSizePointerOESBounds(GLenum type,
+        GLsizei stride, const GLvoid *pointer, GLsizei count);
+GL_API void GL_APIENTRY glMatrixIndexPointerOESBounds(GLint size, GLenum type,
+        GLsizei stride, const GLvoid *pointer, GLsizei count);
+GL_API void GL_APIENTRY glWeightPointerOESBounds(GLint size, GLenum type,
+        GLsizei stride, const GLvoid *pointer, GLsizei count);
+#endif
+#ifdef GL_ES_VERSION_2_0
+static void glVertexAttribPointerBounds(GLuint indx, GLint size, GLenum type,
+        GLboolean normalized, GLsizei stride, const GLvoid *pointer, GLsizei count) {
+    glVertexAttribPointer(indx, size, type, normalized, stride, pointer);
+}
+#endif
+}
+
 /* Cache method IDs each time the class is loaded. */
 
 static void
@@ -61,7 +89,6 @@
         _env->GetFieldID(bufferClass, "_elementSizeShift", "I");
 }
 
-
 static void *
 getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining, jint *offset)
 {
@@ -89,12 +116,204 @@
     return NULL;
 }
 
-
 static void
 releasePointer(JNIEnv *_env, jarray array, void *data, jboolean commit)
 {
     _env->ReleasePrimitiveArrayCritical(array, data,
-					   commit ? 0 : JNI_ABORT);
+                       commit ? 0 : JNI_ABORT);
+}
+
+static void *
+getDirectBufferPointer(JNIEnv *_env, jobject buffer) {
+    char* buf = (char*) _env->GetDirectBufferAddress(buffer);
+    if (buf) {
+        jint position = _env->GetIntField(buffer, positionID);
+        jint elementSizeShift = _env->GetIntField(buffer, elementSizeShiftID);
+        buf += position << elementSizeShift;
+    } else {
+        jniThrowException(_env, "java/lang/IllegalArgumentException",
+                          "Must use a native order direct Buffer");
+    }
+    return (void*) buf;
+}
+
+// --------------------------------------------------------------------------
+
+/*
+ * returns the number of values glGet returns for a given pname.
+ *
+ * The code below is written such that pnames requiring only one values
+ * are the default (and are not explicitely tested for). This makes the
+ * checking code much shorter/readable/efficient.
+ *
+ * This means that unknown pnames (e.g.: extensions) will default to 1. If
+ * that unknown pname needs more than 1 value, then the validation check
+ * is incomplete and the app may crash if it passed the wrong number params.
+ */
+static int getNeededCount(GLint pname) {
+    int needed = 1;
+#ifdef GL_ES_VERSION_2_0
+    // GLES 2.x pnames
+    switch (pname) {
+        case GL_ALIASED_LINE_WIDTH_RANGE:
+        case GL_ALIASED_POINT_SIZE_RANGE:
+            needed = 2;
+            break;
+
+        case GL_BLEND_COLOR:
+        case GL_COLOR_CLEAR_VALUE:
+        case GL_COLOR_WRITEMASK:
+        case GL_SCISSOR_BOX:
+        case GL_VIEWPORT:
+            needed = 4;
+            break;
+
+        case GL_COMPRESSED_TEXTURE_FORMATS:
+            glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &needed);
+            break;
+
+        case GL_SHADER_BINARY_FORMATS:
+            glGetIntegerv(GL_NUM_SHADER_BINARY_FORMATS, &needed);
+            break;
+    }
+#endif
+
+#ifdef GL_VERSION_ES_CM_1_1
+    // GLES 1.x pnames
+    switch (pname) {
+        case GL_ALIASED_LINE_WIDTH_RANGE:
+        case GL_ALIASED_POINT_SIZE_RANGE:
+        case GL_DEPTH_RANGE:
+        case GL_SMOOTH_LINE_WIDTH_RANGE:
+        case GL_SMOOTH_POINT_SIZE_RANGE:
+            needed = 2;
+            break;
+
+        case GL_CURRENT_NORMAL:
+        case GL_POINT_DISTANCE_ATTENUATION:
+            needed = 3;
+            break;
+
+        case GL_COLOR_CLEAR_VALUE:
+        case GL_COLOR_WRITEMASK:
+        case GL_CURRENT_COLOR:
+        case GL_CURRENT_TEXTURE_COORDS:
+        case GL_FOG_COLOR:
+        case GL_LIGHT_MODEL_AMBIENT:
+        case GL_SCISSOR_BOX:
+        case GL_VIEWPORT:
+            needed = 4;
+            break;
+
+        case GL_MODELVIEW_MATRIX:
+        case GL_PROJECTION_MATRIX:
+        case GL_TEXTURE_MATRIX:
+            needed = 16;
+            break;
+
+        case GL_COMPRESSED_TEXTURE_FORMATS:
+            glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &needed);
+            break;
+    }
+#endif
+    return needed;
+}
+
+template <typename JTYPEARRAY, typename CTYPE, void GET(GLenum, CTYPE*)>
+static void
+get
+  (JNIEnv *_env, jobject _this, jint pname, JTYPEARRAY params_ref, jint offset) {
+    jint _exception = 0;
+    const char * _exceptionType;
+    const char * _exceptionMessage;
+    CTYPE *params_base = (CTYPE *) 0;
+    jint _remaining;
+    CTYPE *params = (CTYPE *) 0;
+    int _needed = 0;
+
+    if (!params_ref) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "params == null";
+        goto exit;
+    }
+    if (offset < 0) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "offset < 0";
+        goto exit;
+    }
+    _remaining = _env->GetArrayLength(params_ref) - offset;
+    _needed = getNeededCount(pname);
+    // if we didn't find this pname, we just assume the user passed
+    // an array of the right size -- this might happen with extensions
+    // or if we forget an enum here.
+    if (_remaining < _needed) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "length - offset < needed";
+        goto exit;
+    }
+    params_base = (CTYPE *)
+        _env->GetPrimitiveArrayCritical(params_ref, (jboolean *)0);
+    params = params_base + offset;
+
+    GET(
+        (GLenum)pname,
+        (CTYPE *)params
+    );
+
+exit:
+    if (params_base) {
+        _env->ReleasePrimitiveArrayCritical(params_ref, params_base,
+            _exception ? JNI_ABORT: 0);
+    }
+    if (_exception) {
+        jniThrowException(_env, _exceptionType, _exceptionMessage);
+    }
+}
+
+
+template <typename CTYPE, void GET(GLenum, CTYPE*)>
+static void
+getarray
+  (JNIEnv *_env, jobject _this, jint pname, jobject params_buf) {
+    jint _exception = 0;
+    const char * _exceptionType;
+    const char * _exceptionMessage;
+    jarray _array = (jarray) 0;
+    jint _bufferOffset = (jint) 0;
+    jint _remaining;
+    CTYPE *params = (CTYPE *) 0;
+    int _needed = 0;
+
+    params = (CTYPE *)getPointer(_env, params_buf, &_array, &_remaining, &_bufferOffset);
+    _needed = getNeededCount(pname);
+    // if we didn't find this pname, we just assume the user passed
+    // an array of the right size -- this might happen with extensions
+    // or if we forget an enum here.
+    if (_needed>0 && _remaining < _needed) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "remaining() < needed";
+        goto exit;
+    }
+    if (params == NULL) {
+        char * _paramsBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
+        params = (CTYPE *) (_paramsBase + _bufferOffset);
+    }
+    GET(
+        (GLenum)pname,
+        (CTYPE *)params
+    );
+
+exit:
+    if (_array) {
+        releasePointer(_env, _array, params, _exception ? JNI_FALSE : JNI_TRUE);
+    }
+    if (_exception) {
+        jniThrowException(_env, _exceptionType, _exceptionMessage);
+    }
 }
 
 // --------------------------------------------------------------------------
@@ -103,8 +322,8 @@
 android_glQueryMatrixxOES___3II_3II
   (JNIEnv *_env, jobject _this, jintArray mantissa_ref, jint mantissaOffset, jintArray exponent_ref, jint exponentOffset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLbitfield _returnValue = -1;
     GLfixed *mantissa_base = (GLfixed *) 0;
     jint _mantissaRemaining;
@@ -184,8 +403,8 @@
 android_glQueryMatrixxOES__Ljava_nio_IntBuffer_2Ljava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jobject mantissa_buf, jobject exponent_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _mantissaArray = (jarray) 0;
     jint _mantissaBufferOffset = (jint) 0;
     jarray _exponentArray = (jarray) 0;
diff --git a/core/jni/android_opengl_GLES11.cpp b/core/jni/android_opengl_GLES11.cpp
index 1e6ceb3..352f5bf 100644
--- a/core/jni/android_opengl_GLES11.cpp
+++ b/core/jni/android_opengl_GLES11.cpp
@@ -17,21 +17,14 @@
 
 // This source file is automatically generated
 
+#include <GLES/gl.h>
+#include <GLES/glext.h>
+
 #include "jni.h"
 #include "JNIHelp.h"
 #include <android_runtime/AndroidRuntime.h>
 #include <utils/misc.h>
-
 #include <assert.h>
-#include <GLES/gl.h>
-#include <GLES/glext.h>
-
-/* special calls implemented in Android's GLES wrapper used to more
- * efficiently bound-check passed arrays */
-extern "C" {
-GL_API void GL_APIENTRY glPointSizePointerOESBounds(GLenum type, GLsizei stride,
-        const GLvoid *ptr, GLsizei count);
-}
 
 static int initialized = 0;
 
@@ -44,6 +37,34 @@
 static jfieldID limitID;
 static jfieldID elementSizeShiftID;
 
+
+/* special calls implemented in Android's GLES wrapper used to more
+ * efficiently bound-check passed arrays */
+extern "C" {
+#ifdef GL_VERSION_ES_CM_1_1
+GL_API void GL_APIENTRY glColorPointerBounds(GLint size, GLenum type, GLsizei stride,
+        const GLvoid *ptr, GLsizei count);
+GL_API void GL_APIENTRY glNormalPointerBounds(GLenum type, GLsizei stride,
+        const GLvoid *pointer, GLsizei count);
+GL_API void GL_APIENTRY glTexCoordPointerBounds(GLint size, GLenum type,
+        GLsizei stride, const GLvoid *pointer, GLsizei count);
+GL_API void GL_APIENTRY glVertexPointerBounds(GLint size, GLenum type,
+        GLsizei stride, const GLvoid *pointer, GLsizei count);
+GL_API void GL_APIENTRY glPointSizePointerOESBounds(GLenum type,
+        GLsizei stride, const GLvoid *pointer, GLsizei count);
+GL_API void GL_APIENTRY glMatrixIndexPointerOESBounds(GLint size, GLenum type,
+        GLsizei stride, const GLvoid *pointer, GLsizei count);
+GL_API void GL_APIENTRY glWeightPointerOESBounds(GLint size, GLenum type,
+        GLsizei stride, const GLvoid *pointer, GLsizei count);
+#endif
+#ifdef GL_ES_VERSION_2_0
+static void glVertexAttribPointerBounds(GLuint indx, GLint size, GLenum type,
+        GLboolean normalized, GLsizei stride, const GLvoid *pointer, GLsizei count) {
+    glVertexAttribPointer(indx, size, type, normalized, stride, pointer);
+}
+#endif
+}
+
 /* Cache method IDs each time the class is loaded. */
 
 static void
@@ -68,7 +89,6 @@
         _env->GetFieldID(bufferClass, "_elementSizeShift", "I");
 }
 
-
 static void *
 getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining, jint *offset)
 {
@@ -96,12 +116,11 @@
     return NULL;
 }
 
-
 static void
 releasePointer(JNIEnv *_env, jarray array, void *data, jboolean commit)
 {
     _env->ReleasePrimitiveArrayCritical(array, data,
-					   commit ? 0 : JNI_ABORT);
+                       commit ? 0 : JNI_ABORT);
 }
 
 static void *
@@ -119,6 +138,185 @@
 }
 
 // --------------------------------------------------------------------------
+
+/*
+ * returns the number of values glGet returns for a given pname.
+ *
+ * The code below is written such that pnames requiring only one values
+ * are the default (and are not explicitely tested for). This makes the
+ * checking code much shorter/readable/efficient.
+ *
+ * This means that unknown pnames (e.g.: extensions) will default to 1. If
+ * that unknown pname needs more than 1 value, then the validation check
+ * is incomplete and the app may crash if it passed the wrong number params.
+ */
+static int getNeededCount(GLint pname) {
+    int needed = 1;
+#ifdef GL_ES_VERSION_2_0
+    // GLES 2.x pnames
+    switch (pname) {
+        case GL_ALIASED_LINE_WIDTH_RANGE:
+        case GL_ALIASED_POINT_SIZE_RANGE:
+            needed = 2;
+            break;
+
+        case GL_BLEND_COLOR:
+        case GL_COLOR_CLEAR_VALUE:
+        case GL_COLOR_WRITEMASK:
+        case GL_SCISSOR_BOX:
+        case GL_VIEWPORT:
+            needed = 4;
+            break;
+
+        case GL_COMPRESSED_TEXTURE_FORMATS:
+            glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &needed);
+            break;
+
+        case GL_SHADER_BINARY_FORMATS:
+            glGetIntegerv(GL_NUM_SHADER_BINARY_FORMATS, &needed);
+            break;
+    }
+#endif
+
+#ifdef GL_VERSION_ES_CM_1_1
+    // GLES 1.x pnames
+    switch (pname) {
+        case GL_ALIASED_LINE_WIDTH_RANGE:
+        case GL_ALIASED_POINT_SIZE_RANGE:
+        case GL_DEPTH_RANGE:
+        case GL_SMOOTH_LINE_WIDTH_RANGE:
+        case GL_SMOOTH_POINT_SIZE_RANGE:
+            needed = 2;
+            break;
+
+        case GL_CURRENT_NORMAL:
+        case GL_POINT_DISTANCE_ATTENUATION:
+            needed = 3;
+            break;
+
+        case GL_COLOR_CLEAR_VALUE:
+        case GL_COLOR_WRITEMASK:
+        case GL_CURRENT_COLOR:
+        case GL_CURRENT_TEXTURE_COORDS:
+        case GL_FOG_COLOR:
+        case GL_LIGHT_MODEL_AMBIENT:
+        case GL_SCISSOR_BOX:
+        case GL_VIEWPORT:
+            needed = 4;
+            break;
+
+        case GL_MODELVIEW_MATRIX:
+        case GL_PROJECTION_MATRIX:
+        case GL_TEXTURE_MATRIX:
+            needed = 16;
+            break;
+
+        case GL_COMPRESSED_TEXTURE_FORMATS:
+            glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &needed);
+            break;
+    }
+#endif
+    return needed;
+}
+
+template <typename JTYPEARRAY, typename CTYPE, void GET(GLenum, CTYPE*)>
+static void
+get
+  (JNIEnv *_env, jobject _this, jint pname, JTYPEARRAY params_ref, jint offset) {
+    jint _exception = 0;
+    const char * _exceptionType;
+    const char * _exceptionMessage;
+    CTYPE *params_base = (CTYPE *) 0;
+    jint _remaining;
+    CTYPE *params = (CTYPE *) 0;
+    int _needed = 0;
+
+    if (!params_ref) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "params == null";
+        goto exit;
+    }
+    if (offset < 0) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "offset < 0";
+        goto exit;
+    }
+    _remaining = _env->GetArrayLength(params_ref) - offset;
+    _needed = getNeededCount(pname);
+    // if we didn't find this pname, we just assume the user passed
+    // an array of the right size -- this might happen with extensions
+    // or if we forget an enum here.
+    if (_remaining < _needed) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "length - offset < needed";
+        goto exit;
+    }
+    params_base = (CTYPE *)
+        _env->GetPrimitiveArrayCritical(params_ref, (jboolean *)0);
+    params = params_base + offset;
+
+    GET(
+        (GLenum)pname,
+        (CTYPE *)params
+    );
+
+exit:
+    if (params_base) {
+        _env->ReleasePrimitiveArrayCritical(params_ref, params_base,
+            _exception ? JNI_ABORT: 0);
+    }
+    if (_exception) {
+        jniThrowException(_env, _exceptionType, _exceptionMessage);
+    }
+}
+
+
+template <typename CTYPE, void GET(GLenum, CTYPE*)>
+static void
+getarray
+  (JNIEnv *_env, jobject _this, jint pname, jobject params_buf) {
+    jint _exception = 0;
+    const char * _exceptionType;
+    const char * _exceptionMessage;
+    jarray _array = (jarray) 0;
+    jint _bufferOffset = (jint) 0;
+    jint _remaining;
+    CTYPE *params = (CTYPE *) 0;
+    int _needed = 0;
+
+    params = (CTYPE *)getPointer(_env, params_buf, &_array, &_remaining, &_bufferOffset);
+    _needed = getNeededCount(pname);
+    // if we didn't find this pname, we just assume the user passed
+    // an array of the right size -- this might happen with extensions
+    // or if we forget an enum here.
+    if (_needed>0 && _remaining < _needed) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "remaining() < needed";
+        goto exit;
+    }
+    if (params == NULL) {
+        char * _paramsBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
+        params = (CTYPE *) (_paramsBase + _bufferOffset);
+    }
+    GET(
+        (GLenum)pname,
+        (CTYPE *)params
+    );
+
+exit:
+    if (_array) {
+        releasePointer(_env, _array, params, _exception ? JNI_FALSE : JNI_TRUE);
+    }
+    if (_exception) {
+        jniThrowException(_env, _exceptionType, _exceptionMessage);
+    }
+}
+
+// --------------------------------------------------------------------------
 /* void glBindBuffer ( GLenum target, GLuint buffer ) */
 static void
 android_glBindBuffer__II
@@ -134,8 +332,8 @@
 android_glBufferData__IILjava_nio_Buffer_2I
   (JNIEnv *_env, jobject _this, jint target, jint size, jobject data_buf, jint usage) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -175,8 +373,8 @@
 android_glBufferSubData__IIILjava_nio_Buffer_2
   (JNIEnv *_env, jobject _this, jint target, jint offset, jint size, jobject data_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -214,8 +412,8 @@
 android_glClipPlanef__I_3FI
   (JNIEnv *_env, jobject _this, jint plane, jfloatArray equation_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *equation_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *equation = (GLfloat *) 0;
@@ -257,8 +455,8 @@
 android_glClipPlanef__ILjava_nio_FloatBuffer_2
   (JNIEnv *_env, jobject _this, jint plane, jobject equation_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -286,8 +484,8 @@
 android_glClipPlanex__I_3II
   (JNIEnv *_env, jobject _this, jint plane, jintArray equation_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *equation_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *equation = (GLfixed *) 0;
@@ -329,8 +527,8 @@
 android_glClipPlanex__ILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint plane, jobject equation_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -382,8 +580,8 @@
 android_glDeleteBuffers__I_3II
   (JNIEnv *_env, jobject _this, jint n, jintArray buffers_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLuint *buffers_base = (GLuint *) 0;
     jint _remaining;
     GLuint *buffers = (GLuint *) 0;
@@ -431,8 +629,8 @@
 android_glDeleteBuffers__ILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint n, jobject buffers_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -468,8 +666,8 @@
 android_glDrawElements__IIII
   (JNIEnv *_env, jobject _this, jint mode, jint count, jint type, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     glDrawElements(
         (GLenum)mode,
         (GLsizei)count,
@@ -486,8 +684,8 @@
 android_glGenBuffers__I_3II
   (JNIEnv *_env, jobject _this, jint n, jintArray buffers_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLuint *buffers_base = (GLuint *) 0;
     jint _remaining;
     GLuint *buffers = (GLuint *) 0;
@@ -535,8 +733,8 @@
 android_glGenBuffers__ILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint n, jobject buffers_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -571,75 +769,22 @@
 static void
 android_glGetBooleanv__I_3ZI
   (JNIEnv *_env, jobject _this, jint pname, jbooleanArray params_ref, jint offset) {
-    jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
-    GLboolean *params_base = (GLboolean *) 0;
-    jint _remaining;
-    GLboolean *params = (GLboolean *) 0;
-
-    if (!params_ref) {
-        _exception = 1;
-        _exceptionType = "java/lang/IllegalArgumentException";
-        _exceptionMessage = "params == null";
-        goto exit;
-    }
-    if (offset < 0) {
-        _exception = 1;
-        _exceptionType = "java/lang/IllegalArgumentException";
-        _exceptionMessage = "offset < 0";
-        goto exit;
-    }
-    _remaining = _env->GetArrayLength(params_ref) - offset;
-    params_base = (GLboolean *)
-        _env->GetPrimitiveArrayCritical(params_ref, (jboolean *)0);
-    params = params_base + offset;
-
-    glGetBooleanv(
-        (GLenum)pname,
-        (GLboolean *)params
-    );
-
-exit:
-    if (params_base) {
-        _env->ReleasePrimitiveArrayCritical(params_ref, params_base,
-            _exception ? JNI_ABORT: 0);
-    }
-    if (_exception) {
-        jniThrowException(_env, _exceptionType, _exceptionMessage);
-    }
+    get<jbooleanArray, GLboolean, glGetBooleanv>(_env, _this, pname, params_ref, offset);
 }
 
 /* void glGetBooleanv ( GLenum pname, GLboolean *params ) */
 static void
 android_glGetBooleanv__ILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint pname, jobject params_buf) {
-    jarray _array = (jarray) 0;
-    jint _bufferOffset = (jint) 0;
-    jint _remaining;
-    GLboolean *params = (GLboolean *) 0;
-
-    params = (GLboolean *)getPointer(_env, params_buf, &_array, &_remaining, &_bufferOffset);
-    if (params == NULL) {
-        char * _paramsBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
-        params = (GLboolean *) (_paramsBase + _bufferOffset);
-    }
-    glGetBooleanv(
-        (GLenum)pname,
-        (GLboolean *)params
-    );
-    if (_array) {
-        releasePointer(_env, _array, params, JNI_TRUE);
-    }
+    getarray<GLboolean, glGetBooleanv>(_env, _this, pname, params_buf);
 }
-
 /* void glGetBufferParameteriv ( GLenum target, GLenum pname, GLint *params ) */
 static void
 android_glGetBufferParameteriv__II_3II
   (JNIEnv *_env, jobject _this, jint target, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLint *params_base = (GLint *) 0;
     jint _remaining;
     GLint *params = (GLint *) 0;
@@ -688,8 +833,8 @@
 android_glGetBufferParameteriv__IILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint target, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -726,8 +871,8 @@
 android_glGetClipPlanef__I_3FI
   (JNIEnv *_env, jobject _this, jint pname, jfloatArray eqn_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *eqn_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *eqn = (GLfloat *) 0;
@@ -745,6 +890,12 @@
         goto exit;
     }
     _remaining = _env->GetArrayLength(eqn_ref) - offset;
+    if (_remaining < 4) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "length - offset < 4 < needed";
+        goto exit;
+    }
     eqn_base = (GLfloat *)
         _env->GetPrimitiveArrayCritical(eqn_ref, (jboolean *)0);
     eqn = eqn_base + offset;
@@ -768,12 +919,21 @@
 static void
 android_glGetClipPlanef__ILjava_nio_FloatBuffer_2
   (JNIEnv *_env, jobject _this, jint pname, jobject eqn_buf) {
+    jint _exception = 0;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
     GLfloat *eqn = (GLfloat *) 0;
 
     eqn = (GLfloat *)getPointer(_env, eqn_buf, &_array, &_remaining, &_bufferOffset);
+    if (_remaining < 4) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "remaining() < 4 < needed";
+        goto exit;
+    }
     if (eqn == NULL) {
         char * _eqnBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
         eqn = (GLfloat *) (_eqnBase + _bufferOffset);
@@ -782,8 +942,13 @@
         (GLenum)pname,
         (GLfloat *)eqn
     );
+
+exit:
     if (_array) {
-        releasePointer(_env, _array, eqn, JNI_TRUE);
+        releasePointer(_env, _array, eqn, _exception ? JNI_FALSE : JNI_TRUE);
+    }
+    if (_exception) {
+        jniThrowException(_env, _exceptionType, _exceptionMessage);
     }
 }
 
@@ -792,8 +957,8 @@
 android_glGetClipPlanex__I_3II
   (JNIEnv *_env, jobject _this, jint pname, jintArray eqn_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *eqn_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *eqn = (GLfixed *) 0;
@@ -811,6 +976,12 @@
         goto exit;
     }
     _remaining = _env->GetArrayLength(eqn_ref) - offset;
+    if (_remaining < 4) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "length - offset < 4 < needed";
+        goto exit;
+    }
     eqn_base = (GLfixed *)
         _env->GetPrimitiveArrayCritical(eqn_ref, (jboolean *)0);
     eqn = eqn_base + offset;
@@ -834,12 +1005,21 @@
 static void
 android_glGetClipPlanex__ILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint pname, jobject eqn_buf) {
+    jint _exception = 0;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
     GLfixed *eqn = (GLfixed *) 0;
 
     eqn = (GLfixed *)getPointer(_env, eqn_buf, &_array, &_remaining, &_bufferOffset);
+    if (_remaining < 4) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "remaining() < 4 < needed";
+        goto exit;
+    }
     if (eqn == NULL) {
         char * _eqnBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
         eqn = (GLfixed *) (_eqnBase + _bufferOffset);
@@ -848,8 +1028,13 @@
         (GLenum)pname,
         (GLfixed *)eqn
     );
+
+exit:
     if (_array) {
-        releasePointer(_env, _array, eqn, JNI_TRUE);
+        releasePointer(_env, _array, eqn, _exception ? JNI_FALSE : JNI_TRUE);
+    }
+    if (_exception) {
+        jniThrowException(_env, _exceptionType, _exceptionMessage);
     }
 }
 
@@ -858,8 +1043,8 @@
 android_glGetFixedv__I_3II
   (JNIEnv *_env, jobject _this, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *params_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *params = (GLfixed *) 0;
@@ -923,75 +1108,22 @@
 static void
 android_glGetFloatv__I_3FI
   (JNIEnv *_env, jobject _this, jint pname, jfloatArray params_ref, jint offset) {
-    jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
-    GLfloat *params_base = (GLfloat *) 0;
-    jint _remaining;
-    GLfloat *params = (GLfloat *) 0;
-
-    if (!params_ref) {
-        _exception = 1;
-        _exceptionType = "java/lang/IllegalArgumentException";
-        _exceptionMessage = "params == null";
-        goto exit;
-    }
-    if (offset < 0) {
-        _exception = 1;
-        _exceptionType = "java/lang/IllegalArgumentException";
-        _exceptionMessage = "offset < 0";
-        goto exit;
-    }
-    _remaining = _env->GetArrayLength(params_ref) - offset;
-    params_base = (GLfloat *)
-        _env->GetPrimitiveArrayCritical(params_ref, (jboolean *)0);
-    params = params_base + offset;
-
-    glGetFloatv(
-        (GLenum)pname,
-        (GLfloat *)params
-    );
-
-exit:
-    if (params_base) {
-        _env->ReleasePrimitiveArrayCritical(params_ref, params_base,
-            _exception ? JNI_ABORT: 0);
-    }
-    if (_exception) {
-        jniThrowException(_env, _exceptionType, _exceptionMessage);
-    }
+    get<jfloatArray, GLfloat, glGetFloatv>(_env, _this, pname, params_ref, offset);
 }
 
 /* void glGetFloatv ( GLenum pname, GLfloat *params ) */
 static void
 android_glGetFloatv__ILjava_nio_FloatBuffer_2
   (JNIEnv *_env, jobject _this, jint pname, jobject params_buf) {
-    jarray _array = (jarray) 0;
-    jint _bufferOffset = (jint) 0;
-    jint _remaining;
-    GLfloat *params = (GLfloat *) 0;
-
-    params = (GLfloat *)getPointer(_env, params_buf, &_array, &_remaining, &_bufferOffset);
-    if (params == NULL) {
-        char * _paramsBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
-        params = (GLfloat *) (_paramsBase + _bufferOffset);
-    }
-    glGetFloatv(
-        (GLenum)pname,
-        (GLfloat *)params
-    );
-    if (_array) {
-        releasePointer(_env, _array, params, JNI_TRUE);
-    }
+    getarray<GLfloat, glGetFloatv>(_env, _this, pname, params_buf);
 }
-
 /* void glGetLightfv ( GLenum light, GLenum pname, GLfloat *params ) */
 static void
 android_glGetLightfv__II_3FI
   (JNIEnv *_env, jobject _this, jint light, jint pname, jfloatArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *params_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *params = (GLfloat *) 0;
@@ -1011,23 +1143,6 @@
     _remaining = _env->GetArrayLength(params_ref) - offset;
     int _needed;
     switch (pname) {
-#if defined(GL_SPOT_EXPONENT)
-        case GL_SPOT_EXPONENT:
-#endif // defined(GL_SPOT_EXPONENT)
-#if defined(GL_SPOT_CUTOFF)
-        case GL_SPOT_CUTOFF:
-#endif // defined(GL_SPOT_CUTOFF)
-#if defined(GL_CONSTANT_ATTENUATION)
-        case GL_CONSTANT_ATTENUATION:
-#endif // defined(GL_CONSTANT_ATTENUATION)
-#if defined(GL_LINEAR_ATTENUATION)
-        case GL_LINEAR_ATTENUATION:
-#endif // defined(GL_LINEAR_ATTENUATION)
-#if defined(GL_QUADRATIC_ATTENUATION)
-        case GL_QUADRATIC_ATTENUATION:
-#endif // defined(GL_QUADRATIC_ATTENUATION)
-            _needed = 1;
-            break;
 #if defined(GL_SPOT_DIRECTION)
         case GL_SPOT_DIRECTION:
 #endif // defined(GL_SPOT_DIRECTION)
@@ -1048,7 +1163,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -1082,8 +1197,8 @@
 android_glGetLightfv__IILjava_nio_FloatBuffer_2
   (JNIEnv *_env, jobject _this, jint light, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -1092,23 +1207,6 @@
     params = (GLfloat *)getPointer(_env, params_buf, &_array, &_remaining, &_bufferOffset);
     int _needed;
     switch (pname) {
-#if defined(GL_SPOT_EXPONENT)
-        case GL_SPOT_EXPONENT:
-#endif // defined(GL_SPOT_EXPONENT)
-#if defined(GL_SPOT_CUTOFF)
-        case GL_SPOT_CUTOFF:
-#endif // defined(GL_SPOT_CUTOFF)
-#if defined(GL_CONSTANT_ATTENUATION)
-        case GL_CONSTANT_ATTENUATION:
-#endif // defined(GL_CONSTANT_ATTENUATION)
-#if defined(GL_LINEAR_ATTENUATION)
-        case GL_LINEAR_ATTENUATION:
-#endif // defined(GL_LINEAR_ATTENUATION)
-#if defined(GL_QUADRATIC_ATTENUATION)
-        case GL_QUADRATIC_ATTENUATION:
-#endif // defined(GL_QUADRATIC_ATTENUATION)
-            _needed = 1;
-            break;
 #if defined(GL_SPOT_DIRECTION)
         case GL_SPOT_DIRECTION:
 #endif // defined(GL_SPOT_DIRECTION)
@@ -1129,7 +1227,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -1162,8 +1260,8 @@
 android_glGetLightxv__II_3II
   (JNIEnv *_env, jobject _this, jint light, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *params_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *params = (GLfixed *) 0;
@@ -1183,23 +1281,6 @@
     _remaining = _env->GetArrayLength(params_ref) - offset;
     int _needed;
     switch (pname) {
-#if defined(GL_SPOT_EXPONENT)
-        case GL_SPOT_EXPONENT:
-#endif // defined(GL_SPOT_EXPONENT)
-#if defined(GL_SPOT_CUTOFF)
-        case GL_SPOT_CUTOFF:
-#endif // defined(GL_SPOT_CUTOFF)
-#if defined(GL_CONSTANT_ATTENUATION)
-        case GL_CONSTANT_ATTENUATION:
-#endif // defined(GL_CONSTANT_ATTENUATION)
-#if defined(GL_LINEAR_ATTENUATION)
-        case GL_LINEAR_ATTENUATION:
-#endif // defined(GL_LINEAR_ATTENUATION)
-#if defined(GL_QUADRATIC_ATTENUATION)
-        case GL_QUADRATIC_ATTENUATION:
-#endif // defined(GL_QUADRATIC_ATTENUATION)
-            _needed = 1;
-            break;
 #if defined(GL_SPOT_DIRECTION)
         case GL_SPOT_DIRECTION:
 #endif // defined(GL_SPOT_DIRECTION)
@@ -1220,7 +1301,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -1254,8 +1335,8 @@
 android_glGetLightxv__IILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint light, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -1264,23 +1345,6 @@
     params = (GLfixed *)getPointer(_env, params_buf, &_array, &_remaining, &_bufferOffset);
     int _needed;
     switch (pname) {
-#if defined(GL_SPOT_EXPONENT)
-        case GL_SPOT_EXPONENT:
-#endif // defined(GL_SPOT_EXPONENT)
-#if defined(GL_SPOT_CUTOFF)
-        case GL_SPOT_CUTOFF:
-#endif // defined(GL_SPOT_CUTOFF)
-#if defined(GL_CONSTANT_ATTENUATION)
-        case GL_CONSTANT_ATTENUATION:
-#endif // defined(GL_CONSTANT_ATTENUATION)
-#if defined(GL_LINEAR_ATTENUATION)
-        case GL_LINEAR_ATTENUATION:
-#endif // defined(GL_LINEAR_ATTENUATION)
-#if defined(GL_QUADRATIC_ATTENUATION)
-        case GL_QUADRATIC_ATTENUATION:
-#endif // defined(GL_QUADRATIC_ATTENUATION)
-            _needed = 1;
-            break;
 #if defined(GL_SPOT_DIRECTION)
         case GL_SPOT_DIRECTION:
 #endif // defined(GL_SPOT_DIRECTION)
@@ -1301,7 +1365,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -1334,8 +1398,8 @@
 android_glGetMaterialfv__II_3FI
   (JNIEnv *_env, jobject _this, jint face, jint pname, jfloatArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *params_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *params = (GLfloat *) 0;
@@ -1355,11 +1419,6 @@
     _remaining = _env->GetArrayLength(params_ref) - offset;
     int _needed;
     switch (pname) {
-#if defined(GL_SHININESS)
-        case GL_SHININESS:
-#endif // defined(GL_SHININESS)
-            _needed = 1;
-            break;
 #if defined(GL_AMBIENT)
         case GL_AMBIENT:
 #endif // defined(GL_AMBIENT)
@@ -1378,7 +1437,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -1412,8 +1471,8 @@
 android_glGetMaterialfv__IILjava_nio_FloatBuffer_2
   (JNIEnv *_env, jobject _this, jint face, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -1422,11 +1481,6 @@
     params = (GLfloat *)getPointer(_env, params_buf, &_array, &_remaining, &_bufferOffset);
     int _needed;
     switch (pname) {
-#if defined(GL_SHININESS)
-        case GL_SHININESS:
-#endif // defined(GL_SHININESS)
-            _needed = 1;
-            break;
 #if defined(GL_AMBIENT)
         case GL_AMBIENT:
 #endif // defined(GL_AMBIENT)
@@ -1445,7 +1499,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -1478,8 +1532,8 @@
 android_glGetMaterialxv__II_3II
   (JNIEnv *_env, jobject _this, jint face, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *params_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *params = (GLfixed *) 0;
@@ -1499,11 +1553,6 @@
     _remaining = _env->GetArrayLength(params_ref) - offset;
     int _needed;
     switch (pname) {
-#if defined(GL_SHININESS)
-        case GL_SHININESS:
-#endif // defined(GL_SHININESS)
-            _needed = 1;
-            break;
 #if defined(GL_AMBIENT)
         case GL_AMBIENT:
 #endif // defined(GL_AMBIENT)
@@ -1522,7 +1571,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -1556,8 +1605,8 @@
 android_glGetMaterialxv__IILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint face, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -1566,11 +1615,6 @@
     params = (GLfixed *)getPointer(_env, params_buf, &_array, &_remaining, &_bufferOffset);
     int _needed;
     switch (pname) {
-#if defined(GL_SHININESS)
-        case GL_SHININESS:
-#endif // defined(GL_SHININESS)
-            _needed = 1;
-            break;
 #if defined(GL_AMBIENT)
         case GL_AMBIENT:
 #endif // defined(GL_AMBIENT)
@@ -1589,7 +1633,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -1622,8 +1666,8 @@
 android_glGetTexEnvfv__II_3FI
   (JNIEnv *_env, jobject _this, jint env, jint pname, jfloatArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *params_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *params = (GLfloat *) 0;
@@ -1643,24 +1687,13 @@
     _remaining = _env->GetArrayLength(params_ref) - offset;
     int _needed;
     switch (pname) {
-#if defined(GL_TEXTURE_ENV_MODE)
-        case GL_TEXTURE_ENV_MODE:
-#endif // defined(GL_TEXTURE_ENV_MODE)
-#if defined(GL_COMBINE_RGB)
-        case GL_COMBINE_RGB:
-#endif // defined(GL_COMBINE_RGB)
-#if defined(GL_COMBINE_ALPHA)
-        case GL_COMBINE_ALPHA:
-#endif // defined(GL_COMBINE_ALPHA)
-            _needed = 1;
-            break;
 #if defined(GL_TEXTURE_ENV_COLOR)
         case GL_TEXTURE_ENV_COLOR:
 #endif // defined(GL_TEXTURE_ENV_COLOR)
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -1694,8 +1727,8 @@
 android_glGetTexEnvfv__IILjava_nio_FloatBuffer_2
   (JNIEnv *_env, jobject _this, jint env, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -1704,24 +1737,13 @@
     params = (GLfloat *)getPointer(_env, params_buf, &_array, &_remaining, &_bufferOffset);
     int _needed;
     switch (pname) {
-#if defined(GL_TEXTURE_ENV_MODE)
-        case GL_TEXTURE_ENV_MODE:
-#endif // defined(GL_TEXTURE_ENV_MODE)
-#if defined(GL_COMBINE_RGB)
-        case GL_COMBINE_RGB:
-#endif // defined(GL_COMBINE_RGB)
-#if defined(GL_COMBINE_ALPHA)
-        case GL_COMBINE_ALPHA:
-#endif // defined(GL_COMBINE_ALPHA)
-            _needed = 1;
-            break;
 #if defined(GL_TEXTURE_ENV_COLOR)
         case GL_TEXTURE_ENV_COLOR:
 #endif // defined(GL_TEXTURE_ENV_COLOR)
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -1754,8 +1776,8 @@
 android_glGetTexEnviv__II_3II
   (JNIEnv *_env, jobject _this, jint env, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLint *params_base = (GLint *) 0;
     jint _remaining;
     GLint *params = (GLint *) 0;
@@ -1775,24 +1797,13 @@
     _remaining = _env->GetArrayLength(params_ref) - offset;
     int _needed;
     switch (pname) {
-#if defined(GL_TEXTURE_ENV_MODE)
-        case GL_TEXTURE_ENV_MODE:
-#endif // defined(GL_TEXTURE_ENV_MODE)
-#if defined(GL_COMBINE_RGB)
-        case GL_COMBINE_RGB:
-#endif // defined(GL_COMBINE_RGB)
-#if defined(GL_COMBINE_ALPHA)
-        case GL_COMBINE_ALPHA:
-#endif // defined(GL_COMBINE_ALPHA)
-            _needed = 1;
-            break;
 #if defined(GL_TEXTURE_ENV_COLOR)
         case GL_TEXTURE_ENV_COLOR:
 #endif // defined(GL_TEXTURE_ENV_COLOR)
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -1826,8 +1837,8 @@
 android_glGetTexEnviv__IILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint env, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -1836,24 +1847,13 @@
     params = (GLint *)getPointer(_env, params_buf, &_array, &_remaining, &_bufferOffset);
     int _needed;
     switch (pname) {
-#if defined(GL_TEXTURE_ENV_MODE)
-        case GL_TEXTURE_ENV_MODE:
-#endif // defined(GL_TEXTURE_ENV_MODE)
-#if defined(GL_COMBINE_RGB)
-        case GL_COMBINE_RGB:
-#endif // defined(GL_COMBINE_RGB)
-#if defined(GL_COMBINE_ALPHA)
-        case GL_COMBINE_ALPHA:
-#endif // defined(GL_COMBINE_ALPHA)
-            _needed = 1;
-            break;
 #if defined(GL_TEXTURE_ENV_COLOR)
         case GL_TEXTURE_ENV_COLOR:
 #endif // defined(GL_TEXTURE_ENV_COLOR)
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -1886,8 +1886,8 @@
 android_glGetTexEnvxv__II_3II
   (JNIEnv *_env, jobject _this, jint env, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *params_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *params = (GLfixed *) 0;
@@ -1907,24 +1907,13 @@
     _remaining = _env->GetArrayLength(params_ref) - offset;
     int _needed;
     switch (pname) {
-#if defined(GL_TEXTURE_ENV_MODE)
-        case GL_TEXTURE_ENV_MODE:
-#endif // defined(GL_TEXTURE_ENV_MODE)
-#if defined(GL_COMBINE_RGB)
-        case GL_COMBINE_RGB:
-#endif // defined(GL_COMBINE_RGB)
-#if defined(GL_COMBINE_ALPHA)
-        case GL_COMBINE_ALPHA:
-#endif // defined(GL_COMBINE_ALPHA)
-            _needed = 1;
-            break;
 #if defined(GL_TEXTURE_ENV_COLOR)
         case GL_TEXTURE_ENV_COLOR:
 #endif // defined(GL_TEXTURE_ENV_COLOR)
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -1958,8 +1947,8 @@
 android_glGetTexEnvxv__IILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint env, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -1968,24 +1957,13 @@
     params = (GLfixed *)getPointer(_env, params_buf, &_array, &_remaining, &_bufferOffset);
     int _needed;
     switch (pname) {
-#if defined(GL_TEXTURE_ENV_MODE)
-        case GL_TEXTURE_ENV_MODE:
-#endif // defined(GL_TEXTURE_ENV_MODE)
-#if defined(GL_COMBINE_RGB)
-        case GL_COMBINE_RGB:
-#endif // defined(GL_COMBINE_RGB)
-#if defined(GL_COMBINE_ALPHA)
-        case GL_COMBINE_ALPHA:
-#endif // defined(GL_COMBINE_ALPHA)
-            _needed = 1;
-            break;
 #if defined(GL_TEXTURE_ENV_COLOR)
         case GL_TEXTURE_ENV_COLOR:
 #endif // defined(GL_TEXTURE_ENV_COLOR)
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -2018,8 +1996,8 @@
 android_glGetTexParameterfv__II_3FI
   (JNIEnv *_env, jobject _this, jint target, jint pname, jfloatArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *params_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *params = (GLfloat *) 0;
@@ -2068,8 +2046,8 @@
 android_glGetTexParameterfv__IILjava_nio_FloatBuffer_2
   (JNIEnv *_env, jobject _this, jint target, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -2106,8 +2084,8 @@
 android_glGetTexParameteriv__II_3II
   (JNIEnv *_env, jobject _this, jint target, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLint *params_base = (GLint *) 0;
     jint _remaining;
     GLint *params = (GLint *) 0;
@@ -2156,8 +2134,8 @@
 android_glGetTexParameteriv__IILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint target, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -2194,8 +2172,8 @@
 android_glGetTexParameterxv__II_3II
   (JNIEnv *_env, jobject _this, jint target, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *params_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *params = (GLfixed *) 0;
@@ -2244,8 +2222,8 @@
 android_glGetTexParameterxv__IILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint target, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -2336,8 +2314,8 @@
 android_glPointParameterfv__I_3FI
   (JNIEnv *_env, jobject _this, jint pname, jfloatArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *params_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *params = (GLfloat *) 0;
@@ -2385,8 +2363,8 @@
 android_glPointParameterfv__ILjava_nio_FloatBuffer_2
   (JNIEnv *_env, jobject _this, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -2432,8 +2410,8 @@
 android_glPointParameterxv__I_3II
   (JNIEnv *_env, jobject _this, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *params_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *params = (GLfixed *) 0;
@@ -2481,8 +2459,8 @@
 android_glPointParameterxv__ILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -2564,8 +2542,8 @@
 android_glTexEnviv__II_3II
   (JNIEnv *_env, jobject _this, jint target, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLint *params_base = (GLint *) 0;
     jint _remaining;
     GLint *params = (GLint *) 0;
@@ -2585,24 +2563,13 @@
     _remaining = _env->GetArrayLength(params_ref) - offset;
     int _needed;
     switch (pname) {
-#if defined(GL_TEXTURE_ENV_MODE)
-        case GL_TEXTURE_ENV_MODE:
-#endif // defined(GL_TEXTURE_ENV_MODE)
-#if defined(GL_COMBINE_RGB)
-        case GL_COMBINE_RGB:
-#endif // defined(GL_COMBINE_RGB)
-#if defined(GL_COMBINE_ALPHA)
-        case GL_COMBINE_ALPHA:
-#endif // defined(GL_COMBINE_ALPHA)
-            _needed = 1;
-            break;
 #if defined(GL_TEXTURE_ENV_COLOR)
         case GL_TEXTURE_ENV_COLOR:
 #endif // defined(GL_TEXTURE_ENV_COLOR)
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -2636,8 +2603,8 @@
 android_glTexEnviv__IILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint target, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -2646,24 +2613,13 @@
     params = (GLint *)getPointer(_env, params_buf, &_array, &_remaining, &_bufferOffset);
     int _needed;
     switch (pname) {
-#if defined(GL_TEXTURE_ENV_MODE)
-        case GL_TEXTURE_ENV_MODE:
-#endif // defined(GL_TEXTURE_ENV_MODE)
-#if defined(GL_COMBINE_RGB)
-        case GL_COMBINE_RGB:
-#endif // defined(GL_COMBINE_RGB)
-#if defined(GL_COMBINE_ALPHA)
-        case GL_COMBINE_ALPHA:
-#endif // defined(GL_COMBINE_ALPHA)
-            _needed = 1;
-            break;
 #if defined(GL_TEXTURE_ENV_COLOR)
         case GL_TEXTURE_ENV_COLOR:
 #endif // defined(GL_TEXTURE_ENV_COLOR)
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -2696,8 +2652,8 @@
 android_glTexParameterfv__II_3FI
   (JNIEnv *_env, jobject _this, jint target, jint pname, jfloatArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *params_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *params = (GLfloat *) 0;
@@ -2746,8 +2702,8 @@
 android_glTexParameterfv__IILjava_nio_FloatBuffer_2
   (JNIEnv *_env, jobject _this, jint target, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -2795,8 +2751,8 @@
 android_glTexParameteriv__II_3II
   (JNIEnv *_env, jobject _this, jint target, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLint *params_base = (GLint *) 0;
     jint _remaining;
     GLint *params = (GLint *) 0;
@@ -2845,8 +2801,8 @@
 android_glTexParameteriv__IILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint target, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -2883,8 +2839,8 @@
 android_glTexParameterxv__II_3II
   (JNIEnv *_env, jobject _this, jint target, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *params_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *params = (GLfixed *) 0;
@@ -2933,8 +2889,8 @@
 android_glTexParameterxv__IILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint target, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
diff --git a/core/jni/android_opengl_GLES11Ext.cpp b/core/jni/android_opengl_GLES11Ext.cpp
index 073bbb2..c91baa2 100644
--- a/core/jni/android_opengl_GLES11Ext.cpp
+++ b/core/jni/android_opengl_GLES11Ext.cpp
@@ -17,23 +17,14 @@
 
 // This source file is automatically generated
 
+#include <GLES/gl.h>
+#include <GLES/glext.h>
+
 #include "jni.h"
 #include "JNIHelp.h"
 #include <android_runtime/AndroidRuntime.h>
 #include <utils/misc.h>
-
 #include <assert.h>
-#include <GLES/gl.h>
-#include <GLES/glext.h>
-
-/* special calls implemented in Android's GLES wrapper used to more
- * efficiently bound-check passed arrays */
-extern "C" {
-GL_API void GL_APIENTRY glMatrixIndexPointerOESBounds(GLint size, GLenum type, GLsizei stride,
-        const GLvoid *ptr, GLsizei count);
-GL_API void GL_APIENTRY glWeightPointerOESBounds(GLint size, GLenum type, GLsizei stride,
-        const GLvoid *ptr, GLsizei count);
-}
 
 static int initialized = 0;
 
@@ -46,6 +37,34 @@
 static jfieldID limitID;
 static jfieldID elementSizeShiftID;
 
+
+/* special calls implemented in Android's GLES wrapper used to more
+ * efficiently bound-check passed arrays */
+extern "C" {
+#ifdef GL_VERSION_ES_CM_1_1
+GL_API void GL_APIENTRY glColorPointerBounds(GLint size, GLenum type, GLsizei stride,
+        const GLvoid *ptr, GLsizei count);
+GL_API void GL_APIENTRY glNormalPointerBounds(GLenum type, GLsizei stride,
+        const GLvoid *pointer, GLsizei count);
+GL_API void GL_APIENTRY glTexCoordPointerBounds(GLint size, GLenum type,
+        GLsizei stride, const GLvoid *pointer, GLsizei count);
+GL_API void GL_APIENTRY glVertexPointerBounds(GLint size, GLenum type,
+        GLsizei stride, const GLvoid *pointer, GLsizei count);
+GL_API void GL_APIENTRY glPointSizePointerOESBounds(GLenum type,
+        GLsizei stride, const GLvoid *pointer, GLsizei count);
+GL_API void GL_APIENTRY glMatrixIndexPointerOESBounds(GLint size, GLenum type,
+        GLsizei stride, const GLvoid *pointer, GLsizei count);
+GL_API void GL_APIENTRY glWeightPointerOESBounds(GLint size, GLenum type,
+        GLsizei stride, const GLvoid *pointer, GLsizei count);
+#endif
+#ifdef GL_ES_VERSION_2_0
+static void glVertexAttribPointerBounds(GLuint indx, GLint size, GLenum type,
+        GLboolean normalized, GLsizei stride, const GLvoid *pointer, GLsizei count) {
+    glVertexAttribPointer(indx, size, type, normalized, stride, pointer);
+}
+#endif
+}
+
 /* Cache method IDs each time the class is loaded. */
 
 static void
@@ -70,7 +89,6 @@
         _env->GetFieldID(bufferClass, "_elementSizeShift", "I");
 }
 
-
 static void *
 getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining, jint *offset)
 {
@@ -94,15 +112,15 @@
             getBaseArrayID, buffer);
     *offset = _env->CallStaticIntMethod(nioAccessClass,
             getBaseArrayOffsetID, buffer);
+
     return NULL;
 }
 
-
 static void
 releasePointer(JNIEnv *_env, jarray array, void *data, jboolean commit)
 {
     _env->ReleasePrimitiveArrayCritical(array, data,
-					   commit ? 0 : JNI_ABORT);
+                       commit ? 0 : JNI_ABORT);
 }
 
 static void *
@@ -118,6 +136,186 @@
     }
     return (void*) buf;
 }
+
+// --------------------------------------------------------------------------
+
+/*
+ * returns the number of values glGet returns for a given pname.
+ *
+ * The code below is written such that pnames requiring only one values
+ * are the default (and are not explicitely tested for). This makes the
+ * checking code much shorter/readable/efficient.
+ *
+ * This means that unknown pnames (e.g.: extensions) will default to 1. If
+ * that unknown pname needs more than 1 value, then the validation check
+ * is incomplete and the app may crash if it passed the wrong number params.
+ */
+static int getNeededCount(GLint pname) {
+    int needed = 1;
+#ifdef GL_ES_VERSION_2_0
+    // GLES 2.x pnames
+    switch (pname) {
+        case GL_ALIASED_LINE_WIDTH_RANGE:
+        case GL_ALIASED_POINT_SIZE_RANGE:
+            needed = 2;
+            break;
+
+        case GL_BLEND_COLOR:
+        case GL_COLOR_CLEAR_VALUE:
+        case GL_COLOR_WRITEMASK:
+        case GL_SCISSOR_BOX:
+        case GL_VIEWPORT:
+            needed = 4;
+            break;
+
+        case GL_COMPRESSED_TEXTURE_FORMATS:
+            glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &needed);
+            break;
+
+        case GL_SHADER_BINARY_FORMATS:
+            glGetIntegerv(GL_NUM_SHADER_BINARY_FORMATS, &needed);
+            break;
+    }
+#endif
+
+#ifdef GL_VERSION_ES_CM_1_1
+    // GLES 1.x pnames
+    switch (pname) {
+        case GL_ALIASED_LINE_WIDTH_RANGE:
+        case GL_ALIASED_POINT_SIZE_RANGE:
+        case GL_DEPTH_RANGE:
+        case GL_SMOOTH_LINE_WIDTH_RANGE:
+        case GL_SMOOTH_POINT_SIZE_RANGE:
+            needed = 2;
+            break;
+
+        case GL_CURRENT_NORMAL:
+        case GL_POINT_DISTANCE_ATTENUATION:
+            needed = 3;
+            break;
+
+        case GL_COLOR_CLEAR_VALUE:
+        case GL_COLOR_WRITEMASK:
+        case GL_CURRENT_COLOR:
+        case GL_CURRENT_TEXTURE_COORDS:
+        case GL_FOG_COLOR:
+        case GL_LIGHT_MODEL_AMBIENT:
+        case GL_SCISSOR_BOX:
+        case GL_VIEWPORT:
+            needed = 4;
+            break;
+
+        case GL_MODELVIEW_MATRIX:
+        case GL_PROJECTION_MATRIX:
+        case GL_TEXTURE_MATRIX:
+            needed = 16;
+            break;
+
+        case GL_COMPRESSED_TEXTURE_FORMATS:
+            glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &needed);
+            break;
+    }
+#endif
+    return needed;
+}
+
+template <typename JTYPEARRAY, typename CTYPE, void GET(GLenum, CTYPE*)>
+static void
+get
+  (JNIEnv *_env, jobject _this, jint pname, JTYPEARRAY params_ref, jint offset) {
+    jint _exception = 0;
+    const char * _exceptionType;
+    const char * _exceptionMessage;
+    CTYPE *params_base = (CTYPE *) 0;
+    jint _remaining;
+    CTYPE *params = (CTYPE *) 0;
+    int _needed = 0;
+
+    if (!params_ref) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "params == null";
+        goto exit;
+    }
+    if (offset < 0) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "offset < 0";
+        goto exit;
+    }
+    _remaining = _env->GetArrayLength(params_ref) - offset;
+    _needed = getNeededCount(pname);
+    // if we didn't find this pname, we just assume the user passed
+    // an array of the right size -- this might happen with extensions
+    // or if we forget an enum here.
+    if (_remaining < _needed) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "length - offset < needed";
+        goto exit;
+    }
+    params_base = (CTYPE *)
+        _env->GetPrimitiveArrayCritical(params_ref, (jboolean *)0);
+    params = params_base + offset;
+
+    GET(
+        (GLenum)pname,
+        (CTYPE *)params
+    );
+
+exit:
+    if (params_base) {
+        _env->ReleasePrimitiveArrayCritical(params_ref, params_base,
+            _exception ? JNI_ABORT: 0);
+    }
+    if (_exception) {
+        jniThrowException(_env, _exceptionType, _exceptionMessage);
+    }
+}
+
+
+template <typename CTYPE, void GET(GLenum, CTYPE*)>
+static void
+getarray
+  (JNIEnv *_env, jobject _this, jint pname, jobject params_buf) {
+    jint _exception = 0;
+    const char * _exceptionType;
+    const char * _exceptionMessage;
+    jarray _array = (jarray) 0;
+    jint _bufferOffset = (jint) 0;
+    jint _remaining;
+    CTYPE *params = (CTYPE *) 0;
+    int _needed = 0;
+
+    params = (CTYPE *)getPointer(_env, params_buf, &_array, &_remaining, &_bufferOffset);
+    _needed = getNeededCount(pname);
+    // if we didn't find this pname, we just assume the user passed
+    // an array of the right size -- this might happen with extensions
+    // or if we forget an enum here.
+    if (_needed>0 && _remaining < _needed) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "remaining() < needed";
+        goto exit;
+    }
+    if (params == NULL) {
+        char * _paramsBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
+        params = (CTYPE *) (_paramsBase + _bufferOffset);
+    }
+    GET(
+        (GLenum)pname,
+        (CTYPE *)params
+    );
+
+exit:
+    if (_array) {
+        releasePointer(_env, _array, params, _exception ? JNI_FALSE : JNI_TRUE);
+    }
+    if (_exception) {
+        jniThrowException(_env, _exceptionType, _exceptionMessage);
+    }
+}
+
 // --------------------------------------------------------------------------
 /* void glBlendEquationSeparateOES ( GLenum modeRGB, GLenum modeAlpha ) */
 static void
@@ -194,8 +392,8 @@
 android_glDrawTexsvOES___3SI
   (JNIEnv *_env, jobject _this, jshortArray coords_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLshort *coords_base = (GLshort *) 0;
     jint _remaining;
     GLshort *coords = (GLshort *) 0;
@@ -242,8 +440,8 @@
 android_glDrawTexsvOES__Ljava_nio_ShortBuffer_2
   (JNIEnv *_env, jobject _this, jobject coords_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -278,8 +476,8 @@
 android_glDrawTexivOES___3II
   (JNIEnv *_env, jobject _this, jintArray coords_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLint *coords_base = (GLint *) 0;
     jint _remaining;
     GLint *coords = (GLint *) 0;
@@ -326,8 +524,8 @@
 android_glDrawTexivOES__Ljava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jobject coords_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -362,8 +560,8 @@
 android_glDrawTexxvOES___3II
   (JNIEnv *_env, jobject _this, jintArray coords_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *coords_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *coords = (GLfixed *) 0;
@@ -410,8 +608,8 @@
 android_glDrawTexxvOES__Ljava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jobject coords_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -459,8 +657,8 @@
 android_glDrawTexfvOES___3FI
   (JNIEnv *_env, jobject _this, jfloatArray coords_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *coords_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *coords = (GLfloat *) 0;
@@ -507,8 +705,8 @@
 android_glDrawTexfvOES__Ljava_nio_FloatBuffer_2
   (JNIEnv *_env, jobject _this, jobject coords_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -620,8 +818,8 @@
 android_glClipPlanexOES__I_3II
   (JNIEnv *_env, jobject _this, jint plane, jintArray equation_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *equation_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *equation = (GLfixed *) 0;
@@ -718,8 +916,8 @@
 android_glFogxvOES__I_3II
   (JNIEnv *_env, jobject _this, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *params_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *params = (GLfixed *) 0;
@@ -798,8 +996,8 @@
 android_glGetClipPlanexOES__I_3II
   (JNIEnv *_env, jobject _this, jint pname, jintArray eqn_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *eqn_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *eqn = (GLfixed *) 0;
@@ -847,8 +1045,8 @@
 android_glGetClipPlanexOES__ILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint pname, jobject eqn_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -884,8 +1082,8 @@
 android_glGetFixedvOES__I_3II
   (JNIEnv *_env, jobject _this, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *params_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *params = (GLfixed *) 0;
@@ -950,8 +1148,8 @@
 android_glGetLightxvOES__II_3II
   (JNIEnv *_env, jobject _this, jint light, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *params_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *params = (GLfixed *) 0;
@@ -1018,8 +1216,8 @@
 android_glGetMaterialxvOES__II_3II
   (JNIEnv *_env, jobject _this, jint face, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *params_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *params = (GLfixed *) 0;
@@ -1086,8 +1284,8 @@
 android_glGetTexEnvxvOES__II_3II
   (JNIEnv *_env, jobject _this, jint env, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *params_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *params = (GLfixed *) 0;
@@ -1154,8 +1352,8 @@
 android_glGetTexParameterxvOES__II_3II
   (JNIEnv *_env, jobject _this, jint target, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *params_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *params = (GLfixed *) 0;
@@ -1232,8 +1430,8 @@
 android_glLightModelxvOES__I_3II
   (JNIEnv *_env, jobject _this, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *params_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *params = (GLfixed *) 0;
@@ -1309,8 +1507,8 @@
 android_glLightxvOES__II_3II
   (JNIEnv *_env, jobject _this, jint light, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *params_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *params = (GLfixed *) 0;
@@ -1386,8 +1584,8 @@
 android_glLoadMatrixxOES___3II
   (JNIEnv *_env, jobject _this, jintArray m_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *m_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *m = (GLfixed *) 0;
@@ -1461,8 +1659,8 @@
 android_glMaterialxvOES__II_3II
   (JNIEnv *_env, jobject _this, jint face, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *params_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *params = (GLfixed *) 0;
@@ -1529,8 +1727,8 @@
 android_glMultMatrixxOES___3II
   (JNIEnv *_env, jobject _this, jintArray m_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *m_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *m = (GLfixed *) 0;
@@ -1641,8 +1839,8 @@
 android_glPointParameterxvOES__I_3II
   (JNIEnv *_env, jobject _this, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *params_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *params = (GLfixed *) 0;
@@ -1770,8 +1968,8 @@
 android_glTexEnvxvOES__II_3II
   (JNIEnv *_env, jobject _this, jint target, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *params_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *params = (GLfixed *) 0;
@@ -1849,8 +2047,8 @@
 android_glTexParameterxvOES__II_3II
   (JNIEnv *_env, jobject _this, jint target, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *params_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *params = (GLfixed *) 0;
@@ -1949,8 +2147,8 @@
 android_glDeleteRenderbuffersOES__I_3II
   (JNIEnv *_env, jobject _this, jint n, jintArray renderbuffers_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLuint *renderbuffers_base = (GLuint *) 0;
     jint _remaining;
     GLuint *renderbuffers = (GLuint *) 0;
@@ -1998,8 +2196,8 @@
 android_glDeleteRenderbuffersOES__ILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint n, jobject renderbuffers_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -2035,8 +2233,8 @@
 android_glGenRenderbuffersOES__I_3II
   (JNIEnv *_env, jobject _this, jint n, jintArray renderbuffers_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLuint *renderbuffers_base = (GLuint *) 0;
     jint _remaining;
     GLuint *renderbuffers = (GLuint *) 0;
@@ -2084,8 +2282,8 @@
 android_glGenRenderbuffersOES__ILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint n, jobject renderbuffers_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -2133,8 +2331,8 @@
 android_glGetRenderbufferParameterivOES__II_3II
   (JNIEnv *_env, jobject _this, jint target, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLint *params_base = (GLint *) 0;
     jint _remaining;
     GLint *params = (GLint *) 0;
@@ -2183,8 +2381,8 @@
 android_glGetRenderbufferParameterivOES__IILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint target, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -2242,8 +2440,8 @@
 android_glDeleteFramebuffersOES__I_3II
   (JNIEnv *_env, jobject _this, jint n, jintArray framebuffers_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLuint *framebuffers_base = (GLuint *) 0;
     jint _remaining;
     GLuint *framebuffers = (GLuint *) 0;
@@ -2291,8 +2489,8 @@
 android_glDeleteFramebuffersOES__ILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint n, jobject framebuffers_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -2328,8 +2526,8 @@
 android_glGenFramebuffersOES__I_3II
   (JNIEnv *_env, jobject _this, jint n, jintArray framebuffers_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLuint *framebuffers_base = (GLuint *) 0;
     jint _remaining;
     GLuint *framebuffers = (GLuint *) 0;
@@ -2377,8 +2575,8 @@
 android_glGenFramebuffersOES__ILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint n, jobject framebuffers_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -2450,8 +2648,8 @@
 android_glGetFramebufferAttachmentParameterivOES__III_3II
   (JNIEnv *_env, jobject _this, jint target, jint attachment, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLint *params_base = (GLint *) 0;
     jint _remaining;
     GLint *params = (GLint *) 0;
@@ -2501,8 +2699,8 @@
 android_glGetFramebufferAttachmentParameterivOES__IIILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint target, jint attachment, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -2651,8 +2849,8 @@
 android_glClipPlanefOES__I_3FI
   (JNIEnv *_env, jobject _this, jint plane, jfloatArray equation_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *equation_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *equation = (GLfloat *) 0;
@@ -2717,8 +2915,8 @@
 android_glGetClipPlanefOES__I_3FI
   (JNIEnv *_env, jobject _this, jint pname, jfloatArray eqn_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *eqn_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *eqn = (GLfloat *) 0;
@@ -2766,8 +2964,8 @@
 android_glGetClipPlanefOES__ILjava_nio_FloatBuffer_2
   (JNIEnv *_env, jobject _this, jint pname, jobject eqn_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -2823,8 +3021,8 @@
 android_glTexGenfvOES__II_3FI
   (JNIEnv *_env, jobject _this, jint coord, jint pname, jfloatArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *params_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *params = (GLfloat *) 0;
@@ -2902,8 +3100,8 @@
 android_glTexGenivOES__II_3II
   (JNIEnv *_env, jobject _this, jint coord, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLint *params_base = (GLint *) 0;
     jint _remaining;
     GLint *params = (GLint *) 0;
@@ -2981,8 +3179,8 @@
 android_glTexGenxvOES__II_3II
   (JNIEnv *_env, jobject _this, jint coord, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *params_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *params = (GLfixed *) 0;
@@ -3049,8 +3247,8 @@
 android_glGetTexGenfvOES__II_3FI
   (JNIEnv *_env, jobject _this, jint coord, jint pname, jfloatArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *params_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *params = (GLfloat *) 0;
@@ -3117,8 +3315,8 @@
 android_glGetTexGenivOES__II_3II
   (JNIEnv *_env, jobject _this, jint coord, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLint *params_base = (GLint *) 0;
     jint _remaining;
     GLint *params = (GLint *) 0;
@@ -3185,8 +3383,8 @@
 android_glGetTexGenxvOES__II_3II
   (JNIEnv *_env, jobject _this, jint coord, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *params_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *params = (GLfixed *) 0;
diff --git a/core/jni/android_opengl_GLES20.cpp b/core/jni/android_opengl_GLES20.cpp
index a263f8b..4179785 100644
--- a/core/jni/android_opengl_GLES20.cpp
+++ b/core/jni/android_opengl_GLES20.cpp
@@ -17,14 +17,14 @@
 
 // This source file is automatically generated
 
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+
 #include "jni.h"
 #include "JNIHelp.h"
 #include <android_runtime/AndroidRuntime.h>
 #include <utils/misc.h>
-
 #include <assert.h>
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
 
 static int initialized = 0;
 
@@ -37,6 +37,34 @@
 static jfieldID limitID;
 static jfieldID elementSizeShiftID;
 
+
+/* special calls implemented in Android's GLES wrapper used to more
+ * efficiently bound-check passed arrays */
+extern "C" {
+#ifdef GL_VERSION_ES_CM_1_1
+GL_API void GL_APIENTRY glColorPointerBounds(GLint size, GLenum type, GLsizei stride,
+        const GLvoid *ptr, GLsizei count);
+GL_API void GL_APIENTRY glNormalPointerBounds(GLenum type, GLsizei stride,
+        const GLvoid *pointer, GLsizei count);
+GL_API void GL_APIENTRY glTexCoordPointerBounds(GLint size, GLenum type,
+        GLsizei stride, const GLvoid *pointer, GLsizei count);
+GL_API void GL_APIENTRY glVertexPointerBounds(GLint size, GLenum type,
+        GLsizei stride, const GLvoid *pointer, GLsizei count);
+GL_API void GL_APIENTRY glPointSizePointerOESBounds(GLenum type,
+        GLsizei stride, const GLvoid *pointer, GLsizei count);
+GL_API void GL_APIENTRY glMatrixIndexPointerOESBounds(GLint size, GLenum type,
+        GLsizei stride, const GLvoid *pointer, GLsizei count);
+GL_API void GL_APIENTRY glWeightPointerOESBounds(GLint size, GLenum type,
+        GLsizei stride, const GLvoid *pointer, GLsizei count);
+#endif
+#ifdef GL_ES_VERSION_2_0
+static void glVertexAttribPointerBounds(GLuint indx, GLint size, GLenum type,
+        GLboolean normalized, GLsizei stride, const GLvoid *pointer, GLsizei count) {
+    glVertexAttribPointer(indx, size, type, normalized, stride, pointer);
+}
+#endif
+}
+
 /* Cache method IDs each time the class is loaded. */
 
 static void
@@ -61,7 +89,6 @@
         _env->GetFieldID(bufferClass, "_elementSizeShift", "I");
 }
 
-
 static void *
 getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining, jint *offset)
 {
@@ -89,12 +116,11 @@
     return NULL;
 }
 
-
 static void
 releasePointer(JNIEnv *_env, jarray array, void *data, jboolean commit)
 {
     _env->ReleasePrimitiveArrayCritical(array, data,
-					   commit ? 0 : JNI_ABORT);
+                       commit ? 0 : JNI_ABORT);
 }
 
 static void *
@@ -111,16 +137,183 @@
     return (void*) buf;
 }
 
-static int
-getNumCompressedTextureFormats() {
-    int numCompressedTextureFormats = 0;
-    glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &numCompressedTextureFormats);
-    return numCompressedTextureFormats;
+// --------------------------------------------------------------------------
+
+/*
+ * returns the number of values glGet returns for a given pname.
+ *
+ * The code below is written such that pnames requiring only one values
+ * are the default (and are not explicitely tested for). This makes the
+ * checking code much shorter/readable/efficient.
+ *
+ * This means that unknown pnames (e.g.: extensions) will default to 1. If
+ * that unknown pname needs more than 1 value, then the validation check
+ * is incomplete and the app may crash if it passed the wrong number params.
+ */
+static int getNeededCount(GLint pname) {
+    int needed = 1;
+#ifdef GL_ES_VERSION_2_0
+    // GLES 2.x pnames
+    switch (pname) {
+        case GL_ALIASED_LINE_WIDTH_RANGE:
+        case GL_ALIASED_POINT_SIZE_RANGE:
+            needed = 2;
+            break;
+
+        case GL_BLEND_COLOR:
+        case GL_COLOR_CLEAR_VALUE:
+        case GL_COLOR_WRITEMASK:
+        case GL_SCISSOR_BOX:
+        case GL_VIEWPORT:
+            needed = 4;
+            break;
+
+        case GL_COMPRESSED_TEXTURE_FORMATS:
+            glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &needed);
+            break;
+
+        case GL_SHADER_BINARY_FORMATS:
+            glGetIntegerv(GL_NUM_SHADER_BINARY_FORMATS, &needed);
+            break;
+    }
+#endif
+
+#ifdef GL_VERSION_ES_CM_1_1
+    // GLES 1.x pnames
+    switch (pname) {
+        case GL_ALIASED_LINE_WIDTH_RANGE:
+        case GL_ALIASED_POINT_SIZE_RANGE:
+        case GL_DEPTH_RANGE:
+        case GL_SMOOTH_LINE_WIDTH_RANGE:
+        case GL_SMOOTH_POINT_SIZE_RANGE:
+            needed = 2;
+            break;
+
+        case GL_CURRENT_NORMAL:
+        case GL_POINT_DISTANCE_ATTENUATION:
+            needed = 3;
+            break;
+
+        case GL_COLOR_CLEAR_VALUE:
+        case GL_COLOR_WRITEMASK:
+        case GL_CURRENT_COLOR:
+        case GL_CURRENT_TEXTURE_COORDS:
+        case GL_FOG_COLOR:
+        case GL_LIGHT_MODEL_AMBIENT:
+        case GL_SCISSOR_BOX:
+        case GL_VIEWPORT:
+            needed = 4;
+            break;
+
+        case GL_MODELVIEW_MATRIX:
+        case GL_PROJECTION_MATRIX:
+        case GL_TEXTURE_MATRIX:
+            needed = 16;
+            break;
+
+        case GL_COMPRESSED_TEXTURE_FORMATS:
+            glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &needed);
+            break;
+    }
+#endif
+    return needed;
 }
 
-static void glVertexAttribPointerBounds(GLuint indx, GLint size, GLenum type,
-        GLboolean normalized, GLsizei stride, const GLvoid *pointer, GLsizei count) {
-    glVertexAttribPointer(indx, size, type, normalized, stride, pointer);
+template <typename JTYPEARRAY, typename CTYPE, void GET(GLenum, CTYPE*)>
+static void
+get
+  (JNIEnv *_env, jobject _this, jint pname, JTYPEARRAY params_ref, jint offset) {
+    jint _exception = 0;
+    const char * _exceptionType;
+    const char * _exceptionMessage;
+    CTYPE *params_base = (CTYPE *) 0;
+    jint _remaining;
+    CTYPE *params = (CTYPE *) 0;
+    int _needed = 0;
+
+    if (!params_ref) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "params == null";
+        goto exit;
+    }
+    if (offset < 0) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "offset < 0";
+        goto exit;
+    }
+    _remaining = _env->GetArrayLength(params_ref) - offset;
+    _needed = getNeededCount(pname);
+    // if we didn't find this pname, we just assume the user passed
+    // an array of the right size -- this might happen with extensions
+    // or if we forget an enum here.
+    if (_remaining < _needed) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "length - offset < needed";
+        goto exit;
+    }
+    params_base = (CTYPE *)
+        _env->GetPrimitiveArrayCritical(params_ref, (jboolean *)0);
+    params = params_base + offset;
+
+    GET(
+        (GLenum)pname,
+        (CTYPE *)params
+    );
+
+exit:
+    if (params_base) {
+        _env->ReleasePrimitiveArrayCritical(params_ref, params_base,
+            _exception ? JNI_ABORT: 0);
+    }
+    if (_exception) {
+        jniThrowException(_env, _exceptionType, _exceptionMessage);
+    }
+}
+
+
+template <typename CTYPE, void GET(GLenum, CTYPE*)>
+static void
+getarray
+  (JNIEnv *_env, jobject _this, jint pname, jobject params_buf) {
+    jint _exception = 0;
+    const char * _exceptionType;
+    const char * _exceptionMessage;
+    jarray _array = (jarray) 0;
+    jint _bufferOffset = (jint) 0;
+    jint _remaining;
+    CTYPE *params = (CTYPE *) 0;
+    int _needed = 0;
+
+    params = (CTYPE *)getPointer(_env, params_buf, &_array, &_remaining, &_bufferOffset);
+    _needed = getNeededCount(pname);
+    // if we didn't find this pname, we just assume the user passed
+    // an array of the right size -- this might happen with extensions
+    // or if we forget an enum here.
+    if (_needed>0 && _remaining < _needed) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "remaining() < needed";
+        goto exit;
+    }
+    if (params == NULL) {
+        char * _paramsBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
+        params = (CTYPE *) (_paramsBase + _bufferOffset);
+    }
+    GET(
+        (GLenum)pname,
+        (CTYPE *)params
+    );
+
+exit:
+    if (_array) {
+        releasePointer(_env, _array, params, _exception ? JNI_FALSE : JNI_TRUE);
+    }
+    if (_exception) {
+        jniThrowException(_env, _exceptionType, _exceptionMessage);
+    }
 }
 
 // --------------------------------------------------------------------------
@@ -148,8 +341,8 @@
 android_glBindAttribLocation__IILjava_lang_String_2
   (JNIEnv *_env, jobject _this, jint program, jint index, jstring name) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     const char* _nativename = 0;
 
     if (!name) {
@@ -273,8 +466,8 @@
 android_glBufferData__IILjava_nio_Buffer_2I
   (JNIEnv *_env, jobject _this, jint target, jint size, jobject data_buf, jint usage) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -314,8 +507,8 @@
 android_glBufferSubData__IIILjava_nio_Buffer_2
   (JNIEnv *_env, jobject _this, jint target, jint offset, jint size, jobject data_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -544,8 +737,8 @@
 android_glDeleteBuffers__I_3II
   (JNIEnv *_env, jobject _this, jint n, jintArray buffers_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLuint *buffers_base = (GLuint *) 0;
     jint _remaining;
     GLuint *buffers = (GLuint *) 0;
@@ -593,8 +786,8 @@
 android_glDeleteBuffers__ILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint n, jobject buffers_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -630,8 +823,8 @@
 android_glDeleteFramebuffers__I_3II
   (JNIEnv *_env, jobject _this, jint n, jintArray framebuffers_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLuint *framebuffers_base = (GLuint *) 0;
     jint _remaining;
     GLuint *framebuffers = (GLuint *) 0;
@@ -649,6 +842,12 @@
         goto exit;
     }
     _remaining = _env->GetArrayLength(framebuffers_ref) - offset;
+    if (_remaining < n) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "length - offset < n < needed";
+        goto exit;
+    }
     framebuffers_base = (GLuint *)
         _env->GetPrimitiveArrayCritical(framebuffers_ref, (jboolean *)0);
     framebuffers = framebuffers_base + offset;
@@ -672,12 +871,21 @@
 static void
 android_glDeleteFramebuffers__ILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint n, jobject framebuffers_buf) {
+    jint _exception = 0;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
     GLuint *framebuffers = (GLuint *) 0;
 
     framebuffers = (GLuint *)getPointer(_env, framebuffers_buf, &_array, &_remaining, &_bufferOffset);
+    if (_remaining < n) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "remaining() < n < needed";
+        goto exit;
+    }
     if (framebuffers == NULL) {
         char * _framebuffersBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
         framebuffers = (GLuint *) (_framebuffersBase + _bufferOffset);
@@ -686,9 +894,14 @@
         (GLsizei)n,
         (GLuint *)framebuffers
     );
+
+exit:
     if (_array) {
         releasePointer(_env, _array, framebuffers, JNI_FALSE);
     }
+    if (_exception) {
+        jniThrowException(_env, _exceptionType, _exceptionMessage);
+    }
 }
 
 /* void glDeleteProgram ( GLuint program ) */
@@ -705,8 +918,8 @@
 android_glDeleteRenderbuffers__I_3II
   (JNIEnv *_env, jobject _this, jint n, jintArray renderbuffers_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLuint *renderbuffers_base = (GLuint *) 0;
     jint _remaining;
     GLuint *renderbuffers = (GLuint *) 0;
@@ -724,6 +937,12 @@
         goto exit;
     }
     _remaining = _env->GetArrayLength(renderbuffers_ref) - offset;
+    if (_remaining < n) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "length - offset < n < needed";
+        goto exit;
+    }
     renderbuffers_base = (GLuint *)
         _env->GetPrimitiveArrayCritical(renderbuffers_ref, (jboolean *)0);
     renderbuffers = renderbuffers_base + offset;
@@ -747,12 +966,21 @@
 static void
 android_glDeleteRenderbuffers__ILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint n, jobject renderbuffers_buf) {
+    jint _exception = 0;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
     GLuint *renderbuffers = (GLuint *) 0;
 
     renderbuffers = (GLuint *)getPointer(_env, renderbuffers_buf, &_array, &_remaining, &_bufferOffset);
+    if (_remaining < n) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "remaining() < n < needed";
+        goto exit;
+    }
     if (renderbuffers == NULL) {
         char * _renderbuffersBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
         renderbuffers = (GLuint *) (_renderbuffersBase + _bufferOffset);
@@ -761,9 +989,14 @@
         (GLsizei)n,
         (GLuint *)renderbuffers
     );
+
+exit:
     if (_array) {
         releasePointer(_env, _array, renderbuffers, JNI_FALSE);
     }
+    if (_exception) {
+        jniThrowException(_env, _exceptionType, _exceptionMessage);
+    }
 }
 
 /* void glDeleteShader ( GLuint shader ) */
@@ -780,8 +1013,8 @@
 android_glDeleteTextures__I_3II
   (JNIEnv *_env, jobject _this, jint n, jintArray textures_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLuint *textures_base = (GLuint *) 0;
     jint _remaining;
     GLuint *textures = (GLuint *) 0;
@@ -829,8 +1062,8 @@
 android_glDeleteTextures__ILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint n, jobject textures_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -933,8 +1166,8 @@
 android_glDrawElements__IIII
   (JNIEnv *_env, jobject _this, jint mode, jint count, jint type, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     glDrawElements(
         (GLenum)mode,
         (GLsizei)count,
@@ -951,8 +1184,8 @@
 android_glDrawElements__IIILjava_nio_Buffer_2
   (JNIEnv *_env, jobject _this, jint mode, jint count, jint type, jobject indices_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -1056,8 +1289,8 @@
 android_glGenBuffers__I_3II
   (JNIEnv *_env, jobject _this, jint n, jintArray buffers_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLuint *buffers_base = (GLuint *) 0;
     jint _remaining;
     GLuint *buffers = (GLuint *) 0;
@@ -1105,8 +1338,8 @@
 android_glGenBuffers__ILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint n, jobject buffers_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -1151,8 +1384,8 @@
 android_glGenFramebuffers__I_3II
   (JNIEnv *_env, jobject _this, jint n, jintArray framebuffers_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLuint *framebuffers_base = (GLuint *) 0;
     jint _remaining;
     GLuint *framebuffers = (GLuint *) 0;
@@ -1170,6 +1403,12 @@
         goto exit;
     }
     _remaining = _env->GetArrayLength(framebuffers_ref) - offset;
+    if (_remaining < n) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "length - offset < n < needed";
+        goto exit;
+    }
     framebuffers_base = (GLuint *)
         _env->GetPrimitiveArrayCritical(framebuffers_ref, (jboolean *)0);
     framebuffers = framebuffers_base + offset;
@@ -1193,12 +1432,21 @@
 static void
 android_glGenFramebuffers__ILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint n, jobject framebuffers_buf) {
+    jint _exception = 0;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
     GLuint *framebuffers = (GLuint *) 0;
 
     framebuffers = (GLuint *)getPointer(_env, framebuffers_buf, &_array, &_remaining, &_bufferOffset);
+    if (_remaining < n) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "remaining() < n < needed";
+        goto exit;
+    }
     if (framebuffers == NULL) {
         char * _framebuffersBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
         framebuffers = (GLuint *) (_framebuffersBase + _bufferOffset);
@@ -1207,8 +1455,13 @@
         (GLsizei)n,
         (GLuint *)framebuffers
     );
+
+exit:
     if (_array) {
-        releasePointer(_env, _array, framebuffers, JNI_TRUE);
+        releasePointer(_env, _array, framebuffers, _exception ? JNI_FALSE : JNI_TRUE);
+    }
+    if (_exception) {
+        jniThrowException(_env, _exceptionType, _exceptionMessage);
     }
 }
 
@@ -1217,8 +1470,8 @@
 android_glGenRenderbuffers__I_3II
   (JNIEnv *_env, jobject _this, jint n, jintArray renderbuffers_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLuint *renderbuffers_base = (GLuint *) 0;
     jint _remaining;
     GLuint *renderbuffers = (GLuint *) 0;
@@ -1236,6 +1489,12 @@
         goto exit;
     }
     _remaining = _env->GetArrayLength(renderbuffers_ref) - offset;
+    if (_remaining < n) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "length - offset < n < needed";
+        goto exit;
+    }
     renderbuffers_base = (GLuint *)
         _env->GetPrimitiveArrayCritical(renderbuffers_ref, (jboolean *)0);
     renderbuffers = renderbuffers_base + offset;
@@ -1259,12 +1518,21 @@
 static void
 android_glGenRenderbuffers__ILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint n, jobject renderbuffers_buf) {
+    jint _exception = 0;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
     GLuint *renderbuffers = (GLuint *) 0;
 
     renderbuffers = (GLuint *)getPointer(_env, renderbuffers_buf, &_array, &_remaining, &_bufferOffset);
+    if (_remaining < n) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "remaining() < n < needed";
+        goto exit;
+    }
     if (renderbuffers == NULL) {
         char * _renderbuffersBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
         renderbuffers = (GLuint *) (_renderbuffersBase + _bufferOffset);
@@ -1273,8 +1541,13 @@
         (GLsizei)n,
         (GLuint *)renderbuffers
     );
+
+exit:
     if (_array) {
-        releasePointer(_env, _array, renderbuffers, JNI_TRUE);
+        releasePointer(_env, _array, renderbuffers, _exception ? JNI_FALSE : JNI_TRUE);
+    }
+    if (_exception) {
+        jniThrowException(_env, _exceptionType, _exceptionMessage);
     }
 }
 
@@ -1283,8 +1556,8 @@
 android_glGenTextures__I_3II
   (JNIEnv *_env, jobject _this, jint n, jintArray textures_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLuint *textures_base = (GLuint *) 0;
     jint _remaining;
     GLuint *textures = (GLuint *) 0;
@@ -1332,8 +1605,8 @@
 android_glGenTextures__ILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint n, jobject textures_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -2026,8 +2299,8 @@
 android_glGetAttachedShaders__II_3II_3II
   (JNIEnv *_env, jobject _this, jint program, jint maxcount, jintArray count_ref, jint countOffset, jintArray shaders_ref, jint shadersOffset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLsizei *count_base = (GLsizei *) 0;
     jint _countRemaining;
     GLsizei *count = (GLsizei *) 0;
@@ -2048,6 +2321,12 @@
         goto exit;
     }
     _countRemaining = _env->GetArrayLength(count_ref) - countOffset;
+    if (_countRemaining < 1) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "length - countOffset < 1 < needed";
+        goto exit;
+    }
     count_base = (GLsizei *)
         _env->GetPrimitiveArrayCritical(count_ref, (jboolean *)0);
     count = count_base + countOffset;
@@ -2065,6 +2344,12 @@
         goto exit;
     }
     _shadersRemaining = _env->GetArrayLength(shaders_ref) - shadersOffset;
+    if (_shadersRemaining < maxcount) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "length - shadersOffset < maxcount < needed";
+        goto exit;
+    }
     shaders_base = (GLuint *)
         _env->GetPrimitiveArrayCritical(shaders_ref, (jboolean *)0);
     shaders = shaders_base + shadersOffset;
@@ -2094,6 +2379,9 @@
 static void
 android_glGetAttachedShaders__IILjava_nio_IntBuffer_2Ljava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint program, jint maxcount, jobject count_buf, jobject shaders_buf) {
+    jint _exception = 0;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _countArray = (jarray) 0;
     jint _countBufferOffset = (jint) 0;
     jarray _shadersArray = (jarray) 0;
@@ -2103,13 +2391,29 @@
     jint _shadersRemaining;
     GLuint *shaders = (GLuint *) 0;
 
-    count = (GLsizei *)getPointer(_env, count_buf, &_countArray, &_countRemaining, &_countBufferOffset);
-    shaders = (GLuint *)getPointer(_env, shaders_buf, &_shadersArray, &_shadersRemaining, &_shadersBufferOffset);
-    if (count == NULL) {
+    if (count_buf) {
+        count = (GLsizei *)getPointer(_env, count_buf, &_countArray, &_countRemaining, &_countBufferOffset);
+        if (_countRemaining < 1) {
+            _exception = 1;
+            _exceptionType = "java/lang/IllegalArgumentException";
+            _exceptionMessage = "remaining() < 1 < needed";
+            goto exit;
+        }
+    }
+    if (shaders_buf) {
+        shaders = (GLuint *)getPointer(_env, shaders_buf, &_shadersArray, &_shadersRemaining, &_shadersBufferOffset);
+        if (_shadersRemaining < maxcount) {
+            _exception = 1;
+            _exceptionType = "java/lang/IllegalArgumentException";
+            _exceptionMessage = "remaining() < maxcount < needed";
+            goto exit;
+        }
+    }
+    if (count_buf && count == NULL) {
         char * _countBase = (char *)_env->GetPrimitiveArrayCritical(_countArray, (jboolean *) 0);
         count = (GLsizei *) (_countBase + _countBufferOffset);
     }
-    if (shaders == NULL) {
+    if (shaders_buf && shaders == NULL) {
         char * _shadersBase = (char *)_env->GetPrimitiveArrayCritical(_shadersArray, (jboolean *) 0);
         shaders = (GLuint *) (_shadersBase + _shadersBufferOffset);
     }
@@ -2119,11 +2423,16 @@
         (GLsizei *)count,
         (GLuint *)shaders
     );
+
+exit:
     if (_shadersArray) {
-        releasePointer(_env, _shadersArray, shaders, JNI_TRUE);
+        releasePointer(_env, _shadersArray, shaders, _exception ? JNI_FALSE : JNI_TRUE);
     }
     if (_countArray) {
-        releasePointer(_env, _countArray, count, JNI_TRUE);
+        releasePointer(_env, _countArray, count, _exception ? JNI_FALSE : JNI_TRUE);
+    }
+    if (_exception) {
+        jniThrowException(_env, _exceptionType, _exceptionMessage);
     }
 }
 
@@ -2132,8 +2441,8 @@
 android_glGetAttribLocation__ILjava_lang_String_2
   (JNIEnv *_env, jobject _this, jint program, jstring name) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLint _returnValue = 0;
     const char* _nativename = 0;
 
@@ -2164,75 +2473,22 @@
 static void
 android_glGetBooleanv__I_3ZI
   (JNIEnv *_env, jobject _this, jint pname, jbooleanArray params_ref, jint offset) {
-    jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
-    GLboolean *params_base = (GLboolean *) 0;
-    jint _remaining;
-    GLboolean *params = (GLboolean *) 0;
-
-    if (!params_ref) {
-        _exception = 1;
-        _exceptionType = "java/lang/IllegalArgumentException";
-        _exceptionMessage = "params == null";
-        goto exit;
-    }
-    if (offset < 0) {
-        _exception = 1;
-        _exceptionType = "java/lang/IllegalArgumentException";
-        _exceptionMessage = "offset < 0";
-        goto exit;
-    }
-    _remaining = _env->GetArrayLength(params_ref) - offset;
-    params_base = (GLboolean *)
-        _env->GetPrimitiveArrayCritical(params_ref, (jboolean *)0);
-    params = params_base + offset;
-
-    glGetBooleanv(
-        (GLenum)pname,
-        (GLboolean *)params
-    );
-
-exit:
-    if (params_base) {
-        _env->ReleasePrimitiveArrayCritical(params_ref, params_base,
-            _exception ? JNI_ABORT: 0);
-    }
-    if (_exception) {
-        jniThrowException(_env, _exceptionType, _exceptionMessage);
-    }
+    get<jbooleanArray, GLboolean, glGetBooleanv>(_env, _this, pname, params_ref, offset);
 }
 
 /* void glGetBooleanv ( GLenum pname, GLboolean *params ) */
 static void
 android_glGetBooleanv__ILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint pname, jobject params_buf) {
-    jarray _array = (jarray) 0;
-    jint _bufferOffset = (jint) 0;
-    jint _remaining;
-    GLboolean *params = (GLboolean *) 0;
-
-    params = (GLboolean *)getPointer(_env, params_buf, &_array, &_remaining, &_bufferOffset);
-    if (params == NULL) {
-        char * _paramsBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
-        params = (GLboolean *) (_paramsBase + _bufferOffset);
-    }
-    glGetBooleanv(
-        (GLenum)pname,
-        (GLboolean *)params
-    );
-    if (_array) {
-        releasePointer(_env, _array, params, JNI_TRUE);
-    }
+    getarray<GLboolean, glGetBooleanv>(_env, _this, pname, params_buf);
 }
-
 /* void glGetBufferParameteriv ( GLenum target, GLenum pname, GLint *params ) */
 static void
 android_glGetBufferParameteriv__II_3II
   (JNIEnv *_env, jobject _this, jint target, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLint *params_base = (GLint *) 0;
     jint _remaining;
     GLint *params = (GLint *) 0;
@@ -2281,8 +2537,8 @@
 android_glGetBufferParameteriv__IILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint target, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -2327,75 +2583,22 @@
 static void
 android_glGetFloatv__I_3FI
   (JNIEnv *_env, jobject _this, jint pname, jfloatArray params_ref, jint offset) {
-    jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
-    GLfloat *params_base = (GLfloat *) 0;
-    jint _remaining;
-    GLfloat *params = (GLfloat *) 0;
-
-    if (!params_ref) {
-        _exception = 1;
-        _exceptionType = "java/lang/IllegalArgumentException";
-        _exceptionMessage = "params == null";
-        goto exit;
-    }
-    if (offset < 0) {
-        _exception = 1;
-        _exceptionType = "java/lang/IllegalArgumentException";
-        _exceptionMessage = "offset < 0";
-        goto exit;
-    }
-    _remaining = _env->GetArrayLength(params_ref) - offset;
-    params_base = (GLfloat *)
-        _env->GetPrimitiveArrayCritical(params_ref, (jboolean *)0);
-    params = params_base + offset;
-
-    glGetFloatv(
-        (GLenum)pname,
-        (GLfloat *)params
-    );
-
-exit:
-    if (params_base) {
-        _env->ReleasePrimitiveArrayCritical(params_ref, params_base,
-            _exception ? JNI_ABORT: 0);
-    }
-    if (_exception) {
-        jniThrowException(_env, _exceptionType, _exceptionMessage);
-    }
+    get<jfloatArray, GLfloat, glGetFloatv>(_env, _this, pname, params_ref, offset);
 }
 
 /* void glGetFloatv ( GLenum pname, GLfloat *params ) */
 static void
 android_glGetFloatv__ILjava_nio_FloatBuffer_2
   (JNIEnv *_env, jobject _this, jint pname, jobject params_buf) {
-    jarray _array = (jarray) 0;
-    jint _bufferOffset = (jint) 0;
-    jint _remaining;
-    GLfloat *params = (GLfloat *) 0;
-
-    params = (GLfloat *)getPointer(_env, params_buf, &_array, &_remaining, &_bufferOffset);
-    if (params == NULL) {
-        char * _paramsBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
-        params = (GLfloat *) (_paramsBase + _bufferOffset);
-    }
-    glGetFloatv(
-        (GLenum)pname,
-        (GLfloat *)params
-    );
-    if (_array) {
-        releasePointer(_env, _array, params, JNI_TRUE);
-    }
+    getarray<GLfloat, glGetFloatv>(_env, _this, pname, params_buf);
 }
-
 /* void glGetFramebufferAttachmentParameteriv ( GLenum target, GLenum attachment, GLenum pname, GLint *params ) */
 static void
 android_glGetFramebufferAttachmentParameteriv__III_3II
   (JNIEnv *_env, jobject _this, jint target, jint attachment, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLint *params_base = (GLint *) 0;
     jint _remaining;
     GLint *params = (GLint *) 0;
@@ -2463,748 +2666,14 @@
 static void
 android_glGetIntegerv__I_3II
   (JNIEnv *_env, jobject _this, jint pname, jintArray params_ref, jint offset) {
-    jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
-    GLint *params_base = (GLint *) 0;
-    jint _remaining;
-    GLint *params = (GLint *) 0;
-
-    if (!params_ref) {
-        _exception = 1;
-        _exceptionType = "java/lang/IllegalArgumentException";
-        _exceptionMessage = "params == null";
-        goto exit;
-    }
-    if (offset < 0) {
-        _exception = 1;
-        _exceptionType = "java/lang/IllegalArgumentException";
-        _exceptionMessage = "offset < 0";
-        goto exit;
-    }
-    _remaining = _env->GetArrayLength(params_ref) - offset;
-    int _needed;
-    switch (pname) {
-#if defined(GL_ALPHA_BITS)
-        case GL_ALPHA_BITS:
-#endif // defined(GL_ALPHA_BITS)
-#if defined(GL_ALPHA_TEST_FUNC)
-        case GL_ALPHA_TEST_FUNC:
-#endif // defined(GL_ALPHA_TEST_FUNC)
-#if defined(GL_ALPHA_TEST_REF)
-        case GL_ALPHA_TEST_REF:
-#endif // defined(GL_ALPHA_TEST_REF)
-#if defined(GL_BLEND_DST)
-        case GL_BLEND_DST:
-#endif // defined(GL_BLEND_DST)
-#if defined(GL_BLUE_BITS)
-        case GL_BLUE_BITS:
-#endif // defined(GL_BLUE_BITS)
-#if defined(GL_COLOR_ARRAY_BUFFER_BINDING)
-        case GL_COLOR_ARRAY_BUFFER_BINDING:
-#endif // defined(GL_COLOR_ARRAY_BUFFER_BINDING)
-#if defined(GL_COLOR_ARRAY_SIZE)
-        case GL_COLOR_ARRAY_SIZE:
-#endif // defined(GL_COLOR_ARRAY_SIZE)
-#if defined(GL_COLOR_ARRAY_STRIDE)
-        case GL_COLOR_ARRAY_STRIDE:
-#endif // defined(GL_COLOR_ARRAY_STRIDE)
-#if defined(GL_COLOR_ARRAY_TYPE)
-        case GL_COLOR_ARRAY_TYPE:
-#endif // defined(GL_COLOR_ARRAY_TYPE)
-#if defined(GL_CULL_FACE)
-        case GL_CULL_FACE:
-#endif // defined(GL_CULL_FACE)
-#if defined(GL_DEPTH_BITS)
-        case GL_DEPTH_BITS:
-#endif // defined(GL_DEPTH_BITS)
-#if defined(GL_DEPTH_CLEAR_VALUE)
-        case GL_DEPTH_CLEAR_VALUE:
-#endif // defined(GL_DEPTH_CLEAR_VALUE)
-#if defined(GL_DEPTH_FUNC)
-        case GL_DEPTH_FUNC:
-#endif // defined(GL_DEPTH_FUNC)
-#if defined(GL_DEPTH_WRITEMASK)
-        case GL_DEPTH_WRITEMASK:
-#endif // defined(GL_DEPTH_WRITEMASK)
-#if defined(GL_FOG_DENSITY)
-        case GL_FOG_DENSITY:
-#endif // defined(GL_FOG_DENSITY)
-#if defined(GL_FOG_END)
-        case GL_FOG_END:
-#endif // defined(GL_FOG_END)
-#if defined(GL_FOG_MODE)
-        case GL_FOG_MODE:
-#endif // defined(GL_FOG_MODE)
-#if defined(GL_FOG_START)
-        case GL_FOG_START:
-#endif // defined(GL_FOG_START)
-#if defined(GL_FRONT_FACE)
-        case GL_FRONT_FACE:
-#endif // defined(GL_FRONT_FACE)
-#if defined(GL_GREEN_BITS)
-        case GL_GREEN_BITS:
-#endif // defined(GL_GREEN_BITS)
-#if defined(GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES)
-        case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES:
-#endif // defined(GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES)
-#if defined(GL_IMPLEMENTATION_COLOR_READ_TYPE_OES)
-        case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES:
-#endif // defined(GL_IMPLEMENTATION_COLOR_READ_TYPE_OES)
-#if defined(GL_LIGHT_MODEL_COLOR_CONTROL)
-        case GL_LIGHT_MODEL_COLOR_CONTROL:
-#endif // defined(GL_LIGHT_MODEL_COLOR_CONTROL)
-#if defined(GL_LIGHT_MODEL_LOCAL_VIEWER)
-        case GL_LIGHT_MODEL_LOCAL_VIEWER:
-#endif // defined(GL_LIGHT_MODEL_LOCAL_VIEWER)
-#if defined(GL_LIGHT_MODEL_TWO_SIDE)
-        case GL_LIGHT_MODEL_TWO_SIDE:
-#endif // defined(GL_LIGHT_MODEL_TWO_SIDE)
-#if defined(GL_LINE_SMOOTH_HINT)
-        case GL_LINE_SMOOTH_HINT:
-#endif // defined(GL_LINE_SMOOTH_HINT)
-#if defined(GL_LINE_WIDTH)
-        case GL_LINE_WIDTH:
-#endif // defined(GL_LINE_WIDTH)
-#if defined(GL_LOGIC_OP_MODE)
-        case GL_LOGIC_OP_MODE:
-#endif // defined(GL_LOGIC_OP_MODE)
-#if defined(GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES)
-        case GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES:
-#endif // defined(GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES)
-#if defined(GL_MATRIX_INDEX_ARRAY_SIZE_OES)
-        case GL_MATRIX_INDEX_ARRAY_SIZE_OES:
-#endif // defined(GL_MATRIX_INDEX_ARRAY_SIZE_OES)
-#if defined(GL_MATRIX_INDEX_ARRAY_STRIDE_OES)
-        case GL_MATRIX_INDEX_ARRAY_STRIDE_OES:
-#endif // defined(GL_MATRIX_INDEX_ARRAY_STRIDE_OES)
-#if defined(GL_MATRIX_INDEX_ARRAY_TYPE_OES)
-        case GL_MATRIX_INDEX_ARRAY_TYPE_OES:
-#endif // defined(GL_MATRIX_INDEX_ARRAY_TYPE_OES)
-#if defined(GL_MATRIX_MODE)
-        case GL_MATRIX_MODE:
-#endif // defined(GL_MATRIX_MODE)
-#if defined(GL_MAX_CLIP_PLANES)
-        case GL_MAX_CLIP_PLANES:
-#endif // defined(GL_MAX_CLIP_PLANES)
-#if defined(GL_MAX_ELEMENTS_INDICES)
-        case GL_MAX_ELEMENTS_INDICES:
-#endif // defined(GL_MAX_ELEMENTS_INDICES)
-#if defined(GL_MAX_ELEMENTS_VERTICES)
-        case GL_MAX_ELEMENTS_VERTICES:
-#endif // defined(GL_MAX_ELEMENTS_VERTICES)
-#if defined(GL_MAX_LIGHTS)
-        case GL_MAX_LIGHTS:
-#endif // defined(GL_MAX_LIGHTS)
-#if defined(GL_MAX_MODELVIEW_STACK_DEPTH)
-        case GL_MAX_MODELVIEW_STACK_DEPTH:
-#endif // defined(GL_MAX_MODELVIEW_STACK_DEPTH)
-#if defined(GL_MAX_PALETTE_MATRICES_OES)
-        case GL_MAX_PALETTE_MATRICES_OES:
-#endif // defined(GL_MAX_PALETTE_MATRICES_OES)
-#if defined(GL_MAX_PROJECTION_STACK_DEPTH)
-        case GL_MAX_PROJECTION_STACK_DEPTH:
-#endif // defined(GL_MAX_PROJECTION_STACK_DEPTH)
-#if defined(GL_MAX_TEXTURE_SIZE)
-        case GL_MAX_TEXTURE_SIZE:
-#endif // defined(GL_MAX_TEXTURE_SIZE)
-#if defined(GL_MAX_TEXTURE_STACK_DEPTH)
-        case GL_MAX_TEXTURE_STACK_DEPTH:
-#endif // defined(GL_MAX_TEXTURE_STACK_DEPTH)
-#if defined(GL_MAX_TEXTURE_UNITS)
-        case GL_MAX_TEXTURE_UNITS:
-#endif // defined(GL_MAX_TEXTURE_UNITS)
-#if defined(GL_MAX_VERTEX_UNITS_OES)
-        case GL_MAX_VERTEX_UNITS_OES:
-#endif // defined(GL_MAX_VERTEX_UNITS_OES)
-#if defined(GL_MODELVIEW_STACK_DEPTH)
-        case GL_MODELVIEW_STACK_DEPTH:
-#endif // defined(GL_MODELVIEW_STACK_DEPTH)
-#if defined(GL_NORMAL_ARRAY_BUFFER_BINDING)
-        case GL_NORMAL_ARRAY_BUFFER_BINDING:
-#endif // defined(GL_NORMAL_ARRAY_BUFFER_BINDING)
-#if defined(GL_NORMAL_ARRAY_STRIDE)
-        case GL_NORMAL_ARRAY_STRIDE:
-#endif // defined(GL_NORMAL_ARRAY_STRIDE)
-#if defined(GL_NORMAL_ARRAY_TYPE)
-        case GL_NORMAL_ARRAY_TYPE:
-#endif // defined(GL_NORMAL_ARRAY_TYPE)
-#if defined(GL_NUM_COMPRESSED_TEXTURE_FORMATS)
-        case GL_NUM_COMPRESSED_TEXTURE_FORMATS:
-#endif // defined(GL_NUM_COMPRESSED_TEXTURE_FORMATS)
-#if defined(GL_PACK_ALIGNMENT)
-        case GL_PACK_ALIGNMENT:
-#endif // defined(GL_PACK_ALIGNMENT)
-#if defined(GL_PERSPECTIVE_CORRECTION_HINT)
-        case GL_PERSPECTIVE_CORRECTION_HINT:
-#endif // defined(GL_PERSPECTIVE_CORRECTION_HINT)
-#if defined(GL_POINT_SIZE)
-        case GL_POINT_SIZE:
-#endif // defined(GL_POINT_SIZE)
-#if defined(GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES)
-        case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES:
-#endif // defined(GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES)
-#if defined(GL_POINT_SIZE_ARRAY_STRIDE_OES)
-        case GL_POINT_SIZE_ARRAY_STRIDE_OES:
-#endif // defined(GL_POINT_SIZE_ARRAY_STRIDE_OES)
-#if defined(GL_POINT_SIZE_ARRAY_TYPE_OES)
-        case GL_POINT_SIZE_ARRAY_TYPE_OES:
-#endif // defined(GL_POINT_SIZE_ARRAY_TYPE_OES)
-#if defined(GL_POINT_SMOOTH_HINT)
-        case GL_POINT_SMOOTH_HINT:
-#endif // defined(GL_POINT_SMOOTH_HINT)
-#if defined(GL_POLYGON_OFFSET_FACTOR)
-        case GL_POLYGON_OFFSET_FACTOR:
-#endif // defined(GL_POLYGON_OFFSET_FACTOR)
-#if defined(GL_POLYGON_OFFSET_UNITS)
-        case GL_POLYGON_OFFSET_UNITS:
-#endif // defined(GL_POLYGON_OFFSET_UNITS)
-#if defined(GL_PROJECTION_STACK_DEPTH)
-        case GL_PROJECTION_STACK_DEPTH:
-#endif // defined(GL_PROJECTION_STACK_DEPTH)
-#if defined(GL_RED_BITS)
-        case GL_RED_BITS:
-#endif // defined(GL_RED_BITS)
-#if defined(GL_SHADE_MODEL)
-        case GL_SHADE_MODEL:
-#endif // defined(GL_SHADE_MODEL)
-#if defined(GL_STENCIL_BITS)
-        case GL_STENCIL_BITS:
-#endif // defined(GL_STENCIL_BITS)
-#if defined(GL_STENCIL_CLEAR_VALUE)
-        case GL_STENCIL_CLEAR_VALUE:
-#endif // defined(GL_STENCIL_CLEAR_VALUE)
-#if defined(GL_STENCIL_FAIL)
-        case GL_STENCIL_FAIL:
-#endif // defined(GL_STENCIL_FAIL)
-#if defined(GL_STENCIL_FUNC)
-        case GL_STENCIL_FUNC:
-#endif // defined(GL_STENCIL_FUNC)
-#if defined(GL_STENCIL_PASS_DEPTH_FAIL)
-        case GL_STENCIL_PASS_DEPTH_FAIL:
-#endif // defined(GL_STENCIL_PASS_DEPTH_FAIL)
-#if defined(GL_STENCIL_PASS_DEPTH_PASS)
-        case GL_STENCIL_PASS_DEPTH_PASS:
-#endif // defined(GL_STENCIL_PASS_DEPTH_PASS)
-#if defined(GL_STENCIL_REF)
-        case GL_STENCIL_REF:
-#endif // defined(GL_STENCIL_REF)
-#if defined(GL_STENCIL_VALUE_MASK)
-        case GL_STENCIL_VALUE_MASK:
-#endif // defined(GL_STENCIL_VALUE_MASK)
-#if defined(GL_STENCIL_WRITEMASK)
-        case GL_STENCIL_WRITEMASK:
-#endif // defined(GL_STENCIL_WRITEMASK)
-#if defined(GL_SUBPIXEL_BITS)
-        case GL_SUBPIXEL_BITS:
-#endif // defined(GL_SUBPIXEL_BITS)
-#if defined(GL_TEXTURE_BINDING_2D)
-        case GL_TEXTURE_BINDING_2D:
-#endif // defined(GL_TEXTURE_BINDING_2D)
-#if defined(GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING)
-        case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING:
-#endif // defined(GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING)
-#if defined(GL_TEXTURE_COORD_ARRAY_SIZE)
-        case GL_TEXTURE_COORD_ARRAY_SIZE:
-#endif // defined(GL_TEXTURE_COORD_ARRAY_SIZE)
-#if defined(GL_TEXTURE_COORD_ARRAY_STRIDE)
-        case GL_TEXTURE_COORD_ARRAY_STRIDE:
-#endif // defined(GL_TEXTURE_COORD_ARRAY_STRIDE)
-#if defined(GL_TEXTURE_COORD_ARRAY_TYPE)
-        case GL_TEXTURE_COORD_ARRAY_TYPE:
-#endif // defined(GL_TEXTURE_COORD_ARRAY_TYPE)
-#if defined(GL_TEXTURE_STACK_DEPTH)
-        case GL_TEXTURE_STACK_DEPTH:
-#endif // defined(GL_TEXTURE_STACK_DEPTH)
-#if defined(GL_UNPACK_ALIGNMENT)
-        case GL_UNPACK_ALIGNMENT:
-#endif // defined(GL_UNPACK_ALIGNMENT)
-#if defined(GL_VERTEX_ARRAY_BUFFER_BINDING)
-        case GL_VERTEX_ARRAY_BUFFER_BINDING:
-#endif // defined(GL_VERTEX_ARRAY_BUFFER_BINDING)
-#if defined(GL_VERTEX_ARRAY_SIZE)
-        case GL_VERTEX_ARRAY_SIZE:
-#endif // defined(GL_VERTEX_ARRAY_SIZE)
-#if defined(GL_VERTEX_ARRAY_STRIDE)
-        case GL_VERTEX_ARRAY_STRIDE:
-#endif // defined(GL_VERTEX_ARRAY_STRIDE)
-#if defined(GL_VERTEX_ARRAY_TYPE)
-        case GL_VERTEX_ARRAY_TYPE:
-#endif // defined(GL_VERTEX_ARRAY_TYPE)
-#if defined(GL_WEIGHT_ARRAY_BUFFER_BINDING_OES)
-        case GL_WEIGHT_ARRAY_BUFFER_BINDING_OES:
-#endif // defined(GL_WEIGHT_ARRAY_BUFFER_BINDING_OES)
-#if defined(GL_WEIGHT_ARRAY_SIZE_OES)
-        case GL_WEIGHT_ARRAY_SIZE_OES:
-#endif // defined(GL_WEIGHT_ARRAY_SIZE_OES)
-#if defined(GL_WEIGHT_ARRAY_STRIDE_OES)
-        case GL_WEIGHT_ARRAY_STRIDE_OES:
-#endif // defined(GL_WEIGHT_ARRAY_STRIDE_OES)
-#if defined(GL_WEIGHT_ARRAY_TYPE_OES)
-        case GL_WEIGHT_ARRAY_TYPE_OES:
-#endif // defined(GL_WEIGHT_ARRAY_TYPE_OES)
-            _needed = 1;
-            break;
-#if defined(GL_ALIASED_POINT_SIZE_RANGE)
-        case GL_ALIASED_POINT_SIZE_RANGE:
-#endif // defined(GL_ALIASED_POINT_SIZE_RANGE)
-#if defined(GL_ALIASED_LINE_WIDTH_RANGE)
-        case GL_ALIASED_LINE_WIDTH_RANGE:
-#endif // defined(GL_ALIASED_LINE_WIDTH_RANGE)
-#if defined(GL_DEPTH_RANGE)
-        case GL_DEPTH_RANGE:
-#endif // defined(GL_DEPTH_RANGE)
-#if defined(GL_MAX_VIEWPORT_DIMS)
-        case GL_MAX_VIEWPORT_DIMS:
-#endif // defined(GL_MAX_VIEWPORT_DIMS)
-#if defined(GL_SMOOTH_LINE_WIDTH_RANGE)
-        case GL_SMOOTH_LINE_WIDTH_RANGE:
-#endif // defined(GL_SMOOTH_LINE_WIDTH_RANGE)
-#if defined(GL_SMOOTH_POINT_SIZE_RANGE)
-        case GL_SMOOTH_POINT_SIZE_RANGE:
-#endif // defined(GL_SMOOTH_POINT_SIZE_RANGE)
-            _needed = 2;
-            break;
-#if defined(GL_COLOR_CLEAR_VALUE)
-        case GL_COLOR_CLEAR_VALUE:
-#endif // defined(GL_COLOR_CLEAR_VALUE)
-#if defined(GL_COLOR_WRITEMASK)
-        case GL_COLOR_WRITEMASK:
-#endif // defined(GL_COLOR_WRITEMASK)
-#if defined(GL_FOG_COLOR)
-        case GL_FOG_COLOR:
-#endif // defined(GL_FOG_COLOR)
-#if defined(GL_LIGHT_MODEL_AMBIENT)
-        case GL_LIGHT_MODEL_AMBIENT:
-#endif // defined(GL_LIGHT_MODEL_AMBIENT)
-#if defined(GL_SCISSOR_BOX)
-        case GL_SCISSOR_BOX:
-#endif // defined(GL_SCISSOR_BOX)
-#if defined(GL_VIEWPORT)
-        case GL_VIEWPORT:
-#endif // defined(GL_VIEWPORT)
-            _needed = 4;
-            break;
-#if defined(GL_MODELVIEW_MATRIX)
-        case GL_MODELVIEW_MATRIX:
-#endif // defined(GL_MODELVIEW_MATRIX)
-#if defined(GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES)
-        case GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES:
-#endif // defined(GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES)
-#if defined(GL_PROJECTION_MATRIX)
-        case GL_PROJECTION_MATRIX:
-#endif // defined(GL_PROJECTION_MATRIX)
-#if defined(GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES)
-        case GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES:
-#endif // defined(GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES)
-#if defined(GL_TEXTURE_MATRIX)
-        case GL_TEXTURE_MATRIX:
-#endif // defined(GL_TEXTURE_MATRIX)
-#if defined(GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES)
-        case GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES:
-#endif // defined(GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES)
-            _needed = 16;
-            break;
-#if defined(GL_COMPRESSED_TEXTURE_FORMATS)
-        case GL_COMPRESSED_TEXTURE_FORMATS:
-#endif // defined(GL_COMPRESSED_TEXTURE_FORMATS)
-            _needed = getNumCompressedTextureFormats();
-            break;
-        default:
-            _needed = 0;
-            break;
-    }
-    if (_remaining < _needed) {
-        _exception = 1;
-        _exceptionType = "java/lang/IllegalArgumentException";
-        _exceptionMessage = "length - offset < needed";
-        goto exit;
-    }
-    params_base = (GLint *)
-        _env->GetPrimitiveArrayCritical(params_ref, (jboolean *)0);
-    params = params_base + offset;
-
-    glGetIntegerv(
-        (GLenum)pname,
-        (GLint *)params
-    );
-
-exit:
-    if (params_base) {
-        _env->ReleasePrimitiveArrayCritical(params_ref, params_base,
-            _exception ? JNI_ABORT: 0);
-    }
-    if (_exception) {
-        jniThrowException(_env, _exceptionType, _exceptionMessage);
-    }
+    get<jintArray, GLint, glGetIntegerv>(_env, _this, pname, params_ref, offset);
 }
 
 /* void glGetIntegerv ( GLenum pname, GLint *params ) */
 static void
 android_glGetIntegerv__ILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint pname, jobject params_buf) {
-    jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
-    jarray _array = (jarray) 0;
-    jint _bufferOffset = (jint) 0;
-    jint _remaining;
-    GLint *params = (GLint *) 0;
-
-    params = (GLint *)getPointer(_env, params_buf, &_array, &_remaining, &_bufferOffset);
-    int _needed;
-    switch (pname) {
-#if defined(GL_ALPHA_BITS)
-        case GL_ALPHA_BITS:
-#endif // defined(GL_ALPHA_BITS)
-#if defined(GL_ALPHA_TEST_FUNC)
-        case GL_ALPHA_TEST_FUNC:
-#endif // defined(GL_ALPHA_TEST_FUNC)
-#if defined(GL_ALPHA_TEST_REF)
-        case GL_ALPHA_TEST_REF:
-#endif // defined(GL_ALPHA_TEST_REF)
-#if defined(GL_BLEND_DST)
-        case GL_BLEND_DST:
-#endif // defined(GL_BLEND_DST)
-#if defined(GL_BLUE_BITS)
-        case GL_BLUE_BITS:
-#endif // defined(GL_BLUE_BITS)
-#if defined(GL_COLOR_ARRAY_BUFFER_BINDING)
-        case GL_COLOR_ARRAY_BUFFER_BINDING:
-#endif // defined(GL_COLOR_ARRAY_BUFFER_BINDING)
-#if defined(GL_COLOR_ARRAY_SIZE)
-        case GL_COLOR_ARRAY_SIZE:
-#endif // defined(GL_COLOR_ARRAY_SIZE)
-#if defined(GL_COLOR_ARRAY_STRIDE)
-        case GL_COLOR_ARRAY_STRIDE:
-#endif // defined(GL_COLOR_ARRAY_STRIDE)
-#if defined(GL_COLOR_ARRAY_TYPE)
-        case GL_COLOR_ARRAY_TYPE:
-#endif // defined(GL_COLOR_ARRAY_TYPE)
-#if defined(GL_CULL_FACE)
-        case GL_CULL_FACE:
-#endif // defined(GL_CULL_FACE)
-#if defined(GL_DEPTH_BITS)
-        case GL_DEPTH_BITS:
-#endif // defined(GL_DEPTH_BITS)
-#if defined(GL_DEPTH_CLEAR_VALUE)
-        case GL_DEPTH_CLEAR_VALUE:
-#endif // defined(GL_DEPTH_CLEAR_VALUE)
-#if defined(GL_DEPTH_FUNC)
-        case GL_DEPTH_FUNC:
-#endif // defined(GL_DEPTH_FUNC)
-#if defined(GL_DEPTH_WRITEMASK)
-        case GL_DEPTH_WRITEMASK:
-#endif // defined(GL_DEPTH_WRITEMASK)
-#if defined(GL_FOG_DENSITY)
-        case GL_FOG_DENSITY:
-#endif // defined(GL_FOG_DENSITY)
-#if defined(GL_FOG_END)
-        case GL_FOG_END:
-#endif // defined(GL_FOG_END)
-#if defined(GL_FOG_MODE)
-        case GL_FOG_MODE:
-#endif // defined(GL_FOG_MODE)
-#if defined(GL_FOG_START)
-        case GL_FOG_START:
-#endif // defined(GL_FOG_START)
-#if defined(GL_FRONT_FACE)
-        case GL_FRONT_FACE:
-#endif // defined(GL_FRONT_FACE)
-#if defined(GL_GREEN_BITS)
-        case GL_GREEN_BITS:
-#endif // defined(GL_GREEN_BITS)
-#if defined(GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES)
-        case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES:
-#endif // defined(GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES)
-#if defined(GL_IMPLEMENTATION_COLOR_READ_TYPE_OES)
-        case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES:
-#endif // defined(GL_IMPLEMENTATION_COLOR_READ_TYPE_OES)
-#if defined(GL_LIGHT_MODEL_COLOR_CONTROL)
-        case GL_LIGHT_MODEL_COLOR_CONTROL:
-#endif // defined(GL_LIGHT_MODEL_COLOR_CONTROL)
-#if defined(GL_LIGHT_MODEL_LOCAL_VIEWER)
-        case GL_LIGHT_MODEL_LOCAL_VIEWER:
-#endif // defined(GL_LIGHT_MODEL_LOCAL_VIEWER)
-#if defined(GL_LIGHT_MODEL_TWO_SIDE)
-        case GL_LIGHT_MODEL_TWO_SIDE:
-#endif // defined(GL_LIGHT_MODEL_TWO_SIDE)
-#if defined(GL_LINE_SMOOTH_HINT)
-        case GL_LINE_SMOOTH_HINT:
-#endif // defined(GL_LINE_SMOOTH_HINT)
-#if defined(GL_LINE_WIDTH)
-        case GL_LINE_WIDTH:
-#endif // defined(GL_LINE_WIDTH)
-#if defined(GL_LOGIC_OP_MODE)
-        case GL_LOGIC_OP_MODE:
-#endif // defined(GL_LOGIC_OP_MODE)
-#if defined(GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES)
-        case GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES:
-#endif // defined(GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES)
-#if defined(GL_MATRIX_INDEX_ARRAY_SIZE_OES)
-        case GL_MATRIX_INDEX_ARRAY_SIZE_OES:
-#endif // defined(GL_MATRIX_INDEX_ARRAY_SIZE_OES)
-#if defined(GL_MATRIX_INDEX_ARRAY_STRIDE_OES)
-        case GL_MATRIX_INDEX_ARRAY_STRIDE_OES:
-#endif // defined(GL_MATRIX_INDEX_ARRAY_STRIDE_OES)
-#if defined(GL_MATRIX_INDEX_ARRAY_TYPE_OES)
-        case GL_MATRIX_INDEX_ARRAY_TYPE_OES:
-#endif // defined(GL_MATRIX_INDEX_ARRAY_TYPE_OES)
-#if defined(GL_MATRIX_MODE)
-        case GL_MATRIX_MODE:
-#endif // defined(GL_MATRIX_MODE)
-#if defined(GL_MAX_CLIP_PLANES)
-        case GL_MAX_CLIP_PLANES:
-#endif // defined(GL_MAX_CLIP_PLANES)
-#if defined(GL_MAX_ELEMENTS_INDICES)
-        case GL_MAX_ELEMENTS_INDICES:
-#endif // defined(GL_MAX_ELEMENTS_INDICES)
-#if defined(GL_MAX_ELEMENTS_VERTICES)
-        case GL_MAX_ELEMENTS_VERTICES:
-#endif // defined(GL_MAX_ELEMENTS_VERTICES)
-#if defined(GL_MAX_LIGHTS)
-        case GL_MAX_LIGHTS:
-#endif // defined(GL_MAX_LIGHTS)
-#if defined(GL_MAX_MODELVIEW_STACK_DEPTH)
-        case GL_MAX_MODELVIEW_STACK_DEPTH:
-#endif // defined(GL_MAX_MODELVIEW_STACK_DEPTH)
-#if defined(GL_MAX_PALETTE_MATRICES_OES)
-        case GL_MAX_PALETTE_MATRICES_OES:
-#endif // defined(GL_MAX_PALETTE_MATRICES_OES)
-#if defined(GL_MAX_PROJECTION_STACK_DEPTH)
-        case GL_MAX_PROJECTION_STACK_DEPTH:
-#endif // defined(GL_MAX_PROJECTION_STACK_DEPTH)
-#if defined(GL_MAX_TEXTURE_SIZE)
-        case GL_MAX_TEXTURE_SIZE:
-#endif // defined(GL_MAX_TEXTURE_SIZE)
-#if defined(GL_MAX_TEXTURE_STACK_DEPTH)
-        case GL_MAX_TEXTURE_STACK_DEPTH:
-#endif // defined(GL_MAX_TEXTURE_STACK_DEPTH)
-#if defined(GL_MAX_TEXTURE_UNITS)
-        case GL_MAX_TEXTURE_UNITS:
-#endif // defined(GL_MAX_TEXTURE_UNITS)
-#if defined(GL_MAX_VERTEX_UNITS_OES)
-        case GL_MAX_VERTEX_UNITS_OES:
-#endif // defined(GL_MAX_VERTEX_UNITS_OES)
-#if defined(GL_MODELVIEW_STACK_DEPTH)
-        case GL_MODELVIEW_STACK_DEPTH:
-#endif // defined(GL_MODELVIEW_STACK_DEPTH)
-#if defined(GL_NORMAL_ARRAY_BUFFER_BINDING)
-        case GL_NORMAL_ARRAY_BUFFER_BINDING:
-#endif // defined(GL_NORMAL_ARRAY_BUFFER_BINDING)
-#if defined(GL_NORMAL_ARRAY_STRIDE)
-        case GL_NORMAL_ARRAY_STRIDE:
-#endif // defined(GL_NORMAL_ARRAY_STRIDE)
-#if defined(GL_NORMAL_ARRAY_TYPE)
-        case GL_NORMAL_ARRAY_TYPE:
-#endif // defined(GL_NORMAL_ARRAY_TYPE)
-#if defined(GL_NUM_COMPRESSED_TEXTURE_FORMATS)
-        case GL_NUM_COMPRESSED_TEXTURE_FORMATS:
-#endif // defined(GL_NUM_COMPRESSED_TEXTURE_FORMATS)
-#if defined(GL_PACK_ALIGNMENT)
-        case GL_PACK_ALIGNMENT:
-#endif // defined(GL_PACK_ALIGNMENT)
-#if defined(GL_PERSPECTIVE_CORRECTION_HINT)
-        case GL_PERSPECTIVE_CORRECTION_HINT:
-#endif // defined(GL_PERSPECTIVE_CORRECTION_HINT)
-#if defined(GL_POINT_SIZE)
-        case GL_POINT_SIZE:
-#endif // defined(GL_POINT_SIZE)
-#if defined(GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES)
-        case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES:
-#endif // defined(GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES)
-#if defined(GL_POINT_SIZE_ARRAY_STRIDE_OES)
-        case GL_POINT_SIZE_ARRAY_STRIDE_OES:
-#endif // defined(GL_POINT_SIZE_ARRAY_STRIDE_OES)
-#if defined(GL_POINT_SIZE_ARRAY_TYPE_OES)
-        case GL_POINT_SIZE_ARRAY_TYPE_OES:
-#endif // defined(GL_POINT_SIZE_ARRAY_TYPE_OES)
-#if defined(GL_POINT_SMOOTH_HINT)
-        case GL_POINT_SMOOTH_HINT:
-#endif // defined(GL_POINT_SMOOTH_HINT)
-#if defined(GL_POLYGON_OFFSET_FACTOR)
-        case GL_POLYGON_OFFSET_FACTOR:
-#endif // defined(GL_POLYGON_OFFSET_FACTOR)
-#if defined(GL_POLYGON_OFFSET_UNITS)
-        case GL_POLYGON_OFFSET_UNITS:
-#endif // defined(GL_POLYGON_OFFSET_UNITS)
-#if defined(GL_PROJECTION_STACK_DEPTH)
-        case GL_PROJECTION_STACK_DEPTH:
-#endif // defined(GL_PROJECTION_STACK_DEPTH)
-#if defined(GL_RED_BITS)
-        case GL_RED_BITS:
-#endif // defined(GL_RED_BITS)
-#if defined(GL_SHADE_MODEL)
-        case GL_SHADE_MODEL:
-#endif // defined(GL_SHADE_MODEL)
-#if defined(GL_STENCIL_BITS)
-        case GL_STENCIL_BITS:
-#endif // defined(GL_STENCIL_BITS)
-#if defined(GL_STENCIL_CLEAR_VALUE)
-        case GL_STENCIL_CLEAR_VALUE:
-#endif // defined(GL_STENCIL_CLEAR_VALUE)
-#if defined(GL_STENCIL_FAIL)
-        case GL_STENCIL_FAIL:
-#endif // defined(GL_STENCIL_FAIL)
-#if defined(GL_STENCIL_FUNC)
-        case GL_STENCIL_FUNC:
-#endif // defined(GL_STENCIL_FUNC)
-#if defined(GL_STENCIL_PASS_DEPTH_FAIL)
-        case GL_STENCIL_PASS_DEPTH_FAIL:
-#endif // defined(GL_STENCIL_PASS_DEPTH_FAIL)
-#if defined(GL_STENCIL_PASS_DEPTH_PASS)
-        case GL_STENCIL_PASS_DEPTH_PASS:
-#endif // defined(GL_STENCIL_PASS_DEPTH_PASS)
-#if defined(GL_STENCIL_REF)
-        case GL_STENCIL_REF:
-#endif // defined(GL_STENCIL_REF)
-#if defined(GL_STENCIL_VALUE_MASK)
-        case GL_STENCIL_VALUE_MASK:
-#endif // defined(GL_STENCIL_VALUE_MASK)
-#if defined(GL_STENCIL_WRITEMASK)
-        case GL_STENCIL_WRITEMASK:
-#endif // defined(GL_STENCIL_WRITEMASK)
-#if defined(GL_SUBPIXEL_BITS)
-        case GL_SUBPIXEL_BITS:
-#endif // defined(GL_SUBPIXEL_BITS)
-#if defined(GL_TEXTURE_BINDING_2D)
-        case GL_TEXTURE_BINDING_2D:
-#endif // defined(GL_TEXTURE_BINDING_2D)
-#if defined(GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING)
-        case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING:
-#endif // defined(GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING)
-#if defined(GL_TEXTURE_COORD_ARRAY_SIZE)
-        case GL_TEXTURE_COORD_ARRAY_SIZE:
-#endif // defined(GL_TEXTURE_COORD_ARRAY_SIZE)
-#if defined(GL_TEXTURE_COORD_ARRAY_STRIDE)
-        case GL_TEXTURE_COORD_ARRAY_STRIDE:
-#endif // defined(GL_TEXTURE_COORD_ARRAY_STRIDE)
-#if defined(GL_TEXTURE_COORD_ARRAY_TYPE)
-        case GL_TEXTURE_COORD_ARRAY_TYPE:
-#endif // defined(GL_TEXTURE_COORD_ARRAY_TYPE)
-#if defined(GL_TEXTURE_STACK_DEPTH)
-        case GL_TEXTURE_STACK_DEPTH:
-#endif // defined(GL_TEXTURE_STACK_DEPTH)
-#if defined(GL_UNPACK_ALIGNMENT)
-        case GL_UNPACK_ALIGNMENT:
-#endif // defined(GL_UNPACK_ALIGNMENT)
-#if defined(GL_VERTEX_ARRAY_BUFFER_BINDING)
-        case GL_VERTEX_ARRAY_BUFFER_BINDING:
-#endif // defined(GL_VERTEX_ARRAY_BUFFER_BINDING)
-#if defined(GL_VERTEX_ARRAY_SIZE)
-        case GL_VERTEX_ARRAY_SIZE:
-#endif // defined(GL_VERTEX_ARRAY_SIZE)
-#if defined(GL_VERTEX_ARRAY_STRIDE)
-        case GL_VERTEX_ARRAY_STRIDE:
-#endif // defined(GL_VERTEX_ARRAY_STRIDE)
-#if defined(GL_VERTEX_ARRAY_TYPE)
-        case GL_VERTEX_ARRAY_TYPE:
-#endif // defined(GL_VERTEX_ARRAY_TYPE)
-#if defined(GL_WEIGHT_ARRAY_BUFFER_BINDING_OES)
-        case GL_WEIGHT_ARRAY_BUFFER_BINDING_OES:
-#endif // defined(GL_WEIGHT_ARRAY_BUFFER_BINDING_OES)
-#if defined(GL_WEIGHT_ARRAY_SIZE_OES)
-        case GL_WEIGHT_ARRAY_SIZE_OES:
-#endif // defined(GL_WEIGHT_ARRAY_SIZE_OES)
-#if defined(GL_WEIGHT_ARRAY_STRIDE_OES)
-        case GL_WEIGHT_ARRAY_STRIDE_OES:
-#endif // defined(GL_WEIGHT_ARRAY_STRIDE_OES)
-#if defined(GL_WEIGHT_ARRAY_TYPE_OES)
-        case GL_WEIGHT_ARRAY_TYPE_OES:
-#endif // defined(GL_WEIGHT_ARRAY_TYPE_OES)
-            _needed = 1;
-            break;
-#if defined(GL_ALIASED_POINT_SIZE_RANGE)
-        case GL_ALIASED_POINT_SIZE_RANGE:
-#endif // defined(GL_ALIASED_POINT_SIZE_RANGE)
-#if defined(GL_ALIASED_LINE_WIDTH_RANGE)
-        case GL_ALIASED_LINE_WIDTH_RANGE:
-#endif // defined(GL_ALIASED_LINE_WIDTH_RANGE)
-#if defined(GL_DEPTH_RANGE)
-        case GL_DEPTH_RANGE:
-#endif // defined(GL_DEPTH_RANGE)
-#if defined(GL_MAX_VIEWPORT_DIMS)
-        case GL_MAX_VIEWPORT_DIMS:
-#endif // defined(GL_MAX_VIEWPORT_DIMS)
-#if defined(GL_SMOOTH_LINE_WIDTH_RANGE)
-        case GL_SMOOTH_LINE_WIDTH_RANGE:
-#endif // defined(GL_SMOOTH_LINE_WIDTH_RANGE)
-#if defined(GL_SMOOTH_POINT_SIZE_RANGE)
-        case GL_SMOOTH_POINT_SIZE_RANGE:
-#endif // defined(GL_SMOOTH_POINT_SIZE_RANGE)
-            _needed = 2;
-            break;
-#if defined(GL_COLOR_CLEAR_VALUE)
-        case GL_COLOR_CLEAR_VALUE:
-#endif // defined(GL_COLOR_CLEAR_VALUE)
-#if defined(GL_COLOR_WRITEMASK)
-        case GL_COLOR_WRITEMASK:
-#endif // defined(GL_COLOR_WRITEMASK)
-#if defined(GL_FOG_COLOR)
-        case GL_FOG_COLOR:
-#endif // defined(GL_FOG_COLOR)
-#if defined(GL_LIGHT_MODEL_AMBIENT)
-        case GL_LIGHT_MODEL_AMBIENT:
-#endif // defined(GL_LIGHT_MODEL_AMBIENT)
-#if defined(GL_SCISSOR_BOX)
-        case GL_SCISSOR_BOX:
-#endif // defined(GL_SCISSOR_BOX)
-#if defined(GL_VIEWPORT)
-        case GL_VIEWPORT:
-#endif // defined(GL_VIEWPORT)
-            _needed = 4;
-            break;
-#if defined(GL_MODELVIEW_MATRIX)
-        case GL_MODELVIEW_MATRIX:
-#endif // defined(GL_MODELVIEW_MATRIX)
-#if defined(GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES)
-        case GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES:
-#endif // defined(GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES)
-#if defined(GL_PROJECTION_MATRIX)
-        case GL_PROJECTION_MATRIX:
-#endif // defined(GL_PROJECTION_MATRIX)
-#if defined(GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES)
-        case GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES:
-#endif // defined(GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES)
-#if defined(GL_TEXTURE_MATRIX)
-        case GL_TEXTURE_MATRIX:
-#endif // defined(GL_TEXTURE_MATRIX)
-#if defined(GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES)
-        case GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES:
-#endif // defined(GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES)
-            _needed = 16;
-            break;
-#if defined(GL_COMPRESSED_TEXTURE_FORMATS)
-        case GL_COMPRESSED_TEXTURE_FORMATS:
-#endif // defined(GL_COMPRESSED_TEXTURE_FORMATS)
-            _needed = getNumCompressedTextureFormats();
-            break;
-        default:
-            _needed = 0;
-            break;
-    }
-    if (_remaining < _needed) {
-        _exception = 1;
-        _exceptionType = "java/lang/IllegalArgumentException";
-        _exceptionMessage = "remaining() < needed";
-        goto exit;
-    }
-    if (params == NULL) {
-        char * _paramsBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
-        params = (GLint *) (_paramsBase + _bufferOffset);
-    }
-    glGetIntegerv(
-        (GLenum)pname,
-        (GLint *)params
-    );
-
-exit:
-    if (_array) {
-        releasePointer(_env, _array, params, _exception ? JNI_FALSE : JNI_TRUE);
-    }
-    if (_exception) {
-        jniThrowException(_env, _exceptionType, _exceptionMessage);
-    }
+    getarray<GLint, glGetIntegerv>(_env, _this, pname, params_buf);
 }
 
 /* void glGetProgramiv ( GLuint program, GLenum pname, GLint *params ) */
@@ -3212,8 +2681,8 @@
 android_glGetProgramiv__II_3II
   (JNIEnv *_env, jobject _this, jint program, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLint *params_base = (GLint *) 0;
     jint _remaining;
     GLint *params = (GLint *) 0;
@@ -3231,6 +2700,12 @@
         goto exit;
     }
     _remaining = _env->GetArrayLength(params_ref) - offset;
+    if (_remaining < 1) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "length - offset < 1 < needed";
+        goto exit;
+    }
     params_base = (GLint *)
         _env->GetPrimitiveArrayCritical(params_ref, (jboolean *)0);
     params = params_base + offset;
@@ -3255,12 +2730,21 @@
 static void
 android_glGetProgramiv__IILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint program, jint pname, jobject params_buf) {
+    jint _exception = 0;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
     GLint *params = (GLint *) 0;
 
     params = (GLint *)getPointer(_env, params_buf, &_array, &_remaining, &_bufferOffset);
+    if (_remaining < 1) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "remaining() < 1 < needed";
+        goto exit;
+    }
     if (params == NULL) {
         char * _paramsBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
         params = (GLint *) (_paramsBase + _bufferOffset);
@@ -3270,8 +2754,13 @@
         (GLenum)pname,
         (GLint *)params
     );
+
+exit:
     if (_array) {
-        releasePointer(_env, _array, params, JNI_TRUE);
+        releasePointer(_env, _array, params, _exception ? JNI_FALSE : JNI_TRUE);
+    }
+    if (_exception) {
+        jniThrowException(_env, _exceptionType, _exceptionMessage);
     }
 }
 
@@ -3299,8 +2788,8 @@
 android_glGetRenderbufferParameteriv__II_3II
   (JNIEnv *_env, jobject _this, jint target, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLint *params_base = (GLint *) 0;
     jint _remaining;
     GLint *params = (GLint *) 0;
@@ -3318,6 +2807,12 @@
         goto exit;
     }
     _remaining = _env->GetArrayLength(params_ref) - offset;
+    if (_remaining < 1) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "length - offset < 1 < needed";
+        goto exit;
+    }
     params_base = (GLint *)
         _env->GetPrimitiveArrayCritical(params_ref, (jboolean *)0);
     params = params_base + offset;
@@ -3342,12 +2837,21 @@
 static void
 android_glGetRenderbufferParameteriv__IILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint target, jint pname, jobject params_buf) {
+    jint _exception = 0;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
     GLint *params = (GLint *) 0;
 
     params = (GLint *)getPointer(_env, params_buf, &_array, &_remaining, &_bufferOffset);
+    if (_remaining < 1) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "remaining() < 1 < needed";
+        goto exit;
+    }
     if (params == NULL) {
         char * _paramsBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
         params = (GLint *) (_paramsBase + _bufferOffset);
@@ -3357,8 +2861,13 @@
         (GLenum)pname,
         (GLint *)params
     );
+
+exit:
     if (_array) {
-        releasePointer(_env, _array, params, JNI_TRUE);
+        releasePointer(_env, _array, params, _exception ? JNI_FALSE : JNI_TRUE);
+    }
+    if (_exception) {
+        jniThrowException(_env, _exceptionType, _exceptionMessage);
     }
 }
 
@@ -3367,8 +2876,8 @@
 android_glGetShaderiv__II_3II
   (JNIEnv *_env, jobject _this, jint shader, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLint *params_base = (GLint *) 0;
     jint _remaining;
     GLint *params = (GLint *) 0;
@@ -3386,6 +2895,12 @@
         goto exit;
     }
     _remaining = _env->GetArrayLength(params_ref) - offset;
+    if (_remaining < 1) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "length - offset < 1 < needed";
+        goto exit;
+    }
     params_base = (GLint *)
         _env->GetPrimitiveArrayCritical(params_ref, (jboolean *)0);
     params = params_base + offset;
@@ -3410,12 +2925,21 @@
 static void
 android_glGetShaderiv__IILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint shader, jint pname, jobject params_buf) {
+    jint _exception = 0;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
     GLint *params = (GLint *) 0;
 
     params = (GLint *)getPointer(_env, params_buf, &_array, &_remaining, &_bufferOffset);
+    if (_remaining < 1) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "remaining() < 1 < needed";
+        goto exit;
+    }
     if (params == NULL) {
         char * _paramsBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
         params = (GLint *) (_paramsBase + _bufferOffset);
@@ -3425,8 +2949,13 @@
         (GLenum)pname,
         (GLint *)params
     );
+
+exit:
     if (_array) {
-        releasePointer(_env, _array, params, JNI_TRUE);
+        releasePointer(_env, _array, params, _exception ? JNI_FALSE : JNI_TRUE);
+    }
+    if (_exception) {
+        jniThrowException(_env, _exceptionType, _exceptionMessage);
     }
 }
 
@@ -3454,8 +2983,8 @@
 android_glGetShaderPrecisionFormat__II_3II_3II
   (JNIEnv *_env, jobject _this, jint shadertype, jint precisiontype, jintArray range_ref, jint rangeOffset, jintArray precision_ref, jint precisionOffset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLint *range_base = (GLint *) 0;
     jint _rangeRemaining;
     GLint *range = (GLint *) 0;
@@ -3476,6 +3005,12 @@
         goto exit;
     }
     _rangeRemaining = _env->GetArrayLength(range_ref) - rangeOffset;
+    if (_rangeRemaining < 1) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "length - rangeOffset < 1 < needed";
+        goto exit;
+    }
     range_base = (GLint *)
         _env->GetPrimitiveArrayCritical(range_ref, (jboolean *)0);
     range = range_base + rangeOffset;
@@ -3493,6 +3028,12 @@
         goto exit;
     }
     _precisionRemaining = _env->GetArrayLength(precision_ref) - precisionOffset;
+    if (_precisionRemaining < 1) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "length - precisionOffset < 1 < needed";
+        goto exit;
+    }
     precision_base = (GLint *)
         _env->GetPrimitiveArrayCritical(precision_ref, (jboolean *)0);
     precision = precision_base + precisionOffset;
@@ -3522,6 +3063,9 @@
 static void
 android_glGetShaderPrecisionFormat__IILjava_nio_IntBuffer_2Ljava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint shadertype, jint precisiontype, jobject range_buf, jobject precision_buf) {
+    jint _exception = 0;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _rangeArray = (jarray) 0;
     jint _rangeBufferOffset = (jint) 0;
     jarray _precisionArray = (jarray) 0;
@@ -3532,7 +3076,19 @@
     GLint *precision = (GLint *) 0;
 
     range = (GLint *)getPointer(_env, range_buf, &_rangeArray, &_rangeRemaining, &_rangeBufferOffset);
+    if (_rangeRemaining < 1) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "remaining() < 1 < needed";
+        goto exit;
+    }
     precision = (GLint *)getPointer(_env, precision_buf, &_precisionArray, &_precisionRemaining, &_precisionBufferOffset);
+    if (_precisionRemaining < 1) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "remaining() < 1 < needed";
+        goto exit;
+    }
     if (range == NULL) {
         char * _rangeBase = (char *)_env->GetPrimitiveArrayCritical(_rangeArray, (jboolean *) 0);
         range = (GLint *) (_rangeBase + _rangeBufferOffset);
@@ -3547,11 +3103,16 @@
         (GLint *)range,
         (GLint *)precision
     );
+
+exit:
     if (_precisionArray) {
-        releasePointer(_env, _precisionArray, precision, JNI_TRUE);
+        releasePointer(_env, _precisionArray, precision, _exception ? JNI_FALSE : JNI_TRUE);
     }
     if (_rangeArray) {
-        releasePointer(_env, _rangeArray, range, JNI_TRUE);
+        releasePointer(_env, _rangeArray, range, _exception ? JNI_FALSE : JNI_TRUE);
+    }
+    if (_exception) {
+        jniThrowException(_env, _exceptionType, _exceptionMessage);
     }
 }
 
@@ -3676,8 +3237,8 @@
 android_glGetTexParameterfv__II_3FI
   (JNIEnv *_env, jobject _this, jint target, jint pname, jfloatArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *params_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *params = (GLfloat *) 0;
@@ -3726,8 +3287,8 @@
 android_glGetTexParameterfv__IILjava_nio_FloatBuffer_2
   (JNIEnv *_env, jobject _this, jint target, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -3764,8 +3325,8 @@
 android_glGetTexParameteriv__II_3II
   (JNIEnv *_env, jobject _this, jint target, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLint *params_base = (GLint *) 0;
     jint _remaining;
     GLint *params = (GLint *) 0;
@@ -3814,8 +3375,8 @@
 android_glGetTexParameteriv__IILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint target, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -3852,8 +3413,8 @@
 android_glGetUniformfv__II_3FI
   (JNIEnv *_env, jobject _this, jint program, jint location, jfloatArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *params_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *params = (GLfloat *) 0;
@@ -3871,6 +3432,12 @@
         goto exit;
     }
     _remaining = _env->GetArrayLength(params_ref) - offset;
+    if (_remaining < 1) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "length - offset < 1 < needed";
+        goto exit;
+    }
     params_base = (GLfloat *)
         _env->GetPrimitiveArrayCritical(params_ref, (jboolean *)0);
     params = params_base + offset;
@@ -3895,12 +3462,21 @@
 static void
 android_glGetUniformfv__IILjava_nio_FloatBuffer_2
   (JNIEnv *_env, jobject _this, jint program, jint location, jobject params_buf) {
+    jint _exception = 0;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
     GLfloat *params = (GLfloat *) 0;
 
     params = (GLfloat *)getPointer(_env, params_buf, &_array, &_remaining, &_bufferOffset);
+    if (_remaining < 1) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "remaining() < 1 < needed";
+        goto exit;
+    }
     if (params == NULL) {
         char * _paramsBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
         params = (GLfloat *) (_paramsBase + _bufferOffset);
@@ -3910,8 +3486,13 @@
         (GLint)location,
         (GLfloat *)params
     );
+
+exit:
     if (_array) {
-        releasePointer(_env, _array, params, JNI_TRUE);
+        releasePointer(_env, _array, params, _exception ? JNI_FALSE : JNI_TRUE);
+    }
+    if (_exception) {
+        jniThrowException(_env, _exceptionType, _exceptionMessage);
     }
 }
 
@@ -3920,8 +3501,8 @@
 android_glGetUniformiv__II_3II
   (JNIEnv *_env, jobject _this, jint program, jint location, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLint *params_base = (GLint *) 0;
     jint _remaining;
     GLint *params = (GLint *) 0;
@@ -3939,6 +3520,12 @@
         goto exit;
     }
     _remaining = _env->GetArrayLength(params_ref) - offset;
+    if (_remaining < 1) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "length - offset < 1 < needed";
+        goto exit;
+    }
     params_base = (GLint *)
         _env->GetPrimitiveArrayCritical(params_ref, (jboolean *)0);
     params = params_base + offset;
@@ -3963,12 +3550,21 @@
 static void
 android_glGetUniformiv__IILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint program, jint location, jobject params_buf) {
+    jint _exception = 0;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
     GLint *params = (GLint *) 0;
 
     params = (GLint *)getPointer(_env, params_buf, &_array, &_remaining, &_bufferOffset);
+    if (_remaining < 1) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "remaining() < 1 < needed";
+        goto exit;
+    }
     if (params == NULL) {
         char * _paramsBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
         params = (GLint *) (_paramsBase + _bufferOffset);
@@ -3978,8 +3574,13 @@
         (GLint)location,
         (GLint *)params
     );
+
+exit:
     if (_array) {
-        releasePointer(_env, _array, params, JNI_TRUE);
+        releasePointer(_env, _array, params, _exception ? JNI_FALSE : JNI_TRUE);
+    }
+    if (_exception) {
+        jniThrowException(_env, _exceptionType, _exceptionMessage);
     }
 }
 
@@ -3988,8 +3589,8 @@
 android_glGetUniformLocation__ILjava_lang_String_2
   (JNIEnv *_env, jobject _this, jint program, jstring name) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLint _returnValue = 0;
     const char* _nativename = 0;
 
@@ -4021,8 +3622,8 @@
 android_glGetVertexAttribfv__II_3FI
   (JNIEnv *_env, jobject _this, jint index, jint pname, jfloatArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *params_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *params = (GLfloat *) 0;
@@ -4040,6 +3641,23 @@
         goto exit;
     }
     _remaining = _env->GetArrayLength(params_ref) - offset;
+    int _needed;
+    switch (pname) {
+#if defined(GL_CURRENT_VERTEX_ATTRIB)
+        case GL_CURRENT_VERTEX_ATTRIB:
+#endif // defined(GL_CURRENT_VERTEX_ATTRIB)
+            _needed = 4;
+            break;
+        default:
+            _needed = 1;
+            break;
+    }
+    if (_remaining < _needed) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "length - offset < needed";
+        goto exit;
+    }
     params_base = (GLfloat *)
         _env->GetPrimitiveArrayCritical(params_ref, (jboolean *)0);
     params = params_base + offset;
@@ -4064,12 +3682,32 @@
 static void
 android_glGetVertexAttribfv__IILjava_nio_FloatBuffer_2
   (JNIEnv *_env, jobject _this, jint index, jint pname, jobject params_buf) {
+    jint _exception = 0;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
     GLfloat *params = (GLfloat *) 0;
 
     params = (GLfloat *)getPointer(_env, params_buf, &_array, &_remaining, &_bufferOffset);
+    int _needed;
+    switch (pname) {
+#if defined(GL_CURRENT_VERTEX_ATTRIB)
+        case GL_CURRENT_VERTEX_ATTRIB:
+#endif // defined(GL_CURRENT_VERTEX_ATTRIB)
+            _needed = 4;
+            break;
+        default:
+            _needed = 1;
+            break;
+    }
+    if (_remaining < _needed) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "remaining() < needed";
+        goto exit;
+    }
     if (params == NULL) {
         char * _paramsBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
         params = (GLfloat *) (_paramsBase + _bufferOffset);
@@ -4079,8 +3717,13 @@
         (GLenum)pname,
         (GLfloat *)params
     );
+
+exit:
     if (_array) {
-        releasePointer(_env, _array, params, JNI_TRUE);
+        releasePointer(_env, _array, params, _exception ? JNI_FALSE : JNI_TRUE);
+    }
+    if (_exception) {
+        jniThrowException(_env, _exceptionType, _exceptionMessage);
     }
 }
 
@@ -4089,8 +3732,8 @@
 android_glGetVertexAttribiv__II_3II
   (JNIEnv *_env, jobject _this, jint index, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLint *params_base = (GLint *) 0;
     jint _remaining;
     GLint *params = (GLint *) 0;
@@ -4108,6 +3751,23 @@
         goto exit;
     }
     _remaining = _env->GetArrayLength(params_ref) - offset;
+    int _needed;
+    switch (pname) {
+#if defined(GL_CURRENT_VERTEX_ATTRIB)
+        case GL_CURRENT_VERTEX_ATTRIB:
+#endif // defined(GL_CURRENT_VERTEX_ATTRIB)
+            _needed = 4;
+            break;
+        default:
+            _needed = 1;
+            break;
+    }
+    if (_remaining < _needed) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "length - offset < needed";
+        goto exit;
+    }
     params_base = (GLint *)
         _env->GetPrimitiveArrayCritical(params_ref, (jboolean *)0);
     params = params_base + offset;
@@ -4132,12 +3792,32 @@
 static void
 android_glGetVertexAttribiv__IILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint index, jint pname, jobject params_buf) {
+    jint _exception = 0;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
     GLint *params = (GLint *) 0;
 
     params = (GLint *)getPointer(_env, params_buf, &_array, &_remaining, &_bufferOffset);
+    int _needed;
+    switch (pname) {
+#if defined(GL_CURRENT_VERTEX_ATTRIB)
+        case GL_CURRENT_VERTEX_ATTRIB:
+#endif // defined(GL_CURRENT_VERTEX_ATTRIB)
+            _needed = 4;
+            break;
+        default:
+            _needed = 1;
+            break;
+    }
+    if (_remaining < _needed) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "remaining() < needed";
+        goto exit;
+    }
     if (params == NULL) {
         char * _paramsBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
         params = (GLint *) (_paramsBase + _bufferOffset);
@@ -4147,8 +3827,13 @@
         (GLenum)pname,
         (GLint *)params
     );
+
+exit:
     if (_array) {
-        releasePointer(_env, _array, params, JNI_TRUE);
+        releasePointer(_env, _array, params, _exception ? JNI_FALSE : JNI_TRUE);
+    }
+    if (_exception) {
+        jniThrowException(_env, _exceptionType, _exceptionMessage);
     }
 }
 
@@ -4351,8 +4036,8 @@
 android_glShaderBinary__I_3IIILjava_nio_Buffer_2I
   (JNIEnv *_env, jobject _this, jint n, jintArray shaders_ref, jint offset, jint binaryformat, jobject binary_buf, jint length) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     GLuint *shaders_base = (GLuint *) 0;
@@ -4379,6 +4064,12 @@
     shaders = shaders_base + offset;
 
     binary = (GLvoid *)getPointer(_env, binary_buf, &_array, &_binaryRemaining, &_bufferOffset);
+    if (_binaryRemaining < length) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "remaining() < length < needed";
+        goto exit;
+    }
     if (binary == NULL) {
         char * _binaryBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
         binary = (GLvoid *) (_binaryBase + _bufferOffset);
@@ -4408,6 +4099,9 @@
 static void
 android_glShaderBinary__ILjava_nio_IntBuffer_2ILjava_nio_Buffer_2I
   (JNIEnv *_env, jobject _this, jint n, jobject shaders_buf, jint binaryformat, jobject binary_buf, jint length) {
+    jint _exception = 0;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _shadersArray = (jarray) 0;
     jint _shadersBufferOffset = (jint) 0;
     jarray _binaryArray = (jarray) 0;
@@ -4419,6 +4113,12 @@
 
     shaders = (GLuint *)getPointer(_env, shaders_buf, &_shadersArray, &_shadersRemaining, &_shadersBufferOffset);
     binary = (GLvoid *)getPointer(_env, binary_buf, &_binaryArray, &_binaryRemaining, &_binaryBufferOffset);
+    if (_binaryRemaining < length) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "remaining() < length < needed";
+        goto exit;
+    }
     if (shaders == NULL) {
         char * _shadersBase = (char *)_env->GetPrimitiveArrayCritical(_shadersArray, (jboolean *) 0);
         shaders = (GLuint *) (_shadersBase + _shadersBufferOffset);
@@ -4434,12 +4134,17 @@
         (GLvoid *)binary,
         (GLsizei)length
     );
+
+exit:
     if (_binaryArray) {
         releasePointer(_env, _binaryArray, binary, JNI_FALSE);
     }
     if (_shadersArray) {
         releasePointer(_env, _shadersArray, shaders, JNI_FALSE);
     }
+    if (_exception) {
+        jniThrowException(_env, _exceptionType, _exceptionMessage);
+    }
 }
 
 
@@ -4572,8 +4277,8 @@
 android_glTexParameterfv__II_3FI
   (JNIEnv *_env, jobject _this, jint target, jint pname, jfloatArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *params_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *params = (GLfloat *) 0;
@@ -4622,8 +4327,8 @@
 android_glTexParameterfv__IILjava_nio_FloatBuffer_2
   (JNIEnv *_env, jobject _this, jint target, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -4671,8 +4376,8 @@
 android_glTexParameteriv__II_3II
   (JNIEnv *_env, jobject _this, jint target, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLint *params_base = (GLint *) 0;
     jint _remaining;
     GLint *params = (GLint *) 0;
@@ -4721,8 +4426,8 @@
 android_glTexParameteriv__IILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint target, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -4801,8 +4506,8 @@
 android_glUniform1fv__II_3FI
   (JNIEnv *_env, jobject _this, jint location, jint count, jfloatArray v_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *v_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *v = (GLfloat *) 0;
@@ -4820,6 +4525,12 @@
         goto exit;
     }
     _remaining = _env->GetArrayLength(v_ref) - offset;
+    if (_remaining < count) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "length - offset < count < needed";
+        goto exit;
+    }
     v_base = (GLfloat *)
         _env->GetPrimitiveArrayCritical(v_ref, (jboolean *)0);
     v = v_base + offset;
@@ -4844,12 +4555,21 @@
 static void
 android_glUniform1fv__IILjava_nio_FloatBuffer_2
   (JNIEnv *_env, jobject _this, jint location, jint count, jobject v_buf) {
+    jint _exception = 0;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
     GLfloat *v = (GLfloat *) 0;
 
     v = (GLfloat *)getPointer(_env, v_buf, &_array, &_remaining, &_bufferOffset);
+    if (_remaining < count) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "remaining() < count < needed";
+        goto exit;
+    }
     if (v == NULL) {
         char * _vBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
         v = (GLfloat *) (_vBase + _bufferOffset);
@@ -4859,9 +4579,14 @@
         (GLsizei)count,
         (GLfloat *)v
     );
+
+exit:
     if (_array) {
         releasePointer(_env, _array, v, JNI_FALSE);
     }
+    if (_exception) {
+        jniThrowException(_env, _exceptionType, _exceptionMessage);
+    }
 }
 
 /* void glUniform1i ( GLint location, GLint x ) */
@@ -4879,8 +4604,8 @@
 android_glUniform1iv__II_3II
   (JNIEnv *_env, jobject _this, jint location, jint count, jintArray v_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLint *v_base = (GLint *) 0;
     jint _remaining;
     GLint *v = (GLint *) 0;
@@ -4898,6 +4623,12 @@
         goto exit;
     }
     _remaining = _env->GetArrayLength(v_ref) - offset;
+    if (_remaining < count) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "length - offset < count < needed";
+        goto exit;
+    }
     v_base = (GLint *)
         _env->GetPrimitiveArrayCritical(v_ref, (jboolean *)0);
     v = v_base + offset;
@@ -4922,12 +4653,21 @@
 static void
 android_glUniform1iv__IILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint location, jint count, jobject v_buf) {
+    jint _exception = 0;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
     GLint *v = (GLint *) 0;
 
     v = (GLint *)getPointer(_env, v_buf, &_array, &_remaining, &_bufferOffset);
+    if (_remaining < count) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "remaining() < count < needed";
+        goto exit;
+    }
     if (v == NULL) {
         char * _vBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
         v = (GLint *) (_vBase + _bufferOffset);
@@ -4937,9 +4677,14 @@
         (GLsizei)count,
         (GLint *)v
     );
+
+exit:
     if (_array) {
         releasePointer(_env, _array, v, JNI_FALSE);
     }
+    if (_exception) {
+        jniThrowException(_env, _exceptionType, _exceptionMessage);
+    }
 }
 
 /* void glUniform2f ( GLint location, GLfloat x, GLfloat y ) */
@@ -4958,8 +4703,8 @@
 android_glUniform2fv__II_3FI
   (JNIEnv *_env, jobject _this, jint location, jint count, jfloatArray v_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *v_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *v = (GLfloat *) 0;
@@ -4977,6 +4722,12 @@
         goto exit;
     }
     _remaining = _env->GetArrayLength(v_ref) - offset;
+    if (_remaining < count*2) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "length - offset < count*2 < needed";
+        goto exit;
+    }
     v_base = (GLfloat *)
         _env->GetPrimitiveArrayCritical(v_ref, (jboolean *)0);
     v = v_base + offset;
@@ -5001,12 +4752,21 @@
 static void
 android_glUniform2fv__IILjava_nio_FloatBuffer_2
   (JNIEnv *_env, jobject _this, jint location, jint count, jobject v_buf) {
+    jint _exception = 0;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
     GLfloat *v = (GLfloat *) 0;
 
     v = (GLfloat *)getPointer(_env, v_buf, &_array, &_remaining, &_bufferOffset);
+    if (_remaining < count*2) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "remaining() < count*2 < needed";
+        goto exit;
+    }
     if (v == NULL) {
         char * _vBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
         v = (GLfloat *) (_vBase + _bufferOffset);
@@ -5016,9 +4776,14 @@
         (GLsizei)count,
         (GLfloat *)v
     );
+
+exit:
     if (_array) {
         releasePointer(_env, _array, v, JNI_FALSE);
     }
+    if (_exception) {
+        jniThrowException(_env, _exceptionType, _exceptionMessage);
+    }
 }
 
 /* void glUniform2i ( GLint location, GLint x, GLint y ) */
@@ -5037,8 +4802,8 @@
 android_glUniform2iv__II_3II
   (JNIEnv *_env, jobject _this, jint location, jint count, jintArray v_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLint *v_base = (GLint *) 0;
     jint _remaining;
     GLint *v = (GLint *) 0;
@@ -5056,6 +4821,12 @@
         goto exit;
     }
     _remaining = _env->GetArrayLength(v_ref) - offset;
+    if (_remaining < count*2) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "length - offset < count*2 < needed";
+        goto exit;
+    }
     v_base = (GLint *)
         _env->GetPrimitiveArrayCritical(v_ref, (jboolean *)0);
     v = v_base + offset;
@@ -5080,12 +4851,21 @@
 static void
 android_glUniform2iv__IILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint location, jint count, jobject v_buf) {
+    jint _exception = 0;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
     GLint *v = (GLint *) 0;
 
     v = (GLint *)getPointer(_env, v_buf, &_array, &_remaining, &_bufferOffset);
+    if (_remaining < count*2) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "remaining() < count*2 < needed";
+        goto exit;
+    }
     if (v == NULL) {
         char * _vBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
         v = (GLint *) (_vBase + _bufferOffset);
@@ -5095,9 +4875,14 @@
         (GLsizei)count,
         (GLint *)v
     );
+
+exit:
     if (_array) {
         releasePointer(_env, _array, v, JNI_FALSE);
     }
+    if (_exception) {
+        jniThrowException(_env, _exceptionType, _exceptionMessage);
+    }
 }
 
 /* void glUniform3f ( GLint location, GLfloat x, GLfloat y, GLfloat z ) */
@@ -5117,8 +4902,8 @@
 android_glUniform3fv__II_3FI
   (JNIEnv *_env, jobject _this, jint location, jint count, jfloatArray v_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *v_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *v = (GLfloat *) 0;
@@ -5136,6 +4921,12 @@
         goto exit;
     }
     _remaining = _env->GetArrayLength(v_ref) - offset;
+    if (_remaining < count*3) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "length - offset < count*3 < needed";
+        goto exit;
+    }
     v_base = (GLfloat *)
         _env->GetPrimitiveArrayCritical(v_ref, (jboolean *)0);
     v = v_base + offset;
@@ -5160,12 +4951,21 @@
 static void
 android_glUniform3fv__IILjava_nio_FloatBuffer_2
   (JNIEnv *_env, jobject _this, jint location, jint count, jobject v_buf) {
+    jint _exception = 0;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
     GLfloat *v = (GLfloat *) 0;
 
     v = (GLfloat *)getPointer(_env, v_buf, &_array, &_remaining, &_bufferOffset);
+    if (_remaining < count*3) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "remaining() < count*3 < needed";
+        goto exit;
+    }
     if (v == NULL) {
         char * _vBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
         v = (GLfloat *) (_vBase + _bufferOffset);
@@ -5175,9 +4975,14 @@
         (GLsizei)count,
         (GLfloat *)v
     );
+
+exit:
     if (_array) {
         releasePointer(_env, _array, v, JNI_FALSE);
     }
+    if (_exception) {
+        jniThrowException(_env, _exceptionType, _exceptionMessage);
+    }
 }
 
 /* void glUniform3i ( GLint location, GLint x, GLint y, GLint z ) */
@@ -5197,8 +5002,8 @@
 android_glUniform3iv__II_3II
   (JNIEnv *_env, jobject _this, jint location, jint count, jintArray v_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLint *v_base = (GLint *) 0;
     jint _remaining;
     GLint *v = (GLint *) 0;
@@ -5216,6 +5021,12 @@
         goto exit;
     }
     _remaining = _env->GetArrayLength(v_ref) - offset;
+    if (_remaining < count*3) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "length - offset < count*3 < needed";
+        goto exit;
+    }
     v_base = (GLint *)
         _env->GetPrimitiveArrayCritical(v_ref, (jboolean *)0);
     v = v_base + offset;
@@ -5240,12 +5051,21 @@
 static void
 android_glUniform3iv__IILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint location, jint count, jobject v_buf) {
+    jint _exception = 0;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
     GLint *v = (GLint *) 0;
 
     v = (GLint *)getPointer(_env, v_buf, &_array, &_remaining, &_bufferOffset);
+    if (_remaining < count*3) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "remaining() < count*3 < needed";
+        goto exit;
+    }
     if (v == NULL) {
         char * _vBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
         v = (GLint *) (_vBase + _bufferOffset);
@@ -5255,9 +5075,14 @@
         (GLsizei)count,
         (GLint *)v
     );
+
+exit:
     if (_array) {
         releasePointer(_env, _array, v, JNI_FALSE);
     }
+    if (_exception) {
+        jniThrowException(_env, _exceptionType, _exceptionMessage);
+    }
 }
 
 /* void glUniform4f ( GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w ) */
@@ -5278,8 +5103,8 @@
 android_glUniform4fv__II_3FI
   (JNIEnv *_env, jobject _this, jint location, jint count, jfloatArray v_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *v_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *v = (GLfloat *) 0;
@@ -5297,6 +5122,12 @@
         goto exit;
     }
     _remaining = _env->GetArrayLength(v_ref) - offset;
+    if (_remaining < count*4) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "length - offset < count*4 < needed";
+        goto exit;
+    }
     v_base = (GLfloat *)
         _env->GetPrimitiveArrayCritical(v_ref, (jboolean *)0);
     v = v_base + offset;
@@ -5321,12 +5152,21 @@
 static void
 android_glUniform4fv__IILjava_nio_FloatBuffer_2
   (JNIEnv *_env, jobject _this, jint location, jint count, jobject v_buf) {
+    jint _exception = 0;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
     GLfloat *v = (GLfloat *) 0;
 
     v = (GLfloat *)getPointer(_env, v_buf, &_array, &_remaining, &_bufferOffset);
+    if (_remaining < count*4) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "remaining() < count*4 < needed";
+        goto exit;
+    }
     if (v == NULL) {
         char * _vBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
         v = (GLfloat *) (_vBase + _bufferOffset);
@@ -5336,9 +5176,14 @@
         (GLsizei)count,
         (GLfloat *)v
     );
+
+exit:
     if (_array) {
         releasePointer(_env, _array, v, JNI_FALSE);
     }
+    if (_exception) {
+        jniThrowException(_env, _exceptionType, _exceptionMessage);
+    }
 }
 
 /* void glUniform4i ( GLint location, GLint x, GLint y, GLint z, GLint w ) */
@@ -5359,8 +5204,8 @@
 android_glUniform4iv__II_3II
   (JNIEnv *_env, jobject _this, jint location, jint count, jintArray v_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLint *v_base = (GLint *) 0;
     jint _remaining;
     GLint *v = (GLint *) 0;
@@ -5378,6 +5223,12 @@
         goto exit;
     }
     _remaining = _env->GetArrayLength(v_ref) - offset;
+    if (_remaining < count*4) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "length - offset < count*4 < needed";
+        goto exit;
+    }
     v_base = (GLint *)
         _env->GetPrimitiveArrayCritical(v_ref, (jboolean *)0);
     v = v_base + offset;
@@ -5402,12 +5253,21 @@
 static void
 android_glUniform4iv__IILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint location, jint count, jobject v_buf) {
+    jint _exception = 0;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
     GLint *v = (GLint *) 0;
 
     v = (GLint *)getPointer(_env, v_buf, &_array, &_remaining, &_bufferOffset);
+    if (_remaining < count*4) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "remaining() < count*4 < needed";
+        goto exit;
+    }
     if (v == NULL) {
         char * _vBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
         v = (GLint *) (_vBase + _bufferOffset);
@@ -5417,9 +5277,14 @@
         (GLsizei)count,
         (GLint *)v
     );
+
+exit:
     if (_array) {
         releasePointer(_env, _array, v, JNI_FALSE);
     }
+    if (_exception) {
+        jniThrowException(_env, _exceptionType, _exceptionMessage);
+    }
 }
 
 /* void glUniformMatrix2fv ( GLint location, GLsizei count, GLboolean transpose, const GLfloat *value ) */
@@ -5427,8 +5292,8 @@
 android_glUniformMatrix2fv__IIZ_3FI
   (JNIEnv *_env, jobject _this, jint location, jint count, jboolean transpose, jfloatArray value_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *value_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *value = (GLfloat *) 0;
@@ -5446,6 +5311,12 @@
         goto exit;
     }
     _remaining = _env->GetArrayLength(value_ref) - offset;
+    if (_remaining < count*4) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "length - offset < count*4 < needed";
+        goto exit;
+    }
     value_base = (GLfloat *)
         _env->GetPrimitiveArrayCritical(value_ref, (jboolean *)0);
     value = value_base + offset;
@@ -5471,12 +5342,21 @@
 static void
 android_glUniformMatrix2fv__IIZLjava_nio_FloatBuffer_2
   (JNIEnv *_env, jobject _this, jint location, jint count, jboolean transpose, jobject value_buf) {
+    jint _exception = 0;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
     GLfloat *value = (GLfloat *) 0;
 
     value = (GLfloat *)getPointer(_env, value_buf, &_array, &_remaining, &_bufferOffset);
+    if (_remaining < count*4) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "remaining() < count*4 < needed";
+        goto exit;
+    }
     if (value == NULL) {
         char * _valueBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
         value = (GLfloat *) (_valueBase + _bufferOffset);
@@ -5487,9 +5367,14 @@
         (GLboolean)transpose,
         (GLfloat *)value
     );
+
+exit:
     if (_array) {
         releasePointer(_env, _array, value, JNI_FALSE);
     }
+    if (_exception) {
+        jniThrowException(_env, _exceptionType, _exceptionMessage);
+    }
 }
 
 /* void glUniformMatrix3fv ( GLint location, GLsizei count, GLboolean transpose, const GLfloat *value ) */
@@ -5497,8 +5382,8 @@
 android_glUniformMatrix3fv__IIZ_3FI
   (JNIEnv *_env, jobject _this, jint location, jint count, jboolean transpose, jfloatArray value_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *value_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *value = (GLfloat *) 0;
@@ -5516,6 +5401,12 @@
         goto exit;
     }
     _remaining = _env->GetArrayLength(value_ref) - offset;
+    if (_remaining < count*9) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "length - offset < count*9 < needed";
+        goto exit;
+    }
     value_base = (GLfloat *)
         _env->GetPrimitiveArrayCritical(value_ref, (jboolean *)0);
     value = value_base + offset;
@@ -5541,12 +5432,21 @@
 static void
 android_glUniformMatrix3fv__IIZLjava_nio_FloatBuffer_2
   (JNIEnv *_env, jobject _this, jint location, jint count, jboolean transpose, jobject value_buf) {
+    jint _exception = 0;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
     GLfloat *value = (GLfloat *) 0;
 
     value = (GLfloat *)getPointer(_env, value_buf, &_array, &_remaining, &_bufferOffset);
+    if (_remaining < count*9) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "remaining() < count*9 < needed";
+        goto exit;
+    }
     if (value == NULL) {
         char * _valueBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
         value = (GLfloat *) (_valueBase + _bufferOffset);
@@ -5557,9 +5457,14 @@
         (GLboolean)transpose,
         (GLfloat *)value
     );
+
+exit:
     if (_array) {
         releasePointer(_env, _array, value, JNI_FALSE);
     }
+    if (_exception) {
+        jniThrowException(_env, _exceptionType, _exceptionMessage);
+    }
 }
 
 /* void glUniformMatrix4fv ( GLint location, GLsizei count, GLboolean transpose, const GLfloat *value ) */
@@ -5567,8 +5472,8 @@
 android_glUniformMatrix4fv__IIZ_3FI
   (JNIEnv *_env, jobject _this, jint location, jint count, jboolean transpose, jfloatArray value_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *value_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *value = (GLfloat *) 0;
@@ -5586,6 +5491,12 @@
         goto exit;
     }
     _remaining = _env->GetArrayLength(value_ref) - offset;
+    if (_remaining < count*16) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "length - offset < count*16 < needed";
+        goto exit;
+    }
     value_base = (GLfloat *)
         _env->GetPrimitiveArrayCritical(value_ref, (jboolean *)0);
     value = value_base + offset;
@@ -5611,12 +5522,21 @@
 static void
 android_glUniformMatrix4fv__IIZLjava_nio_FloatBuffer_2
   (JNIEnv *_env, jobject _this, jint location, jint count, jboolean transpose, jobject value_buf) {
+    jint _exception = 0;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
     GLfloat *value = (GLfloat *) 0;
 
     value = (GLfloat *)getPointer(_env, value_buf, &_array, &_remaining, &_bufferOffset);
+    if (_remaining < count*16) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "remaining() < count*16 < needed";
+        goto exit;
+    }
     if (value == NULL) {
         char * _valueBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
         value = (GLfloat *) (_valueBase + _bufferOffset);
@@ -5627,9 +5547,14 @@
         (GLboolean)transpose,
         (GLfloat *)value
     );
+
+exit:
     if (_array) {
         releasePointer(_env, _array, value, JNI_FALSE);
     }
+    if (_exception) {
+        jniThrowException(_env, _exceptionType, _exceptionMessage);
+    }
 }
 
 /* void glUseProgram ( GLuint program ) */
@@ -5665,8 +5590,8 @@
 android_glVertexAttrib1fv__I_3FI
   (JNIEnv *_env, jobject _this, jint indx, jfloatArray values_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *values_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *values = (GLfloat *) 0;
@@ -5684,6 +5609,12 @@
         goto exit;
     }
     _remaining = _env->GetArrayLength(values_ref) - offset;
+    if (_remaining < 1) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "length - offset < 1 < needed";
+        goto exit;
+    }
     values_base = (GLfloat *)
         _env->GetPrimitiveArrayCritical(values_ref, (jboolean *)0);
     values = values_base + offset;
@@ -5707,12 +5638,21 @@
 static void
 android_glVertexAttrib1fv__ILjava_nio_FloatBuffer_2
   (JNIEnv *_env, jobject _this, jint indx, jobject values_buf) {
+    jint _exception = 0;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
     GLfloat *values = (GLfloat *) 0;
 
     values = (GLfloat *)getPointer(_env, values_buf, &_array, &_remaining, &_bufferOffset);
+    if (_remaining < 1) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "remaining() < 1 < needed";
+        goto exit;
+    }
     if (values == NULL) {
         char * _valuesBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
         values = (GLfloat *) (_valuesBase + _bufferOffset);
@@ -5721,9 +5661,14 @@
         (GLuint)indx,
         (GLfloat *)values
     );
+
+exit:
     if (_array) {
         releasePointer(_env, _array, values, JNI_FALSE);
     }
+    if (_exception) {
+        jniThrowException(_env, _exceptionType, _exceptionMessage);
+    }
 }
 
 /* void glVertexAttrib2f ( GLuint indx, GLfloat x, GLfloat y ) */
@@ -5742,8 +5687,8 @@
 android_glVertexAttrib2fv__I_3FI
   (JNIEnv *_env, jobject _this, jint indx, jfloatArray values_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *values_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *values = (GLfloat *) 0;
@@ -5761,6 +5706,12 @@
         goto exit;
     }
     _remaining = _env->GetArrayLength(values_ref) - offset;
+    if (_remaining < 2) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "length - offset < 2 < needed";
+        goto exit;
+    }
     values_base = (GLfloat *)
         _env->GetPrimitiveArrayCritical(values_ref, (jboolean *)0);
     values = values_base + offset;
@@ -5784,12 +5735,21 @@
 static void
 android_glVertexAttrib2fv__ILjava_nio_FloatBuffer_2
   (JNIEnv *_env, jobject _this, jint indx, jobject values_buf) {
+    jint _exception = 0;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
     GLfloat *values = (GLfloat *) 0;
 
     values = (GLfloat *)getPointer(_env, values_buf, &_array, &_remaining, &_bufferOffset);
+    if (_remaining < 2) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "remaining() < 2 < needed";
+        goto exit;
+    }
     if (values == NULL) {
         char * _valuesBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
         values = (GLfloat *) (_valuesBase + _bufferOffset);
@@ -5798,9 +5758,14 @@
         (GLuint)indx,
         (GLfloat *)values
     );
+
+exit:
     if (_array) {
         releasePointer(_env, _array, values, JNI_FALSE);
     }
+    if (_exception) {
+        jniThrowException(_env, _exceptionType, _exceptionMessage);
+    }
 }
 
 /* void glVertexAttrib3f ( GLuint indx, GLfloat x, GLfloat y, GLfloat z ) */
@@ -5820,8 +5785,8 @@
 android_glVertexAttrib3fv__I_3FI
   (JNIEnv *_env, jobject _this, jint indx, jfloatArray values_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *values_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *values = (GLfloat *) 0;
@@ -5839,6 +5804,12 @@
         goto exit;
     }
     _remaining = _env->GetArrayLength(values_ref) - offset;
+    if (_remaining < 3) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "length - offset < 3 < needed";
+        goto exit;
+    }
     values_base = (GLfloat *)
         _env->GetPrimitiveArrayCritical(values_ref, (jboolean *)0);
     values = values_base + offset;
@@ -5862,12 +5833,21 @@
 static void
 android_glVertexAttrib3fv__ILjava_nio_FloatBuffer_2
   (JNIEnv *_env, jobject _this, jint indx, jobject values_buf) {
+    jint _exception = 0;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
     GLfloat *values = (GLfloat *) 0;
 
     values = (GLfloat *)getPointer(_env, values_buf, &_array, &_remaining, &_bufferOffset);
+    if (_remaining < 3) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "remaining() < 3 < needed";
+        goto exit;
+    }
     if (values == NULL) {
         char * _valuesBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
         values = (GLfloat *) (_valuesBase + _bufferOffset);
@@ -5876,9 +5856,14 @@
         (GLuint)indx,
         (GLfloat *)values
     );
+
+exit:
     if (_array) {
         releasePointer(_env, _array, values, JNI_FALSE);
     }
+    if (_exception) {
+        jniThrowException(_env, _exceptionType, _exceptionMessage);
+    }
 }
 
 /* void glVertexAttrib4f ( GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w ) */
@@ -5899,8 +5884,8 @@
 android_glVertexAttrib4fv__I_3FI
   (JNIEnv *_env, jobject _this, jint indx, jfloatArray values_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *values_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *values = (GLfloat *) 0;
@@ -5918,6 +5903,12 @@
         goto exit;
     }
     _remaining = _env->GetArrayLength(values_ref) - offset;
+    if (_remaining < 4) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "length - offset < 4 < needed";
+        goto exit;
+    }
     values_base = (GLfloat *)
         _env->GetPrimitiveArrayCritical(values_ref, (jboolean *)0);
     values = values_base + offset;
@@ -5941,12 +5932,21 @@
 static void
 android_glVertexAttrib4fv__ILjava_nio_FloatBuffer_2
   (JNIEnv *_env, jobject _this, jint indx, jobject values_buf) {
+    jint _exception = 0;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
     GLfloat *values = (GLfloat *) 0;
 
     values = (GLfloat *)getPointer(_env, values_buf, &_array, &_remaining, &_bufferOffset);
+    if (_remaining < 4) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "remaining() < 4 < needed";
+        goto exit;
+    }
     if (values == NULL) {
         char * _valuesBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
         values = (GLfloat *) (_valuesBase + _bufferOffset);
@@ -5955,9 +5955,14 @@
         (GLuint)indx,
         (GLfloat *)values
     );
+
+exit:
     if (_array) {
         releasePointer(_env, _array, values, JNI_FALSE);
     }
+    if (_exception) {
+        jniThrowException(_env, _exceptionType, _exceptionMessage);
+    }
 }
 
 /* void glVertexAttribPointer ( GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLint offset ) */
diff --git a/core/jni/com_google_android_gles_jni_GLImpl.cpp b/core/jni/com_google_android_gles_jni_GLImpl.cpp
index 3f9942e..badd697 100644
--- a/core/jni/com_google_android_gles_jni_GLImpl.cpp
+++ b/core/jni/com_google_android_gles_jni_GLImpl.cpp
@@ -541,8 +541,8 @@
 android_glDeleteTextures__I_3II
   (JNIEnv *_env, jobject _this, jint n, jintArray textures_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLuint *textures_base = (GLuint *) 0;
     jint _remaining;
     GLuint *textures = (GLuint *) 0;
@@ -590,8 +590,8 @@
 android_glDeleteTextures__ILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint n, jobject textures_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -694,8 +694,8 @@
 android_glDrawElements__IIILjava_nio_Buffer_2
   (JNIEnv *_env, jobject _this, jint mode, jint count, jint type, jobject indices_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -775,8 +775,8 @@
 android_glFogfv__I_3FI
   (JNIEnv *_env, jobject _this, jint pname, jfloatArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *params_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *params = (GLfloat *) 0;
@@ -816,7 +816,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -849,8 +849,8 @@
 android_glFogfv__ILjava_nio_FloatBuffer_2
   (JNIEnv *_env, jobject _this, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -879,7 +879,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -921,8 +921,8 @@
 android_glFogxv__I_3II
   (JNIEnv *_env, jobject _this, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *params_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *params = (GLfixed *) 0;
@@ -962,7 +962,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -995,8 +995,8 @@
 android_glFogxv__ILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -1025,7 +1025,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -1094,8 +1094,8 @@
 android_glGenTextures__I_3II
   (JNIEnv *_env, jobject _this, jint n, jintArray textures_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLuint *textures_base = (GLuint *) 0;
     jint _remaining;
     GLuint *textures = (GLuint *) 0;
@@ -1143,8 +1143,8 @@
 android_glGenTextures__ILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint n, jobject textures_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -1189,8 +1189,8 @@
 android_glGetIntegerv__I_3II
   (JNIEnv *_env, jobject _this, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLint *params_base = (GLint *) 0;
     jint _remaining;
     GLint *params = (GLint *) 0;
@@ -1536,7 +1536,7 @@
             _needed = getNumCompressedTextureFormats();
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -1569,8 +1569,8 @@
 android_glGetIntegerv__ILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -1905,7 +1905,7 @@
             _needed = getNumCompressedTextureFormats();
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -1962,8 +1962,8 @@
 android_glLightModelfv__I_3FI
   (JNIEnv *_env, jobject _this, jint pname, jfloatArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *params_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *params = (GLfloat *) 0;
@@ -1994,7 +1994,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -2027,8 +2027,8 @@
 android_glLightModelfv__ILjava_nio_FloatBuffer_2
   (JNIEnv *_env, jobject _this, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -2048,7 +2048,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -2090,8 +2090,8 @@
 android_glLightModelxv__I_3II
   (JNIEnv *_env, jobject _this, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *params_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *params = (GLfixed *) 0;
@@ -2122,7 +2122,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -2155,8 +2155,8 @@
 android_glLightModelxv__ILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -2176,7 +2176,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -2219,8 +2219,8 @@
 android_glLightfv__II_3FI
   (JNIEnv *_env, jobject _this, jint light, jint pname, jfloatArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *params_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *params = (GLfloat *) 0;
@@ -2277,7 +2277,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -2311,8 +2311,8 @@
 android_glLightfv__IILjava_nio_FloatBuffer_2
   (JNIEnv *_env, jobject _this, jint light, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -2358,7 +2358,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -2402,8 +2402,8 @@
 android_glLightxv__II_3II
   (JNIEnv *_env, jobject _this, jint light, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *params_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *params = (GLfixed *) 0;
@@ -2460,7 +2460,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -2494,8 +2494,8 @@
 android_glLightxv__IILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint light, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -2541,7 +2541,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -2599,8 +2599,8 @@
 android_glLoadMatrixf___3FI
   (JNIEnv *_env, jobject _this, jfloatArray m_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *m_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *m = (GLfloat *) 0;
@@ -2663,8 +2663,8 @@
 android_glLoadMatrixx___3II
   (JNIEnv *_env, jobject _this, jintArray m_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *m_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *m = (GLfixed *) 0;
@@ -2747,8 +2747,8 @@
 android_glMaterialfv__II_3FI
   (JNIEnv *_env, jobject _this, jint face, jint pname, jfloatArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *params_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *params = (GLfloat *) 0;
@@ -2791,7 +2791,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -2825,8 +2825,8 @@
 android_glMaterialfv__IILjava_nio_FloatBuffer_2
   (JNIEnv *_env, jobject _this, jint face, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -2858,7 +2858,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -2902,8 +2902,8 @@
 android_glMaterialxv__II_3II
   (JNIEnv *_env, jobject _this, jint face, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *params_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *params = (GLfixed *) 0;
@@ -2946,7 +2946,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -2980,8 +2980,8 @@
 android_glMaterialxv__IILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint face, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -3013,7 +3013,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -3055,8 +3055,8 @@
 android_glMultMatrixf___3FI
   (JNIEnv *_env, jobject _this, jfloatArray m_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *m_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *m = (GLfloat *) 0;
@@ -3119,8 +3119,8 @@
 android_glMultMatrixx___3II
   (JNIEnv *_env, jobject _this, jintArray m_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *m_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *m = (GLfixed *) 0;
@@ -3525,8 +3525,8 @@
 android_glTexEnvfv__II_3FI
   (JNIEnv *_env, jobject _this, jint target, jint pname, jfloatArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *params_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *params = (GLfloat *) 0;
@@ -3563,7 +3563,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -3597,8 +3597,8 @@
 android_glTexEnvfv__IILjava_nio_FloatBuffer_2
   (JNIEnv *_env, jobject _this, jint target, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -3624,7 +3624,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -3668,8 +3668,8 @@
 android_glTexEnvxv__II_3II
   (JNIEnv *_env, jobject _this, jint target, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *params_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *params = (GLfixed *) 0;
@@ -3706,7 +3706,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -3740,8 +3740,8 @@
 android_glTexEnvxv__IILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint target, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -3767,7 +3767,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -3944,8 +3944,8 @@
 android_glQueryMatrixxOES___3II_3II
   (JNIEnv *_env, jobject _this, jintArray mantissa_ref, jint mantissaOffset, jintArray exponent_ref, jint exponentOffset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLbitfield _returnValue = -1;
     GLfixed *mantissa_base = (GLfixed *) 0;
     jint _mantissaRemaining;
@@ -4025,8 +4025,8 @@
 android_glQueryMatrixxOES__Ljava_nio_IntBuffer_2Ljava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jobject mantissa_buf, jobject exponent_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _mantissaArray = (jarray) 0;
     jint _mantissaBufferOffset = (jint) 0;
     jarray _exponentArray = (jarray) 0;
@@ -4092,8 +4092,8 @@
 android_glBufferData__IILjava_nio_Buffer_2I
   (JNIEnv *_env, jobject _this, jint target, jint size, jobject data_buf, jint usage) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -4133,8 +4133,8 @@
 android_glBufferSubData__IIILjava_nio_Buffer_2
   (JNIEnv *_env, jobject _this, jint target, jint offset, jint size, jobject data_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -4172,8 +4172,8 @@
 android_glClipPlanef__I_3FI
   (JNIEnv *_env, jobject _this, jint plane, jfloatArray equation_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *equation_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *equation = (GLfloat *) 0;
@@ -4221,8 +4221,8 @@
 android_glClipPlanef__ILjava_nio_FloatBuffer_2
   (JNIEnv *_env, jobject _this, jint plane, jobject equation_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -4258,8 +4258,8 @@
 android_glClipPlanex__I_3II
   (JNIEnv *_env, jobject _this, jint plane, jintArray equation_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *equation_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *equation = (GLfixed *) 0;
@@ -4307,8 +4307,8 @@
 android_glClipPlanex__ILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint plane, jobject equation_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -4368,8 +4368,8 @@
 android_glDeleteBuffers__I_3II
   (JNIEnv *_env, jobject _this, jint n, jintArray buffers_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLuint *buffers_base = (GLuint *) 0;
     jint _remaining;
     GLuint *buffers = (GLuint *) 0;
@@ -4417,8 +4417,8 @@
 android_glDeleteBuffers__ILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint n, jobject buffers_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -4454,8 +4454,8 @@
 android_glDrawElements__IIII
   (JNIEnv *_env, jobject _this, jint mode, jint count, jint type, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     glDrawElements(
         (GLenum)mode,
         (GLsizei)count,
@@ -4472,8 +4472,8 @@
 android_glGenBuffers__I_3II
   (JNIEnv *_env, jobject _this, jint n, jintArray buffers_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLuint *buffers_base = (GLuint *) 0;
     jint _remaining;
     GLuint *buffers = (GLuint *) 0;
@@ -4521,8 +4521,8 @@
 android_glGenBuffers__ILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint n, jobject buffers_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -4558,8 +4558,8 @@
 android_glGetBooleanv__I_3ZI
   (JNIEnv *_env, jobject _this, jint pname, jbooleanArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLboolean *params_base = (GLboolean *) 0;
     jint _remaining;
     GLboolean *params = (GLboolean *) 0;
@@ -4640,8 +4640,8 @@
 android_glGetClipPlanef__I_3FI
   (JNIEnv *_env, jobject _this, jint pname, jfloatArray eqn_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *eqn_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *eqn = (GLfloat *) 0;
@@ -4706,8 +4706,8 @@
 android_glGetClipPlanex__I_3II
   (JNIEnv *_env, jobject _this, jint pname, jintArray eqn_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *eqn_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *eqn = (GLfixed *) 0;
@@ -4772,8 +4772,8 @@
 android_glGetFixedv__I_3II
   (JNIEnv *_env, jobject _this, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *params_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *params = (GLfixed *) 0;
@@ -4838,8 +4838,8 @@
 android_glGetFloatv__I_3FI
   (JNIEnv *_env, jobject _this, jint pname, jfloatArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *params_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *params = (GLfloat *) 0;
@@ -4904,8 +4904,8 @@
 android_glGetLightfv__II_3FI
   (JNIEnv *_env, jobject _this, jint light, jint pname, jfloatArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *params_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *params = (GLfloat *) 0;
@@ -4962,7 +4962,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -4996,8 +4996,8 @@
 android_glGetLightfv__IILjava_nio_FloatBuffer_2
   (JNIEnv *_env, jobject _this, jint light, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -5043,7 +5043,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -5076,8 +5076,8 @@
 android_glGetLightxv__II_3II
   (JNIEnv *_env, jobject _this, jint light, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *params_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *params = (GLfixed *) 0;
@@ -5134,7 +5134,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -5168,8 +5168,8 @@
 android_glGetLightxv__IILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint light, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -5215,7 +5215,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -5248,8 +5248,8 @@
 android_glGetMaterialfv__II_3FI
   (JNIEnv *_env, jobject _this, jint face, jint pname, jfloatArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *params_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *params = (GLfloat *) 0;
@@ -5292,7 +5292,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -5326,8 +5326,8 @@
 android_glGetMaterialfv__IILjava_nio_FloatBuffer_2
   (JNIEnv *_env, jobject _this, jint face, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -5359,7 +5359,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -5392,8 +5392,8 @@
 android_glGetMaterialxv__II_3II
   (JNIEnv *_env, jobject _this, jint face, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *params_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *params = (GLfixed *) 0;
@@ -5436,7 +5436,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -5470,8 +5470,8 @@
 android_glGetMaterialxv__IILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint face, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -5503,7 +5503,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -5536,8 +5536,8 @@
 android_glGetTexEnviv__II_3II
   (JNIEnv *_env, jobject _this, jint env, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLint *params_base = (GLint *) 0;
     jint _remaining;
     GLint *params = (GLint *) 0;
@@ -5574,7 +5574,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -5608,8 +5608,8 @@
 android_glGetTexEnviv__IILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint env, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -5635,7 +5635,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -5668,8 +5668,8 @@
 android_glGetTexEnvxv__II_3II
   (JNIEnv *_env, jobject _this, jint env, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *params_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *params = (GLfixed *) 0;
@@ -5706,7 +5706,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -5740,8 +5740,8 @@
 android_glGetTexEnvxv__IILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint env, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -5767,7 +5767,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -5800,8 +5800,8 @@
 android_glGetTexParameterfv__II_3FI
   (JNIEnv *_env, jobject _this, jint target, jint pname, jfloatArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *params_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *params = (GLfloat *) 0;
@@ -5850,8 +5850,8 @@
 android_glGetTexParameterfv__IILjava_nio_FloatBuffer_2
   (JNIEnv *_env, jobject _this, jint target, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -5888,8 +5888,8 @@
 android_glGetTexParameteriv__II_3II
   (JNIEnv *_env, jobject _this, jint target, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLint *params_base = (GLint *) 0;
     jint _remaining;
     GLint *params = (GLint *) 0;
@@ -5938,8 +5938,8 @@
 android_glGetTexParameteriv__IILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint target, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -5976,8 +5976,8 @@
 android_glGetTexParameterxv__II_3II
   (JNIEnv *_env, jobject _this, jint target, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *params_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *params = (GLfixed *) 0;
@@ -6026,8 +6026,8 @@
 android_glGetTexParameterxv__IILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint target, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -6118,8 +6118,8 @@
 android_glPointParameterfv__I_3FI
   (JNIEnv *_env, jobject _this, jint pname, jfloatArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *params_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *params = (GLfloat *) 0;
@@ -6167,8 +6167,8 @@
 android_glPointParameterfv__ILjava_nio_FloatBuffer_2
   (JNIEnv *_env, jobject _this, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -6214,8 +6214,8 @@
 android_glPointParameterxv__I_3II
   (JNIEnv *_env, jobject _this, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *params_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *params = (GLfixed *) 0;
@@ -6263,8 +6263,8 @@
 android_glPointParameterxv__ILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -6346,8 +6346,8 @@
 android_glTexEnviv__II_3II
   (JNIEnv *_env, jobject _this, jint target, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLint *params_base = (GLint *) 0;
     jint _remaining;
     GLint *params = (GLint *) 0;
@@ -6384,7 +6384,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -6418,8 +6418,8 @@
 android_glTexEnviv__IILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint target, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -6445,7 +6445,7 @@
             _needed = 4;
             break;
         default:
-            _needed = 0;
+            _needed = 1;
             break;
     }
     if (_remaining < _needed) {
@@ -6478,8 +6478,8 @@
 android_glTexParameterfv__II_3FI
   (JNIEnv *_env, jobject _this, jint target, jint pname, jfloatArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *params_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *params = (GLfloat *) 0;
@@ -6528,8 +6528,8 @@
 android_glTexParameterfv__IILjava_nio_FloatBuffer_2
   (JNIEnv *_env, jobject _this, jint target, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -6577,8 +6577,8 @@
 android_glTexParameteriv__II_3II
   (JNIEnv *_env, jobject _this, jint target, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLint *params_base = (GLint *) 0;
     jint _remaining;
     GLint *params = (GLint *) 0;
@@ -6627,8 +6627,8 @@
 android_glTexParameteriv__IILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint target, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -6665,8 +6665,8 @@
 android_glTexParameterxv__II_3II
   (JNIEnv *_env, jobject _this, jint target, jint pname, jintArray params_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *params_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *params = (GLfixed *) 0;
@@ -6715,8 +6715,8 @@
 android_glTexParameterxv__IILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint target, jint pname, jobject params_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -6787,8 +6787,8 @@
 android_glDrawTexfvOES___3FI
   (JNIEnv *_env, jobject _this, jfloatArray coords_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *coords_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *coords = (GLfloat *) 0;
@@ -6835,8 +6835,8 @@
 android_glDrawTexfvOES__Ljava_nio_FloatBuffer_2
   (JNIEnv *_env, jobject _this, jobject coords_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -6884,8 +6884,8 @@
 android_glDrawTexivOES___3II
   (JNIEnv *_env, jobject _this, jintArray coords_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLint *coords_base = (GLint *) 0;
     jint _remaining;
     GLint *coords = (GLint *) 0;
@@ -6932,8 +6932,8 @@
 android_glDrawTexivOES__Ljava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jobject coords_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -6981,8 +6981,8 @@
 android_glDrawTexsvOES___3SI
   (JNIEnv *_env, jobject _this, jshortArray coords_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLshort *coords_base = (GLshort *) 0;
     jint _remaining;
     GLshort *coords = (GLshort *) 0;
@@ -7029,8 +7029,8 @@
 android_glDrawTexsvOES__Ljava_nio_ShortBuffer_2
   (JNIEnv *_env, jobject _this, jobject coords_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -7078,8 +7078,8 @@
 android_glDrawTexxvOES___3II
   (JNIEnv *_env, jobject _this, jintArray coords_ref, jint offset) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfixed *coords_base = (GLfixed *) 0;
     jint _remaining;
     GLfixed *coords = (GLfixed *) 0;
@@ -7126,8 +7126,8 @@
 android_glDrawTexxvOES__Ljava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jobject coords_buf) {
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -7338,8 +7338,8 @@
             return;
     }
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLuint *framebuffers_base = (GLuint *) 0;
     jint _remaining;
     GLuint *framebuffers = (GLuint *) 0;
@@ -7392,8 +7392,8 @@
             return;
     }
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -7434,8 +7434,8 @@
             return;
     }
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLuint *renderbuffers_base = (GLuint *) 0;
     jint _remaining;
     GLuint *renderbuffers = (GLuint *) 0;
@@ -7488,8 +7488,8 @@
             return;
     }
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -7579,8 +7579,8 @@
             return;
     }
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLuint *framebuffers_base = (GLuint *) 0;
     jint _remaining;
     GLuint *framebuffers = (GLuint *) 0;
@@ -7633,8 +7633,8 @@
             return;
     }
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -7675,8 +7675,8 @@
             return;
     }
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLuint *renderbuffers_base = (GLuint *) 0;
     jint _remaining;
     GLuint *renderbuffers = (GLuint *) 0;
@@ -7729,8 +7729,8 @@
             return;
     }
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     jarray _array = (jarray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
@@ -7771,8 +7771,8 @@
             return;
     }
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLint *params_base = (GLint *) 0;
     jint _remaining;
     GLint *params = (GLint *) 0;
@@ -7851,8 +7851,8 @@
             return;
     }
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLint *params_base = (GLint *) 0;
     jint _remaining;
     GLint *params = (GLint *) 0;
@@ -7929,8 +7929,8 @@
             return;
     }
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *params_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *params = (GLfloat *) 0;
@@ -8007,8 +8007,8 @@
             return;
     }
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLint *params_base = (GLint *) 0;
     jint _remaining;
     GLint *params = (GLint *) 0;
@@ -8085,8 +8085,8 @@
             return;
     }
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLint *params_base = (GLint *) 0;
     jint _remaining;
     GLint *params = (GLint *) 0;
@@ -8228,8 +8228,8 @@
             return;
     }
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLfloat *params_base = (GLfloat *) 0;
     jint _remaining;
     GLfloat *params = (GLfloat *) 0;
@@ -8322,8 +8322,8 @@
             return;
     }
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLint *params_base = (GLint *) 0;
     jint _remaining;
     GLint *params = (GLint *) 0;
@@ -8416,8 +8416,8 @@
             return;
     }
     jint _exception = 0;
-    const char * _exceptionType;
-    const char * _exceptionMessage;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
     GLint *params_base = (GLint *) 0;
     jint _remaining;
     GLint *params = (GLint *) 0;
diff --git a/docs/html/tools/debugging/debugging-tracing.jd b/docs/html/tools/debugging/debugging-tracing.jd
index f0d0c0b..7d750cf 100644
--- a/docs/html/tools/debugging/debugging-tracing.jd
+++ b/docs/html/tools/debugging/debugging-tracing.jd
@@ -18,15 +18,6 @@
           </ol>
         </li>
 
-        <li>
-          <a href="#format">Traceview File Format</a>
-          <ol>
-            <li><a href="#datafileformat">Data File Format</a></li>
-
-            <li><a href="#keyfileformat">Key File Format</a></li>
-          </ol>
-        </li>
-
         <li><a href="#creatingtracefiles">Creating Trace Files</a></li>
 
         <li><a href="#copyingfiles">Copying Trace Files to a Host Machine</a></li>
@@ -95,114 +86,6 @@
        height="630" />
   <p class="img-caption"><strong>Figure 2.</strong> The Traceview Profile Panel</p>
 
-  <h2 id="format">Traceview File Format</h2>
-
-  <p>Tracing creates two distinct pieces of output: a <em>data</em> file, which holds the trace
-  data, and a <em>key</em> file, which provides a mapping from binary identifiers to thread and
-  method names. The files are concatenated when tracing completes, into a single <em>.trace</em>
-  file.</p>
-
-  <p class="note"><strong>Note:</strong> The previous version of Traceview did not concatenate
-  these files for you. If you have old key and data files that you'd still like to trace, you can
-  concatenate them yourself with <code>cat mytrace.key mytrace.data &gt;
-  mytrace.trace</code>.</p>
-
-  <h3 id="datafileformat">Data File Format</h3>
-
-  <p>The data file is binary, structured as follows (all values are stored in little-endian
-  order):</p>
-  <pre>
-* File format:
-* header
-* record 0
-* record 1
-* ...
-*
-* Header format:
-* u4 magic 0x574f4c53 ('SLOW')
-* u2 version
-* u2 offset to data
-* u8 start date/time in usec
-*
-* Record format:
-* u1 thread ID
-* u4 method ID | method action
-* u4 time delta since start, in usec
-</pre>
-
-  <p>The application is expected to parse all of the header fields, then seek to "offset to data"
-  from the start of the file. From there it just reads 9-byte records until EOF is reached.</p>
-
-  <p><em>u8 start date/time in usec</em> is the output from <code>gettimeofday()</code>. It's mainly there so
-  that you can tell if the output was generated yesterday or three months ago.</p>
-
-  <p><em>method action</em> sits in the two least-significant bits of the <em>method</em> word. The
-  currently defined meanings are:</p>
-
-  <ul>
-    <li>0 - method entry</li>
-
-    <li>1 - method exit</li>
-
-    <li>2 - method "exited" when unrolled by exception handling</li>
-
-    <li>3 - (reserved)</li>
-  </ul>
-
-  <p>An unsigned 32-bit integer can hold about 70 minutes of time in microseconds.</p>
-
-  <h3 id="keyfileformat">Key File Format</h3>
-
-  <p>The key file is a plain text file divided into three sections. Each section starts with a
-  keyword that begins with '*'. If you see a '*' at the start of a line, you have found the start
-  of a new section.</p>
-
-  <p>An example file might look like this:</p>
-  <pre>
-*version
-1
-clock=global
-*threads
-1 main
-6 JDWP Handler
-5 Async GC
-4 Reference Handler
-3 Finalizer
-2 Signal Handler
-*methods
-0x080f23f8 java/io/PrintStream write ([BII)V
-0x080f25d4 java/io/PrintStream print (Ljava/lang/String;)V
-0x080f27f4 java/io/PrintStream println (Ljava/lang/String;)V
-0x080da620 java/lang/RuntimeException   &lt;init&gt;    ()V
-[...]
-0x080f630c android/os/Debug startMethodTracing ()V
-0x080f6350 android/os/Debug startMethodTracing (Ljava/lang/String;Ljava/lang/String;I)V
-*end
-</pre>
-<p>The following list describes the major sections of a key file:</p>
-  <dl>
-    <dt><em>version section</em></dt>
-
-    <dd>The first line is the file version number, currently 1. The second line,
-    <code>clock=global</code>, indicates that we use a common clock across all threads. A future
-    version may use per-thread CPU time counters that are independent for every thread.</dd>
-
-    <dt><em>threads section</em></dt>
-
-    <dd>One line per thread. Each line consists of two parts: the thread ID, followed by a tab,
-    followed by the thread name. There are few restrictions on what a valid thread name is, so
-    include everything to the end of the line.</dd>
-
-    <dt><em>methods section</em></dt>
-
-    <dd>One line per method entry or exit. A line consists of four pieces, separated by tab marks:
-    <em>method-ID</em> [TAB] <em>class-name</em> [TAB] <em>method-name</em> [TAB]
-    <em>signature</em> . Only the methods that were actually entered or exited are included in the
-    list. Note that all three identifiers are required to uniquely identify a method.</dd>
-  </dl>
-
-  <p>Neither the threads nor methods sections are sorted.</p>
-
   <h2 id="creatingtracefiles">Creating Trace Files</h2>
 
   <p>To use Traceview, you need to generate log files containing the trace information you want to
@@ -269,9 +152,6 @@
   <p>When using the Android emulator, you must specify an SD card when you create your AVD because the trace files
   are written to the SD card. Your application must have permission to write to the SD card as well.
 
-  <p>The format of the trace files is previously described <a href="#format">in this
-  document</a>.</p>
-
   <h2 id="copyingfiles">Copying Trace Files to a Host Machine</h2>
 
   <p>After your application has run and the system has created your trace files
@@ -297,7 +177,7 @@
   You can use the Proguard <code>mapping.txt</code> file to figure out the original unobfuscated names. For more information
   on this file, see the <a href="{@docRoot}tools/help/proguard.html">Proguard</a> documentation.</p>
 
-      <h2 id="dmtracedump">Using dmtracdedump</h2>
+      <h2 id="dmtracedump">Using dmtracedump</h2>
 
       <p><code>dmtracedump</code> is a tool that gives you an alternate way of generating
       graphical call-stack diagrams from trace log files. The tool uses the Graphviz Dot utility to
@@ -399,4 +279,4 @@
       </ol>
     </dd>
 
-    </dl>
\ No newline at end of file
+    </dl>
diff --git a/libs/hwui/Caches.cpp b/libs/hwui/Caches.cpp
index 88f1d83..5befb95 100644
--- a/libs/hwui/Caches.cpp
+++ b/libs/hwui/Caches.cpp
@@ -91,6 +91,7 @@
 
     debugLayersUpdates = false;
     debugOverdraw = false;
+    debugStencilClip = kStencilHide;
 
     mInitialized = true;
 }
@@ -132,6 +133,7 @@
 bool Caches::initProperties() {
     bool prevDebugLayersUpdates = debugLayersUpdates;
     bool prevDebugOverdraw = debugOverdraw;
+    StencilClipDebug prevDebugStencilClip = debugStencilClip;
 
     char property[PROPERTY_VALUE_MAX];
     if (property_get(PROPERTY_DEBUG_LAYERS_UPDATES, property, NULL) > 0) {
@@ -148,8 +150,23 @@
         debugOverdraw = false;
     }
 
+    // See Properties.h for valid values
+    if (property_get(PROPERTY_DEBUG_STENCIL_CLIP, property, NULL) > 0) {
+        INIT_LOGD("  Stencil clip debug enabled: %s", property);
+        if (!strcmp(property, "hide")) {
+            debugStencilClip = kStencilHide;
+        } else if (!strcmp(property, "highlight")) {
+            debugStencilClip = kStencilShowHighlight;
+        } else if (!strcmp(property, "region")) {
+            debugStencilClip = kStencilShowRegion;
+        }
+    } else {
+        debugStencilClip = kStencilHide;
+    }
+
     return (prevDebugLayersUpdates != debugLayersUpdates) ||
-            (prevDebugOverdraw != debugOverdraw);
+            (prevDebugOverdraw != debugOverdraw) ||
+            (prevDebugStencilClip != debugStencilClip);
 }
 
 void Caches::terminate() {
diff --git a/libs/hwui/Caches.h b/libs/hwui/Caches.h
index 0ca2ffd..c35ad883 100644
--- a/libs/hwui/Caches.h
+++ b/libs/hwui/Caches.h
@@ -245,9 +245,18 @@
 
     // Misc
     GLint maxTextureSize;
+
+    // Debugging
     bool debugLayersUpdates;
     bool debugOverdraw;
 
+    enum StencilClipDebug {
+        kStencilHide,
+        kStencilShowHighlight,
+        kStencilShowRegion
+    };
+    StencilClipDebug debugStencilClip;
+
     TextureCache textureCache;
     LayerCache layerCache;
     RenderBufferCache renderBufferCache;
diff --git a/libs/hwui/Debug.h b/libs/hwui/Debug.h
index 9a6494f..773fe82 100644
--- a/libs/hwui/Debug.h
+++ b/libs/hwui/Debug.h
@@ -48,6 +48,7 @@
 #define DEBUG_RENDER_BUFFERS 0
 
 // Turn on to make stencil operations easier to debug
+// (writes 255 instead of 1 in the buffer, forces 8 bit stencil)
 #define DEBUG_STENCIL 0
 
 // Turn on to display debug info about 9patch objects
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index 1afeaf0..34d1c98 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -1368,6 +1368,12 @@
             drawRegionRects(*mSnapshot->clipRegion, 0xff000000, SkXfermode::kSrc_Mode, false);
 
             mCaches.stencil.enableTest();
+
+            // Draw the region used to generate the stencil if the appropriate debug
+            // mode is enabled
+            if (mCaches.debugStencilClip == Caches::kStencilShowRegion) {
+                drawRegionRects(*mSnapshot->clipRegion, 0x7f0000ff, SkXfermode::kSrcOver_Mode);
+            }
         } else {
             mCaches.stencil.disable();
         }
@@ -1515,12 +1521,20 @@
         }
         setStencilFromClip();
     }
+
     mDescription.reset();
+
     mSetShaderColor = false;
     mColorSet = false;
     mColorA = mColorR = mColorG = mColorB = 0.0f;
     mTextureUnit = 0;
     mTrackDirtyRegions = true;
+
+    // Enable debug highlight when what we're about to draw is tested against
+    // the stencil buffer and if stencil highlight debugging is on
+    mDescription.hasDebugHighlight = !mCaches.debugOverdraw &&
+            mCaches.debugStencilClip == Caches::kStencilShowHighlight &&
+            mCaches.stencil.isTestEnabled();
 }
 
 void OpenGLRenderer::setupDrawWithTexture(bool isAlpha8) {
diff --git a/libs/hwui/Program.h b/libs/hwui/Program.h
index 7b67b3c..13ee336 100644
--- a/libs/hwui/Program.h
+++ b/libs/hwui/Program.h
@@ -83,6 +83,8 @@
 
 #define PROGRAM_HAS_COLORS 42
 
+#define PROGRAM_HAS_DEBUG_HIGHLIGHT 43
+
 ///////////////////////////////////////////////////////////////////////////////
 // Types
 ///////////////////////////////////////////////////////////////////////////////
@@ -159,6 +161,8 @@
     bool hasGammaCorrection;
     float gamma;
 
+    bool hasDebugHighlight;
+
     /**
      * Resets this description. All fields are reset back to the default
      * values they hold after building a new instance.
@@ -199,6 +203,8 @@
 
         hasGammaCorrection = false;
         gamma = 2.2f;
+
+        hasDebugHighlight = false;
     }
 
     /**
@@ -267,6 +273,7 @@
         if (hasGammaCorrection) key |= programid(0x1) << PROGRAM_HAS_GAMMA_CORRECTION;
         if (isSimpleGradient) key |= programid(0x1) << PROGRAM_IS_SIMPLE_GRADIENT;
         if (hasColors) key |= programid(0x1) << PROGRAM_HAS_COLORS;
+        if (hasDebugHighlight) key |= programid(0x1) << PROGRAM_HAS_DEBUG_HIGHLIGHT;
         return key;
     }
 
diff --git a/libs/hwui/ProgramCache.cpp b/libs/hwui/ProgramCache.cpp
index 74d598d..0f014cb 100644
--- a/libs/hwui/ProgramCache.cpp
+++ b/libs/hwui/ProgramCache.cpp
@@ -351,6 +351,8 @@
         // PorterDuff
         "    fragColor = blendColors(colorBlend, fragColor);\n"
 };
+const char* gFS_Main_DebugHighlight =
+        "    gl_FragColor.rgb = vec3(0.0, gl_FragColor.a, 0.0);\n";
 const char* gFS_Footer =
         "}\n\n";
 
@@ -604,7 +606,8 @@
 
     // Optimization for common cases
     if (!description.isAA && !blendFramebuffer && !description.hasColors &&
-            description.colorOp == ProgramDescription::kColorNone && !description.isPoint) {
+            description.colorOp == ProgramDescription::kColorNone &&
+            !description.isPoint && !description.hasDebugHighlight) {
         bool fast = false;
 
         const bool noShader = !description.hasGradient && !description.hasBitmap;
@@ -752,6 +755,9 @@
         if (description.hasColors) {
             shader.append(gFS_Main_FragColor_HasColors);
         }
+        if (description.hasDebugHighlight) {
+            shader.append(gFS_Main_DebugHighlight);
+        }
     }
     // End the shader
     shader.append(gFS_Footer);
diff --git a/libs/hwui/Properties.h b/libs/hwui/Properties.h
index f3957cf..b8559bc8 100644
--- a/libs/hwui/Properties.h
+++ b/libs/hwui/Properties.h
@@ -68,6 +68,20 @@
 #define PROPERTY_DEBUG_OVERDRAW "debug.hwui.show_overdraw"
 
 /**
+ * Used to enable/disable non-rectangular clipping debugging.
+ *
+ * The accepted values are:
+ * "highlight", drawing commands clipped by the stencil will
+ *              be colored differently
+ * "region", renders the clipping region on screen whenever
+ *           the stencil is set
+ * "hide", don't show the clip
+ *
+ * The default value is "hide".
+ */
+#define PROPERTY_DEBUG_STENCIL_CLIP "debug.hwui.show_non_rect_clip"
+
+/**
  * Used to enable/disable scissor optimization. The accepted values are
  * "true" and "false". The default value is "false".
  *
diff --git a/libs/hwui/Stencil.h b/libs/hwui/Stencil.h
index 047f7ee..83ad668 100644
--- a/libs/hwui/Stencil.h
+++ b/libs/hwui/Stencil.h
@@ -87,6 +87,13 @@
         return mState != kDisabled;
     }
 
+    /**
+     * Indicates whether testing only is enabled.
+     */
+    bool isTestEnabled() {
+        return mState == kTest;
+    }
+
 private:
     void enable();
 
diff --git a/opengl/java/android/opengl/GLES10.java b/opengl/java/android/opengl/GLES10.java
index 790acbd..db52b82 100644
--- a/opengl/java/android/opengl/GLES10.java
+++ b/opengl/java/android/opengl/GLES10.java
@@ -669,22 +669,6 @@
         java.nio.IntBuffer params
     );
 
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
     // C function const GLubyte * glGetString ( GLenum name )
 
     public static native String glGetString(
diff --git a/opengl/java/android/opengl/GLES20.java b/opengl/java/android/opengl/GLES20.java
index e99d412..dd9f8b8 100644
--- a/opengl/java/android/opengl/GLES20.java
+++ b/opengl/java/android/opengl/GLES20.java
@@ -1024,22 +1024,6 @@
         java.nio.IntBuffer params
     );
 
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
     // C function void glGetProgramInfoLog( GLuint program, GLsizei maxLength, GLsizei * length,
  	//     GLchar * infoLog);
 
@@ -1080,22 +1064,6 @@
         java.nio.IntBuffer params
     );
 
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
     // C function void glGetShaderInfoLog( GLuint shader, GLsizei maxLength, GLsizei * length,
  	//     GLchar * infoLog);
 
@@ -1147,22 +1115,6 @@
     public static native String glGetShaderSource(
         int shader
     );
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
     // C function const GLubyte * glGetString ( GLenum name )
 
     public static native String glGetString(
@@ -1415,22 +1367,6 @@
         int length
     );
 
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
     // C function void glShaderSource ( GLuint shader, GLsizei count, const GLchar ** string, const GLint* length )
 
     public static native void glShaderSource(
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java
index 621e662..4a67997 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java
@@ -16,8 +16,6 @@
 
 package com.android.providers.settings;
 
-import java.util.Locale;
-
 import android.app.ActivityManagerNative;
 import android.app.IActivityManager;
 import android.app.backup.IBackupManager;
@@ -28,9 +26,12 @@
 import android.os.IPowerManager;
 import android.os.RemoteException;
 import android.os.ServiceManager;
+import android.os.UserManager;
 import android.provider.Settings;
 import android.text.TextUtils;
 
+import java.util.Locale;
+
 public class SettingsHelper {
     private Context mContext;
     private AudioManager mAudioManager;
@@ -96,6 +97,10 @@
     }
 
     private void setGpsLocation(String value) {
+        UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
+        if (! um.isLocationSharingToggleAllowed()) {
+            return;
+        }
         final String GPS = LocationManager.GPS_PROVIDER;
         boolean enabled = 
                 GPS.equals(value) ||
diff --git a/services/java/com/android/server/pm/PackageManagerService.java b/services/java/com/android/server/pm/PackageManagerService.java
index 5f44ff4..7fb8902 100644
--- a/services/java/com/android/server/pm/PackageManagerService.java
+++ b/services/java/com/android/server/pm/PackageManagerService.java
@@ -1454,7 +1454,7 @@
                 if ("group".equals(name)) {
                     String gidStr = parser.getAttributeValue(null, "gid");
                     if (gidStr != null) {
-                        int gid = Integer.parseInt(gidStr);
+                        int gid = Process.getGidForName(gidStr);
                         mGlobalGids = appendInt(mGlobalGids, gid);
                     } else {
                         Slog.w(TAG, "<group> without gid at "
diff --git a/services/java/com/android/server/pm/UserManagerService.java b/services/java/com/android/server/pm/UserManagerService.java
index 18ccf75..c3f4256 100644
--- a/services/java/com/android/server/pm/UserManagerService.java
+++ b/services/java/com/android/server/pm/UserManagerService.java
@@ -603,6 +603,7 @@
                 writeBoolean(serializer, restrictions, UserManager.ALLOW_MODIFY_ACCOUNTS);
                 writeBoolean(serializer, restrictions, UserManager.ALLOW_INSTALL_APPS);
                 writeBoolean(serializer, restrictions, UserManager.ALLOW_UNINSTALL_APPS);
+                writeBoolean(serializer, restrictions, UserManager.ALLOW_CONFIG_LOCATION_ACCESS);
                 serializer.endTag(null, TAG_RESTRICTIONS);
             }
             serializer.endTag(null, TAG_USER);
@@ -719,6 +720,7 @@
                         readBoolean(parser, restrictions, UserManager.ALLOW_MODIFY_ACCOUNTS);
                         readBoolean(parser, restrictions, UserManager.ALLOW_INSTALL_APPS);
                         readBoolean(parser, restrictions, UserManager.ALLOW_UNINSTALL_APPS);
+                        readBoolean(parser, restrictions, UserManager.ALLOW_CONFIG_LOCATION_ACCESS);
                     }
                 }
             }
@@ -763,6 +765,7 @@
         restrictions.putBoolean(UserManager.ALLOW_MODIFY_ACCOUNTS, true);
         restrictions.putBoolean(UserManager.ALLOW_INSTALL_APPS, true);
         restrictions.putBoolean(UserManager.ALLOW_UNINSTALL_APPS, true);
+        restrictions.putBoolean(UserManager.ALLOW_CONFIG_LOCATION_ACCESS, true);
     }
 
     private int readIntAttribute(XmlPullParser parser, String attr, int defaultValue) {
diff --git a/services/tests/servicestests/src/com/android/server/pm/UserManagerTest.java b/services/tests/servicestests/src/com/android/server/pm/UserManagerTest.java
index c4911a0..7ef1485 100644
--- a/services/tests/servicestests/src/com/android/server/pm/UserManagerTest.java
+++ b/services/tests/servicestests/src/com/android/server/pm/UserManagerTest.java
@@ -22,8 +22,6 @@
 import android.content.IntentFilter;
 import android.content.pm.UserInfo;
 import android.os.Bundle;
-import android.os.Debug;
-import android.os.Environment;
 import android.os.UserHandle;
 import android.os.UserManager;
 import android.test.AndroidTestCase;
@@ -67,6 +65,9 @@
                     && !user.isAdmin()
                     && !user.isPrimary()) {
                 found = true;
+                Bundle restrictions = mUserManager.getUserRestrictions(user.getUserHandle());
+                assertTrue("New user should have ALLOW_CONFIG_WIFI =true by default",
+                        restrictions.getBoolean(UserManager.ALLOW_CONFIG_WIFI));
             }
         }
         assertTrue(found);
diff --git a/tools/aapt/Command.cpp b/tools/aapt/Command.cpp
index 5cec06f..84f5a5c 100644
--- a/tools/aapt/Command.cpp
+++ b/tools/aapt/Command.cpp
@@ -1283,7 +1283,7 @@
                 // network location feature, we infer that it meant to
                 printf("uses-feature:'android.hardware.location.network'\n");
                 printf("uses-implied-feature:'android.hardware.location.network'," \
-                        "'requested android.permission.ACCESS_COURSE_LOCATION permission'\n");
+                        "'requested android.permission.ACCESS_COARSE_LOCATION permission'\n");
             }
 
             // Bluetooth-related compatibility logic