Improve glgen

+ gen script is really a bash script rather than a sh script,
  so declare that to be true. (For example, it uses pushd,
  which is a part of bash, but not a part of sh. Not sure
  how this worked until now. Possibly gen was only run in
  environments where /bin/sh was really bash.

+ Check the results of the java compile of the code generator,
  and abort the script if the compile fails.

+ Turn on the bash shell option that guards against using
  uninitialized variables in the script.

+ Remove the generated class files.

Refactor JniCodeEmitter into two classes: a general-purpose
JniCodeEmitter and a specific Jsr239CodeEmitter. The hope is
to use JniCodeEmitter as a base for emitting static OpenGL ES
bindings.
diff --git a/opengl/tools/glgen/gen b/opengl/tools/glgen/gen
index c060040c..25e9a09 100755
--- a/opengl/tools/glgen/gen
+++ b/opengl/tools/glgen/gen
@@ -1,4 +1,5 @@
-#!/bin/sh
+#!/bin/bash
+set -u
 rm -rf out generated
 
 mkdir out
@@ -12,12 +13,18 @@
 GLFILE=out/javax/microedition/khronos/opengles/GL.java
 cp stubs/GLHeader.java-if $GLFILE
 
-GLGEN_FILES="CFunc.java CType.java CodeEmitter.java GenerateGL.java JFunc.java JType.java JniCodeEmitter.java ParameterChecker.java"
+GLGEN_FILES="CFunc.java CType.java CodeEmitter.java GenerateGL.java JFunc.java JniCodeEmitter.java JType.java Jsr239CodeEmitter.java ParameterChecker.java"
 
 pushd src > /dev/null
 javac ${GLGEN_FILES}
+JAVAC_RESULT=$?
+if [ $JAVAC_RESULT -ne 0 ]; then
+    echo "Could not compile glgen."
+    exit $JAVAC_RESULT
+fi
 popd > /dev/null
 java -classpath src GenerateGL -c glspec-1.0 glspec-1.0ext glspec-1.1 glspec-1.1ext glspec-1.1extpack glspec-checks
+rm src/*.class
 
 pushd out > /dev/null
 mkdir classes