add error propagation for thunking layer

bug 11370403

Change-Id: I5e25d1c01bc4f72445c94d36ffeb509e60f1803f
diff --git a/v8/renderscript/java/src/android/support/v8/renderscript/AllocationThunker.java b/v8/renderscript/java/src/android/support/v8/renderscript/AllocationThunker.java
index 72bb023..f3eb0da 100644
--- a/v8/renderscript/java/src/android/support/v8/renderscript/AllocationThunker.java
+++ b/v8/renderscript/java/src/android/support/v8/renderscript/AllocationThunker.java
@@ -57,11 +57,19 @@
     }
 
     public int getUsage() {
-        return mN.getUsage();
+        try {
+            return mN.getUsage();
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public int getBytesSize() {
-        return mN.getBytesSize();
+        try {
+            return mN.getBytesSize();
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     AllocationThunker(RenderScript rs, Type t, int usage, android.renderscript.Allocation na) {
@@ -73,15 +81,27 @@
     }
 
     public void syncAll(int srcLocation) {
-        mN.syncAll(srcLocation);
+        try {
+            mN.syncAll(srcLocation);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public void ioSend() {
-        mN.ioSend();
+        try {
+            mN.ioSend();
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public void ioReceive() {
-        mN.ioReceive();
+        try {
+            mN.ioReceive();
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public void copyFrom(BaseObj[] d) {
@@ -92,126 +112,262 @@
         for (int i = 0; i < d.length; i++) {
             dN[i] = d[i].getNObj();
         }
-        mN.copyFrom(dN);
+        try {
+            mN.copyFrom(dN);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public void copyFromUnchecked(int[] d) {
-        mN.copyFromUnchecked(d);
+        try {
+            mN.copyFromUnchecked(d);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
     public void copyFromUnchecked(short[] d) {
-        mN.copyFromUnchecked(d);
+        try {
+            mN.copyFromUnchecked(d);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
     public void copyFromUnchecked(byte[] d) {
-        mN.copyFromUnchecked(d);
+        try {
+            mN.copyFromUnchecked(d);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
     public void copyFromUnchecked(float[] d) {
-        mN.copyFromUnchecked(d);
+        try {
+            mN.copyFromUnchecked(d);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public void copyFrom(int[] d) {
-        mN.copyFrom(d);
+        try {
+            mN.copyFrom(d);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
     public void copyFrom(short[] d) {
-        mN.copyFrom(d);
+        try {
+            mN.copyFrom(d);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
     public void copyFrom(byte[] d) {
-        mN.copyFrom(d);
+        try {
+            mN.copyFrom(d);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
     public void copyFrom(float[] d) {
-        mN.copyFrom(d);
+        try {
+            mN.copyFrom(d);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
     public void copyFrom(Bitmap b) {
-        mN.copyFrom(b);
+        try {
+            mN.copyFrom(b);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
     public void copyFrom(Allocation a) {
         AllocationThunker at = (AllocationThunker)a;
-        mN.copyFrom(at.mN);
+        try {
+            mN.copyFrom(at.mN);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
 
     public void setFromFieldPacker(int xoff, FieldPacker fp) {
-        android.renderscript.FieldPacker nfp =
-            new android.renderscript.FieldPacker(fp.getData());
-        mN.setFromFieldPacker(xoff, nfp);
+        try {
+            android.renderscript.FieldPacker nfp =
+                new android.renderscript.FieldPacker(fp.getData());
+            mN.setFromFieldPacker(xoff, nfp);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
     public void setFromFieldPacker(int xoff, int component_number, FieldPacker fp) {
-        android.renderscript.FieldPacker nfp =
-            new android.renderscript.FieldPacker(fp.getData());
-        mN.setFromFieldPacker(xoff, component_number, nfp);
+        try {
+            android.renderscript.FieldPacker nfp =
+                new android.renderscript.FieldPacker(fp.getData());
+            mN.setFromFieldPacker(xoff, component_number, nfp);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public void generateMipmaps() {
-        mN.generateMipmaps();
+        try {
+            mN.generateMipmaps();
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public void copy1DRangeFromUnchecked(int off, int count, int[] d) {
-        mN.copy1DRangeFromUnchecked(off, count, d);
+        try {
+            mN.copy1DRangeFromUnchecked(off, count, d);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
     public void copy1DRangeFromUnchecked(int off, int count, short[] d) {
-        mN.copy1DRangeFromUnchecked(off, count, d);
+        try {
+            mN.copy1DRangeFromUnchecked(off, count, d);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
     public void copy1DRangeFromUnchecked(int off, int count, byte[] d) {
-        mN.copy1DRangeFromUnchecked(off, count, d);
+        try {
+            mN.copy1DRangeFromUnchecked(off, count, d);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
     public void copy1DRangeFromUnchecked(int off, int count, float[] d) {
-        mN.copy1DRangeFromUnchecked(off, count, d);
+        try {
+            mN.copy1DRangeFromUnchecked(off, count, d);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public void copy1DRangeFrom(int off, int count, int[] d) {
-        mN.copy1DRangeFrom(off, count, d);
+        try {
+            mN.copy1DRangeFrom(off, count, d);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
     public void copy1DRangeFrom(int off, int count, short[] d) {
-        mN.copy1DRangeFrom(off, count, d);
+        try {
+            mN.copy1DRangeFrom(off, count, d);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
     public void copy1DRangeFrom(int off, int count, byte[] d) {
-        mN.copy1DRangeFrom(off, count, d);
+        try {
+            mN.copy1DRangeFrom(off, count, d);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
     public void copy1DRangeFrom(int off, int count, float[] d) {
-        mN.copy1DRangeFrom(off, count, d);
+        try {
+            mN.copy1DRangeFrom(off, count, d);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public void copy1DRangeFrom(int off, int count, Allocation data, int dataOff) {
-        AllocationThunker at = (AllocationThunker)data;
-        mN.copy1DRangeFrom(off, count, at.mN, dataOff);
+        try {
+            AllocationThunker at = (AllocationThunker)data;
+            mN.copy1DRangeFrom(off, count, at.mN, dataOff);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public void copy2DRangeFrom(int xoff, int yoff, int w, int h, byte[] data) {
-        mN.copy2DRangeFrom(xoff, yoff, w, h, data);
+        try {
+            mN.copy2DRangeFrom(xoff, yoff, w, h, data);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
     public void copy2DRangeFrom(int xoff, int yoff, int w, int h, short[] data) {
-        mN.copy2DRangeFrom(xoff, yoff, w, h, data);
+        try {
+            mN.copy2DRangeFrom(xoff, yoff, w, h, data);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
     public void copy2DRangeFrom(int xoff, int yoff, int w, int h, int[] data) {
-        mN.copy2DRangeFrom(xoff, yoff, w, h, data);
+        try {
+            mN.copy2DRangeFrom(xoff, yoff, w, h, data);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
     public void copy2DRangeFrom(int xoff, int yoff, int w, int h, float[] data) {
-        mN.copy2DRangeFrom(xoff, yoff, w, h, data);
+        try {
+            mN.copy2DRangeFrom(xoff, yoff, w, h, data);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public void copy2DRangeFrom(int xoff, int yoff, int w, int h,
                                 Allocation data, int dataXoff, int dataYoff) {
-        AllocationThunker at = (AllocationThunker)data;
-        mN.copy2DRangeFrom(xoff, yoff, w, h, at.mN, dataXoff, dataYoff);
+        try {
+            AllocationThunker at = (AllocationThunker)data;
+            mN.copy2DRangeFrom(xoff, yoff, w, h, at.mN, dataXoff, dataYoff);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
     public void copy2DRangeFrom(int xoff, int yoff, Bitmap data) {
-        mN.copy2DRangeFrom(xoff, yoff, data);
+        try {
+            mN.copy2DRangeFrom(xoff, yoff, data);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
 
     public void copyTo(Bitmap b) {
-        mN.copyTo(b);
+        try {
+            mN.copyTo(b);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
     public void copyTo(byte[] d) {
-        mN.copyTo(d);
+        try {
+            mN.copyTo(d);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
     public void copyTo(short[] d) {
-        mN.copyTo(d);
+        try {
+            mN.copyTo(d);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
     public void copyTo(int[] d) {
-        mN.copyTo(d);
+        try {
+            mN.copyTo(d);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
     public void copyTo(float[] d) {
-        mN.copyTo(d);
+        try {
+            mN.copyTo(d);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     // creation
@@ -225,11 +381,15 @@
         RenderScriptThunker rst = (RenderScriptThunker)rs;
         TypeThunker tt = (TypeThunker)type;
 
-        android.renderscript.Allocation a =
-            android.renderscript.Allocation.createTyped(rst.mN, tt.mN,
-                                                        convertMipmapControl(mips), usage);
-
-        return new AllocationThunker(rs, type, usage, a);
+        try {
+            android.renderscript.Allocation a =
+                android.renderscript.Allocation.createTyped(rst.mN, tt.mN,
+                                                            convertMipmapControl(mips),
+                                                            usage);
+            return new AllocationThunker(rs, type, usage, a);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     static public Allocation createFromBitmap(RenderScript rs, Bitmap b,
@@ -237,23 +397,32 @@
                                               int usage) {
 
         RenderScriptThunker rst = (RenderScriptThunker)rs;
-        android.renderscript.Allocation a =
-                android.renderscript.Allocation.createFromBitmap(
-                rst.mN, b, convertMipmapControl(mips), usage);
-        TypeThunker tt = new TypeThunker(rs, a.getType());
+        try {
+            android.renderscript.Allocation a =
+                android.renderscript.Allocation.createFromBitmap(rst.mN, b,
+                                                                 convertMipmapControl(mips),
+                                                                 usage);
+            TypeThunker tt = new TypeThunker(rs, a.getType());
+            return new AllocationThunker(rs, tt, usage, a);
 
-        return new AllocationThunker(rs, tt, usage, a);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     static public Allocation createCubemapFromBitmap(RenderScript rs, Bitmap b,
                                                      MipmapControl mips,
                                                      int usage) {
         RenderScriptThunker rst = (RenderScriptThunker)rs;
-        android.renderscript.Allocation a =
-                android.renderscript.Allocation.createCubemapFromBitmap(
-                rst.mN, b, convertMipmapControl(mips), usage);
-        TypeThunker tt = new TypeThunker(rs, a.getType());
-        return new AllocationThunker(rs, tt, usage, a);
+        try {
+            android.renderscript.Allocation a =
+                    android.renderscript.Allocation.createCubemapFromBitmap(
+                    rst.mN, b, convertMipmapControl(mips), usage);
+            TypeThunker tt = new TypeThunker(rs, a.getType());
+            return new AllocationThunker(rs, tt, usage, a);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     static public Allocation createCubemapFromCubeFaces(RenderScript rs,
@@ -266,12 +435,16 @@
                                                         MipmapControl mips,
                                                         int usage) {
         RenderScriptThunker rst = (RenderScriptThunker)rs;
-        android.renderscript.Allocation a =
-                android.renderscript.Allocation.createCubemapFromCubeFaces(
-                rst.mN, xpos, xneg, ypos, yneg, zpos, zneg,
-                convertMipmapControl(mips), usage);
-        TypeThunker tt = new TypeThunker(rs, a.getType());
-        return new AllocationThunker(rs, tt, usage, a);
+        try {
+            android.renderscript.Allocation a =
+                    android.renderscript.Allocation.createCubemapFromCubeFaces(
+                    rst.mN, xpos, xneg, ypos, yneg, zpos, zneg,
+                    convertMipmapControl(mips), usage);
+            TypeThunker tt = new TypeThunker(rs, a.getType());
+            return new AllocationThunker(rs, tt, usage, a);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     static public Allocation createFromBitmapResource(RenderScript rs,
@@ -281,32 +454,45 @@
                                                       int usage) {
 
         RenderScriptThunker rst = (RenderScriptThunker)rs;
-        android.renderscript.Allocation a =
-                android.renderscript.Allocation.createFromBitmapResource(
-                rst.mN, res, id, convertMipmapControl(mips), usage);
-        TypeThunker tt = new TypeThunker(rs, a.getType());
-        return new AllocationThunker(rs, tt, usage, a);
+        try {
+            android.renderscript.Allocation a =
+                    android.renderscript.Allocation.createFromBitmapResource(
+                    rst.mN, res, id, convertMipmapControl(mips), usage);
+            TypeThunker tt = new TypeThunker(rs, a.getType());
+            return new AllocationThunker(rs, tt, usage, a);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     static public Allocation createFromString(RenderScript rs,
                                               String str,
                                               int usage) {
         RenderScriptThunker rst = (RenderScriptThunker)rs;
-        android.renderscript.Allocation a =
-                android.renderscript.Allocation.createFromString(
-                rst.mN, str, usage);
-        TypeThunker tt = new TypeThunker(rs, a.getType());
-        return new AllocationThunker(rs, tt, usage, a);
+        try {
+            android.renderscript.Allocation a =
+                    android.renderscript.Allocation.createFromString(
+                    rst.mN, str, usage);
+            TypeThunker tt = new TypeThunker(rs, a.getType());
+            return new AllocationThunker(rs, tt, usage, a);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     static public Allocation createSized(RenderScript rs, Element e,
                                          int count, int usage) {
         RenderScriptThunker rst = (RenderScriptThunker)rs;
         ElementThunker et = (ElementThunker) e;
-        android.renderscript.Allocation a =
-            android.renderscript.Allocation.createSized(rst.mN, (android.renderscript.Element)e.getNObj(), count, usage);
-        TypeThunker tt = new TypeThunker(rs, a.getType());
-        return new AllocationThunker(rs, tt, usage, a);
+        try {
+            android.renderscript.Allocation a =
+                android.renderscript.Allocation.createSized
+                (rst.mN, (android.renderscript.Element)e.getNObj(), count, usage);
+            TypeThunker tt = new TypeThunker(rs, a.getType());
+            return new AllocationThunker(rs, tt, usage, a);
+        } catch (android.renderscript.RSRuntimeException exc) {
+            throw ExceptionThunker.convertException(exc);
+        }
     }
 
 }
\ No newline at end of file
diff --git a/v8/renderscript/java/src/android/support/v8/renderscript/ElementThunker.java b/v8/renderscript/java/src/android/support/v8/renderscript/ElementThunker.java
index 4ac16f6..9b820e2 100644
--- a/v8/renderscript/java/src/android/support/v8/renderscript/ElementThunker.java
+++ b/v8/renderscript/java/src/android/support/v8/renderscript/ElementThunker.java
@@ -28,11 +28,19 @@
     }
 
     public int getBytesSize() {
-        return mN.getBytesSize();
+        try {
+            return mN.getBytesSize();
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public int getVectorSize() {
-        return mN.getVectorSize();
+        try {
+            return mN.getVectorSize();
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     static android.renderscript.Element.DataKind convertKind(DataKind cdk) {
@@ -104,27 +112,51 @@
     }
 
     public boolean isComplex() {
-        return mN.isComplex();
+        try {
+            return mN.isComplex();
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public int getSubElementCount() {
-        return mN.getSubElementCount();
+        try {
+            return mN.getSubElementCount();
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public Element getSubElement(int index) {
-        return new ElementThunker(mRS, mN.getSubElement(index));
+        try {
+            return new ElementThunker(mRS, mN.getSubElement(index));
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public String getSubElementName(int index) {
-        return mN.getSubElementName(index);
+        try {
+            return mN.getSubElementName(index);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public int getSubElementArraySize(int index) {
-        return mN.getSubElementArraySize(index);
+        try {
+            return mN.getSubElementArraySize(index);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public int getSubElementOffsetBytes(int index) {
-        return mN.getSubElementOffsetBytes(index);
+        try {
+            return mN.getSubElementOffsetBytes(index);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public DataType getDataType() {
@@ -144,90 +176,106 @@
 
     static Element create(RenderScript rs, DataType dt) {
         RenderScriptThunker rst = (RenderScriptThunker)rs;
-        android.renderscript.Element e = null;
-        switch(dt) {
-        case FLOAT_32:
-            e = android.renderscript.Element.F32(rst.mN);
-            break;
-        case FLOAT_64:
-            e = android.renderscript.Element.F64(rst.mN);
-            break;
-        case SIGNED_8:
-            e = android.renderscript.Element.I8(rst.mN);
-            break;
-        case SIGNED_16:
-            e = android.renderscript.Element.I16(rst.mN);
-            break;
-        case SIGNED_32:
-            e = android.renderscript.Element.I32(rst.mN);
-            break;
-        case SIGNED_64:
-            e = android.renderscript.Element.I64(rst.mN);
-            break;
-        case UNSIGNED_8:
-            e = android.renderscript.Element.U8(rst.mN);
-            break;
-        case UNSIGNED_16:
-            e = android.renderscript.Element.U16(rst.mN);
-            break;
-        case UNSIGNED_32:
-            e = android.renderscript.Element.U32(rst.mN);
-            break;
-        case UNSIGNED_64:
-            e = android.renderscript.Element.U64(rst.mN);
-            break;
-
-        case BOOLEAN:
-            e = android.renderscript.Element.BOOLEAN(rst.mN);
-            break;
-
-        case MATRIX_4X4:
-            e = android.renderscript.Element.MATRIX_4X4(rst.mN);
+        try {
+            android.renderscript.Element e = null;
+            switch(dt) {
+            case FLOAT_32:
+                e = android.renderscript.Element.F32(rst.mN);
                 break;
-        case MATRIX_3X3:
-            e = android.renderscript.Element.MATRIX_3X3(rst.mN);
-            break;
-        case MATRIX_2X2:
-            e = android.renderscript.Element.MATRIX_2X2(rst.mN);
-            break;
+            case FLOAT_64:
+                e = android.renderscript.Element.F64(rst.mN);
+                break;
+            case SIGNED_8:
+                e = android.renderscript.Element.I8(rst.mN);
+                break;
+            case SIGNED_16:
+                e = android.renderscript.Element.I16(rst.mN);
+                break;
+            case SIGNED_32:
+                e = android.renderscript.Element.I32(rst.mN);
+                break;
+            case SIGNED_64:
+                e = android.renderscript.Element.I64(rst.mN);
+                break;
+            case UNSIGNED_8:
+                e = android.renderscript.Element.U8(rst.mN);
+                break;
+            case UNSIGNED_16:
+                e = android.renderscript.Element.U16(rst.mN);
+                break;
+            case UNSIGNED_32:
+                e = android.renderscript.Element.U32(rst.mN);
+                break;
+            case UNSIGNED_64:
+                e = android.renderscript.Element.U64(rst.mN);
+                break;
 
-        case RS_ELEMENT:
-            e = android.renderscript.Element.ELEMENT(rst.mN);
-            break;
-        case RS_TYPE:
-            e = android.renderscript.Element.TYPE(rst.mN);
-            break;
-        case RS_ALLOCATION:
-            e = android.renderscript.Element.ALLOCATION(rst.mN);
-            break;
-        case RS_SAMPLER:
-            e = android.renderscript.Element.SAMPLER(rst.mN);
-            break;
-        case RS_SCRIPT:
-            e = android.renderscript.Element.SCRIPT(rst.mN);
-            break;
+            case BOOLEAN:
+                e = android.renderscript.Element.BOOLEAN(rst.mN);
+                break;
+
+            case MATRIX_4X4:
+                e = android.renderscript.Element.MATRIX_4X4(rst.mN);
+                break;
+            case MATRIX_3X3:
+                e = android.renderscript.Element.MATRIX_3X3(rst.mN);
+                break;
+            case MATRIX_2X2:
+                e = android.renderscript.Element.MATRIX_2X2(rst.mN);
+                break;
+
+            case RS_ELEMENT:
+                e = android.renderscript.Element.ELEMENT(rst.mN);
+                break;
+            case RS_TYPE:
+                e = android.renderscript.Element.TYPE(rst.mN);
+                break;
+            case RS_ALLOCATION:
+                e = android.renderscript.Element.ALLOCATION(rst.mN);
+                break;
+            case RS_SAMPLER:
+                e = android.renderscript.Element.SAMPLER(rst.mN);
+                break;
+            case RS_SCRIPT:
+                e = android.renderscript.Element.SCRIPT(rst.mN);
+                break;
+            }
+
+            return new ElementThunker(rs, e);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
         }
-
-        return new ElementThunker(rs, e);
     }
 
     public static Element createVector(RenderScript rs, DataType dt, int size) {
         RenderScriptThunker rst = (RenderScriptThunker)rs;
         android.renderscript.Element e;
-        e = android.renderscript.Element.createVector(rst.mN, convertType(dt), size);
-        return new ElementThunker(rs, e);
+        try {
+            e = android.renderscript.Element.createVector(rst.mN, convertType(dt), size);
+            return new ElementThunker(rs, e);
+        } catch (android.renderscript.RSRuntimeException exc) {
+            throw ExceptionThunker.convertException(exc);
+        }
     }
 
     public static Element createPixel(RenderScript rs, DataType dt, DataKind dk) {
         RenderScriptThunker rst = (RenderScriptThunker)rs;
         android.renderscript.Element e;
-        e = android.renderscript.Element.createPixel(rst.mN, convertType(dt), convertKind(dk));
+        try {
+            e = android.renderscript.Element.createPixel(rst.mN, convertType(dt), convertKind(dk));
         return new ElementThunker(rs, e);
+        } catch (android.renderscript.RSRuntimeException exc) {
+            throw ExceptionThunker.convertException(exc);
+        }
     }
 
     public boolean isCompatible(Element e) {
         ElementThunker et = (ElementThunker)e;
-        return et.mN.isCompatible(mN);
+        try {
+            return et.mN.isCompatible(mN);
+        } catch (android.renderscript.RSRuntimeException exc) {
+            throw ExceptionThunker.convertException(exc);
+        }
     }
 
     static class BuilderThunker {
@@ -235,18 +283,31 @@
 
         public BuilderThunker(RenderScript rs) {
             RenderScriptThunker rst = (RenderScriptThunker)rs;
-            mN = new android.renderscript.Element.Builder(rst.mN);
+            try {
+                mN = new android.renderscript.Element.Builder(rst.mN);
+            } catch (android.renderscript.RSRuntimeException e) {
+                throw ExceptionThunker.convertException(e);
+            }
         }
 
         public void add(Element e, String name, int arraySize) {
             ElementThunker et = (ElementThunker)e;
-            mN.add(et.mN, name, arraySize);
+            try {
+                mN.add(et.mN, name, arraySize);
+            } catch (android.renderscript.RSRuntimeException exc) {
+                throw ExceptionThunker.convertException(exc);
+            }
         }
 
         public Element create(RenderScript rs) {
-            android.renderscript.Element e = mN.create();
-            return new ElementThunker(rs, e);
+            try {
+                android.renderscript.Element e = mN.create();
+                return new ElementThunker(rs, e);
+            } catch (android.renderscript.RSRuntimeException exc) {
+                throw ExceptionThunker.convertException(exc);
+            }
         }
     }
 }
 
+
diff --git a/v8/renderscript/java/src/android/support/v8/renderscript/ExceptionThunker.java b/v8/renderscript/java/src/android/support/v8/renderscript/ExceptionThunker.java
new file mode 100644
index 0000000..3e553b7
--- /dev/null
+++ b/v8/renderscript/java/src/android/support/v8/renderscript/ExceptionThunker.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2013 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.
+ */
+
+package android.support.v8.renderscript;
+
+import java.lang.Exception;
+
+class ExceptionThunker {
+    static RuntimeException convertException (RuntimeException e) {
+        if (e instanceof android.renderscript.RSIllegalArgumentException) {
+            return new android.support.v8.renderscript.RSIllegalArgumentException(e.getMessage());
+        } else if (e instanceof android.renderscript.RSInvalidStateException) {
+            return new android.support.v8.renderscript.RSInvalidStateException(e.getMessage());
+        } else if (e instanceof android.renderscript.RSDriverException) {
+            return new android.support.v8.renderscript.RSDriverException(e.getMessage());
+        } else if (e instanceof android.renderscript.RSRuntimeException) {
+            return new android.support.v8.renderscript.RSRuntimeException(e.getMessage());
+        }
+        return e;
+    }
+
+}
\ No newline at end of file
diff --git a/v8/renderscript/java/src/android/support/v8/renderscript/RenderScriptThunker.java b/v8/renderscript/java/src/android/support/v8/renderscript/RenderScriptThunker.java
index 5ba76df..daf0b26 100644
--- a/v8/renderscript/java/src/android/support/v8/renderscript/RenderScriptThunker.java
+++ b/v8/renderscript/java/src/android/support/v8/renderscript/RenderScriptThunker.java
@@ -36,8 +36,12 @@
     }
 
     public void setPriority(Priority p) {
-        if (p == Priority.LOW) mN.setPriority(android.renderscript.RenderScript.Priority.LOW);
-        if (p == Priority.NORMAL) mN.setPriority(android.renderscript.RenderScript.Priority.NORMAL);
+        try {
+            if (p == Priority.LOW) mN.setPriority(android.renderscript.RenderScript.Priority.LOW);
+            if (p == Priority.NORMAL) mN.setPriority(android.renderscript.RenderScript.Priority.NORMAL);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     RenderScriptThunker(Context ctx) {
@@ -46,21 +50,39 @@
     }
 
     public static RenderScript create(Context ctx, int sdkVersion) {
-        RenderScriptThunker rs = new RenderScriptThunker(ctx);
-        rs.mN = android.renderscript.RenderScript.create(ctx, sdkVersion);
-        return rs;
+        try {
+            RenderScriptThunker rs = new RenderScriptThunker(ctx);
+            rs.mN = android.renderscript.RenderScript.create(ctx, sdkVersion);
+            return rs;
+        }
+        catch(android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public void contextDump() {
-        mN.contextDump();
+        try {
+            mN.contextDump();
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public void finish() {
-        mN.finish();
+        try {
+            mN.finish();
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public void destroy() {
-        mN.destroy();
-        mN = null;
+        try {
+            mN.destroy();
+            mN = null;
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
+
     }
 }
diff --git a/v8/renderscript/java/src/android/support/v8/renderscript/SamplerThunker.java b/v8/renderscript/java/src/android/support/v8/renderscript/SamplerThunker.java
index 56d9487..eb14c7f 100644
--- a/v8/renderscript/java/src/android/support/v8/renderscript/SamplerThunker.java
+++ b/v8/renderscript/java/src/android/support/v8/renderscript/SamplerThunker.java
@@ -129,24 +129,28 @@
 
         public Sampler create() {
             mRS.validate();
-            android.renderscript.Sampler.Builder b = new android.renderscript.Sampler.Builder(mRS.mN);
-            b.setMinification(convertValue(mMin));
-            b.setMagnification(convertValue(mMag));
-            b.setWrapS(convertValue(mWrapS));
-            b.setWrapT(convertValue(mWrapT));
-            b.setAnisotropy(mAniso);
-            android.renderscript.Sampler s = b.create();
+            try {
+                android.renderscript.Sampler.Builder b = new android.renderscript.Sampler.Builder(mRS.mN);
+                b.setMinification(convertValue(mMin));
+                b.setMagnification(convertValue(mMag));
+                b.setWrapS(convertValue(mWrapS));
+                b.setWrapT(convertValue(mWrapT));
+                b.setAnisotropy(mAniso);
+                android.renderscript.Sampler s = b.create();
 
-            SamplerThunker sampler = new SamplerThunker(0, mRS);
-            sampler.mMin = mMin;
-            sampler.mMag = mMag;
-            sampler.mWrapS = mWrapS;
-            sampler.mWrapT = mWrapT;
-            sampler.mWrapR = mWrapR;
-            sampler.mAniso = mAniso;
-            sampler.mN = s;
+                SamplerThunker sampler = new SamplerThunker(0, mRS);
+                sampler.mMin = mMin;
+                sampler.mMag = mMag;
+                sampler.mWrapS = mWrapS;
+                sampler.mWrapT = mWrapT;
+                sampler.mWrapR = mWrapR;
+                sampler.mAniso = mAniso;
+                sampler.mN = s;
 
-            return sampler;
+                return sampler;
+            } catch (android.renderscript.RSRuntimeException e) {
+                throw ExceptionThunker.convertException(e);
+            }
         }
     }
 
diff --git a/v8/renderscript/java/src/android/support/v8/renderscript/ScriptCThunker.java b/v8/renderscript/java/src/android/support/v8/renderscript/ScriptCThunker.java
index ba6a075..2dd9ae9 100644
--- a/v8/renderscript/java/src/android/support/v8/renderscript/ScriptCThunker.java
+++ b/v8/renderscript/java/src/android/support/v8/renderscript/ScriptCThunker.java
@@ -50,12 +50,21 @@
         if (eout != null) {
             neout = ((ElementThunker)eout).mN;
         }
-        return createKernelID(slot, sig, nein, neout);
+        try {
+            android.renderscript.Script.KernelID kid = createKernelID(slot, sig, nein, neout);
+            return kid;
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
 
     void thunkInvoke(int slot) {
-        invoke(slot);
+        try {
+            invoke(slot);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     void thunkBindAllocation(Allocation va, int slot) {
@@ -63,17 +72,29 @@
         if (va != null) {
             nva = ((AllocationThunker)va).mN;
         }
-        bindAllocation(nva, slot);
+        try {
+            bindAllocation(nva, slot);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     void thunkSetTimeZone(String timeZone) {
-        setTimeZone(timeZone);
+        try {
+            setTimeZone(timeZone);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     void thunkInvoke(int slot, FieldPacker v) {
-        android.renderscript.FieldPacker nfp =
+        try {
+            android.renderscript.FieldPacker nfp =
                 new android.renderscript.FieldPacker(v.getData());
-        invoke(slot, nfp);
+            invoke(slot, nfp);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     void thunkForEach(int slot, Allocation ain, Allocation aout, FieldPacker v) {
@@ -86,76 +107,124 @@
         if (aout != null) {
             nout = ((AllocationThunker)aout).mN;
         }
-        if (v != null) {
-            nfp = new android.renderscript.FieldPacker(v.getData());
+        try {
+            if (v != null) {
+                nfp = new android.renderscript.FieldPacker(v.getData());
+            }
+            forEach(slot, nin, nout, nfp);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
         }
-        forEach(slot, nin, nout, nfp);
     }
 
     void thunkForEach(int slot, Allocation ain, Allocation aout, FieldPacker v,
                       android.support.v8.renderscript.Script.LaunchOptions sc) {
-        android.renderscript.Script.LaunchOptions lo = null;
-        if (sc != null) {
-            lo = new android.renderscript.Script.LaunchOptions();
-            if (sc.getXEnd() > 0) lo.setX(sc.getXStart(), sc.getXEnd());
-            if (sc.getYEnd() > 0) lo.setY(sc.getYStart(), sc.getYEnd());
-            if (sc.getZEnd() > 0) lo.setZ(sc.getZStart(), sc.getZEnd());
-        }
+        try {
+            android.renderscript.Script.LaunchOptions lo = null;
+            if (sc != null) {
+                lo = new android.renderscript.Script.LaunchOptions();
+                if (sc.getXEnd() > 0) lo.setX(sc.getXStart(), sc.getXEnd());
+                if (sc.getYEnd() > 0) lo.setY(sc.getYStart(), sc.getYEnd());
+                if (sc.getZEnd() > 0) lo.setZ(sc.getZStart(), sc.getZEnd());
+            }
 
-        android.renderscript.Allocation nin = null;
-        android.renderscript.Allocation nout = null;
-        android.renderscript.FieldPacker nfp = null;
-        if (ain != null) {
-            nin = ((AllocationThunker)ain).mN;
+            android.renderscript.Allocation nin = null;
+            android.renderscript.Allocation nout = null;
+            android.renderscript.FieldPacker nfp = null;
+            if (ain != null) {
+                nin = ((AllocationThunker)ain).mN;
+            }
+            if (aout != null) {
+                nout = ((AllocationThunker)aout).mN;
+            }
+            if (v != null) {
+                nfp = new android.renderscript.FieldPacker(v.getData());
+            }
+            forEach(slot, nin, nout, nfp, lo);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
         }
-        if (aout != null) {
-            nout = ((AllocationThunker)aout).mN;
-        }
-        if (v != null) {
-            nfp = new android.renderscript.FieldPacker(v.getData());
-        }
-        forEach(slot, nin, nout, nfp, lo);
     }
 
     void thunkSetVar(int index, float v) {
-        setVar(index, v);
+        try {
+            setVar(index, v);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
     void thunkSetVar(int index, double v) {
-        setVar(index, v);
+        try {
+            setVar(index, v);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
     void thunkSetVar(int index, int v) {
-        setVar(index, v);
+        try {
+            setVar(index, v);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
     void thunkSetVar(int index, long v) {
-        setVar(index, v);
+        try {
+            setVar(index, v);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
     void thunkSetVar(int index, boolean v) {
-        setVar(index, v);
+        try {
+            setVar(index, v);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     void thunkSetVar(int index, BaseObj o) {
         if (o == null) {
-            setVar(index, 0);
+            try {
+                setVar(index, 0);
+            } catch (android.renderscript.RSRuntimeException e) {
+                throw ExceptionThunker.convertException(e);
+            }
             return;
         }
-        setVar(index, o.getNObj());
+        try {
+            setVar(index, o.getNObj());
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
     void thunkSetVar(int index, FieldPacker v) {
-        android.renderscript.FieldPacker nfp =
+        try {
+            android.renderscript.FieldPacker nfp =
                 new android.renderscript.FieldPacker(v.getData());
-        setVar(index, nfp);
+            setVar(index, nfp);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     void thunkSetVar(int index, FieldPacker v, Element e, int[] dims) {
-        android.renderscript.FieldPacker nfp =
+        try {
+            android.renderscript.FieldPacker nfp =
                 new android.renderscript.FieldPacker(v.getData());
-        ElementThunker et = (ElementThunker)e;
-        setVar(index, nfp, et.mN, dims);
+            ElementThunker et = (ElementThunker)e;
+            setVar(index, nfp, et.mN, dims);
+        } catch (android.renderscript.RSRuntimeException exc) {
+            throw ExceptionThunker.convertException(exc);
+        }
     }
 
     android.renderscript.Script.FieldID thunkCreateFieldID(int slot, Element e) {
-        ElementThunker et = (ElementThunker) e;
-        return createFieldID(slot, et.getNObj());
+        try {
+            ElementThunker et = (ElementThunker) e;
+            return createFieldID(slot, et.getNObj());
+        } catch (android.renderscript.RSRuntimeException exc) {
+            throw ExceptionThunker.convertException(exc);
+        }
     }
 
 }
diff --git a/v8/renderscript/java/src/android/support/v8/renderscript/ScriptGroupThunker.java b/v8/renderscript/java/src/android/support/v8/renderscript/ScriptGroupThunker.java
index f6e8bc4..588d674 100644
--- a/v8/renderscript/java/src/android/support/v8/renderscript/ScriptGroupThunker.java
+++ b/v8/renderscript/java/src/android/support/v8/renderscript/ScriptGroupThunker.java
@@ -32,16 +32,28 @@
 
     public void setInput(Script.KernelID s, Allocation a) {
         AllocationThunker at = (AllocationThunker) a;
-        mN.setInput(s.mN, at.getNObj());
+        try {
+            mN.setInput(s.mN, at.getNObj());
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public void setOutput(Script.KernelID s, Allocation a) {
         AllocationThunker at = (AllocationThunker) a;
-        mN.setOutput(s.mN, at.getNObj());
+        try {
+            mN.setOutput(s.mN, at.getNObj());
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public void execute() {
-        mN.execute();
+        try {
+            mN.execute();
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
 
@@ -53,23 +65,39 @@
         Builder(RenderScript rs) {
             RenderScriptThunker rst = (RenderScriptThunker) rs;
             mRS = rs;
-            bN = new android.renderscript.ScriptGroup.Builder(rst.mN);
+            try {
+                bN = new android.renderscript.ScriptGroup.Builder(rst.mN);
+            } catch (android.renderscript.RSRuntimeException e) {
+                throw ExceptionThunker.convertException(e);
+            }
         }
 
         public Builder addKernel(Script.KernelID k) {
-            bN.addKernel(k.mN);
+            try {
+                bN.addKernel(k.mN);
+            } catch (android.renderscript.RSRuntimeException e) {
+                throw ExceptionThunker.convertException(e);
+            }
             return this;
         }
 
         public Builder addConnection(Type t, Script.KernelID from, Script.FieldID to) {
             TypeThunker tt = (TypeThunker) t;
-            bN.addConnection(tt.getNObj(), from.mN, to.mN);
+            try {
+                bN.addConnection(tt.getNObj(), from.mN, to.mN);
+            } catch (android.renderscript.RSRuntimeException e) {
+                throw ExceptionThunker.convertException(e);
+            }
             return this;
         }
 
         public Builder addConnection(Type t, Script.KernelID from, Script.KernelID to) {
             TypeThunker tt = (TypeThunker) t;
-            bN.addConnection(tt.getNObj(), from.mN, to.mN);
+            try {
+                bN.addConnection(tt.getNObj(), from.mN, to.mN);
+            } catch (android.renderscript.RSRuntimeException e) {
+                throw ExceptionThunker.convertException(e);
+            }
             return this;
         }
 
@@ -77,7 +105,11 @@
 
         public ScriptGroupThunker create() {
             ScriptGroupThunker sg = new ScriptGroupThunker(0, mRS);
-            sg.mN = bN.create();
+            try {
+                sg.mN = bN.create();
+            } catch (android.renderscript.RSRuntimeException e) {
+                throw ExceptionThunker.convertException(e);
+            }
             return sg;
         }
     }
diff --git a/v8/renderscript/java/src/android/support/v8/renderscript/ScriptIntrinsic3DLUTThunker.java b/v8/renderscript/java/src/android/support/v8/renderscript/ScriptIntrinsic3DLUTThunker.java
index ce11a4d..a1c6ada 100644
--- a/v8/renderscript/java/src/android/support/v8/renderscript/ScriptIntrinsic3DLUTThunker.java
+++ b/v8/renderscript/java/src/android/support/v8/renderscript/ScriptIntrinsic3DLUTThunker.java
@@ -38,13 +38,21 @@
         ElementThunker et = (ElementThunker) e;
 
         ScriptIntrinsic3DLUTThunker lut = new ScriptIntrinsic3DLUTThunker(0, rs, e);
-        lut.mN = android.renderscript.ScriptIntrinsic3DLUT.create(rst.mN, et.getNObj());
+        try {
+            lut.mN = android.renderscript.ScriptIntrinsic3DLUT.create(rst.mN, et.getNObj());
+        } catch (android.renderscript.RSRuntimeException exc) {
+            throw ExceptionThunker.convertException(exc);
+        }
         return lut;
     }
 
     public void setLUT(Allocation lut) {
         AllocationThunker lutt = (AllocationThunker) lut;
-        mN.setLUT(lutt.getNObj());
+        try {
+            mN.setLUT(lutt.getNObj());
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
 
@@ -58,7 +66,11 @@
     public void forEach(Allocation ain, Allocation aout) {
         AllocationThunker aint = (AllocationThunker)ain;
         AllocationThunker aoutt = (AllocationThunker)aout;
-        mN.forEach(aint.getNObj(), aoutt.getNObj());
+        try {
+            mN.forEach(aint.getNObj(), aoutt.getNObj());
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     /**
@@ -68,7 +80,11 @@
      */
     public Script.KernelID getKernelID() {
         Script.KernelID k = createKernelID(0, 3, null, null);
-        k.mN = mN.getKernelID();
+        try {
+            k.mN = mN.getKernelID();
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
         return k;
     }
 }
diff --git a/v8/renderscript/java/src/android/support/v8/renderscript/ScriptIntrinsicBlendThunker.java b/v8/renderscript/java/src/android/support/v8/renderscript/ScriptIntrinsicBlendThunker.java
index 2836034..7c70934 100644
--- a/v8/renderscript/java/src/android/support/v8/renderscript/ScriptIntrinsicBlendThunker.java
+++ b/v8/renderscript/java/src/android/support/v8/renderscript/ScriptIntrinsicBlendThunker.java
@@ -32,7 +32,11 @@
         ElementThunker et = (ElementThunker)e;
 
         ScriptIntrinsicBlendThunker blend = new ScriptIntrinsicBlendThunker(0, rs);
-        blend.mN = android.renderscript.ScriptIntrinsicBlend.create(rst.mN, et.getNObj());
+        try {
+            blend.mN = android.renderscript.ScriptIntrinsicBlend.create(rst.mN, et.getNObj());
+        } catch (android.renderscript.RSRuntimeException exc) {
+            throw ExceptionThunker.convertException(exc);
+        }
         return blend;
     }
 
@@ -40,12 +44,20 @@
         AllocationThunker aint = (AllocationThunker)ain;
         AllocationThunker aoutt = (AllocationThunker)aout;
 
-        mN.forEachClear(aint.getNObj(), aoutt.getNObj());
+        try {
+            mN.forEachClear(aint.getNObj(), aoutt.getNObj());
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public Script.KernelID getKernelIDClear() {
         Script.KernelID k = createKernelID(0, 3, null, null);
-        k.mN = mN.getKernelIDClear();
+        try {
+            k.mN = mN.getKernelIDClear();
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
         return k;
     }
 
@@ -53,12 +65,20 @@
         AllocationThunker aint = (AllocationThunker)ain;
         AllocationThunker aoutt = (AllocationThunker)aout;
 
-        mN.forEachSrc(aint.getNObj(), aoutt.getNObj());
+        try {
+            mN.forEachSrc(aint.getNObj(), aoutt.getNObj());
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public Script.KernelID getKernelIDSrc() {
         Script.KernelID k = createKernelID(1, 3, null, null);
-        k.mN = mN.getKernelIDSrc();
+        try {
+            k.mN = mN.getKernelIDSrc();
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
         return k;
     }
 
@@ -66,12 +86,20 @@
         AllocationThunker aint = (AllocationThunker)ain;
         AllocationThunker aoutt = (AllocationThunker)aout;
 
-        mN.forEachDst(aint.getNObj(), aoutt.getNObj());
+        try {
+            mN.forEachDst(aint.getNObj(), aoutt.getNObj());
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public Script.KernelID getKernelIDDst() {
         Script.KernelID k = createKernelID(2, 3, null, null);
-        k.mN = mN.getKernelIDDst();
+        try {
+            k.mN = mN.getKernelIDDst();
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
         return k;
     }
 
@@ -79,12 +107,20 @@
         AllocationThunker aint = (AllocationThunker)ain;
         AllocationThunker aoutt = (AllocationThunker)aout;
 
-        mN.forEachSrcOver(aint.getNObj(), aoutt.getNObj());
+        try {
+            mN.forEachSrcOver(aint.getNObj(), aoutt.getNObj());
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public Script.KernelID getKernelIDSrcOver() {
         Script.KernelID k = createKernelID(3, 3, null, null);
-        k.mN = mN.getKernelIDSrcOver();
+        try {
+            k.mN = mN.getKernelIDSrcOver();
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
         return k;
     }
 
@@ -92,12 +128,20 @@
         AllocationThunker aint = (AllocationThunker)ain;
         AllocationThunker aoutt = (AllocationThunker)aout;
 
-        mN.forEachDstOver(aint.getNObj(), aoutt.getNObj());
+        try {
+            mN.forEachDstOver(aint.getNObj(), aoutt.getNObj());
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public Script.KernelID getKernelIDDstOver() {
         Script.KernelID k = createKernelID(4, 3, null, null);
-        k.mN = mN.getKernelIDDstOver();
+        try {
+            k.mN = mN.getKernelIDDstOver();
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
         return k;
     }
 
@@ -105,12 +149,20 @@
         AllocationThunker aint = (AllocationThunker)ain;
         AllocationThunker aoutt = (AllocationThunker)aout;
 
-        mN.forEachSrcIn(aint.getNObj(), aoutt.getNObj());
+        try {
+            mN.forEachSrcIn(aint.getNObj(), aoutt.getNObj());
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public Script.KernelID getKernelIDSrcIn() {
         Script.KernelID k = createKernelID(5, 3, null, null);
-        k.mN = mN.getKernelIDSrcIn();
+        try {
+            k.mN = mN.getKernelIDSrcIn();
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
         return k;
     }
 
@@ -118,12 +170,20 @@
         AllocationThunker aint = (AllocationThunker)ain;
         AllocationThunker aoutt = (AllocationThunker)aout;
 
-        mN.forEachDstIn(aint.getNObj(), aoutt.getNObj());
+        try {
+            mN.forEachDstIn(aint.getNObj(), aoutt.getNObj());
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public Script.KernelID getKernelIDDstIn() {
         Script.KernelID k = createKernelID(6, 3, null, null);
-        k.mN = mN.getKernelIDDstIn();
+        try {
+            k.mN = mN.getKernelIDDstIn();
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
         return k;
     }
 
@@ -131,12 +191,20 @@
         AllocationThunker aint = (AllocationThunker)ain;
         AllocationThunker aoutt = (AllocationThunker)aout;
 
-        mN.forEachSrcOut(aint.getNObj(), aoutt.getNObj());
+        try {
+            mN.forEachSrcOut(aint.getNObj(), aoutt.getNObj());
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public Script.KernelID getKernelIDSrcOut() {
         Script.KernelID k = createKernelID(7, 3, null, null);
-        k.mN = mN.getKernelIDSrcOut();
+        try {
+            k.mN = mN.getKernelIDSrcOut();
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
         return k;
     }
 
@@ -144,12 +212,20 @@
         AllocationThunker aint = (AllocationThunker)ain;
         AllocationThunker aoutt = (AllocationThunker)aout;
 
-        mN.forEachDstOut(aint.getNObj(), aoutt.getNObj());
+        try {
+            mN.forEachDstOut(aint.getNObj(), aoutt.getNObj());
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public Script.KernelID getKernelIDDstOut() {
         Script.KernelID k = createKernelID(8, 3, null, null);
-        k.mN = mN.getKernelIDDstOut();
+        try {
+            k.mN = mN.getKernelIDDstOut();
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
         return k;
     }
 
@@ -157,12 +233,20 @@
         AllocationThunker aint = (AllocationThunker)ain;
         AllocationThunker aoutt = (AllocationThunker)aout;
 
-        mN.forEachSrcAtop(aint.getNObj(), aoutt.getNObj());
+        try {
+            mN.forEachSrcAtop(aint.getNObj(), aoutt.getNObj());
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public Script.KernelID getKernelIDSrcAtop() {
         Script.KernelID k = createKernelID(9, 3, null, null);
-        k.mN = mN.getKernelIDSrcAtop();
+        try {
+            k.mN = mN.getKernelIDSrcAtop();
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
         return k;
     }
 
@@ -170,12 +254,20 @@
         AllocationThunker aint = (AllocationThunker)ain;
         AllocationThunker aoutt = (AllocationThunker)aout;
 
-        mN.forEachDstAtop(aint.getNObj(), aoutt.getNObj());
+        try {
+            mN.forEachDstAtop(aint.getNObj(), aoutt.getNObj());
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public Script.KernelID getKernelIDDstAtop() {
         Script.KernelID k = createKernelID(10, 3, null, null);
-        k.mN = mN.getKernelIDDstAtop();
+        try {
+            k.mN = mN.getKernelIDDstAtop();
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
         return k;
     }
 
@@ -183,12 +275,20 @@
         AllocationThunker aint = (AllocationThunker)ain;
         AllocationThunker aoutt = (AllocationThunker)aout;
 
-        mN.forEachXor(aint.getNObj(), aoutt.getNObj());
+        try {
+            mN.forEachXor(aint.getNObj(), aoutt.getNObj());
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public Script.KernelID getKernelIDXor() {
         Script.KernelID k = createKernelID(11, 3, null, null);
-        k.mN = mN.getKernelIDXor();
+        try {
+            k.mN = mN.getKernelIDXor();
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
         return k;
     }
 
@@ -196,12 +296,20 @@
         AllocationThunker aint = (AllocationThunker)ain;
         AllocationThunker aoutt = (AllocationThunker)aout;
 
-        mN.forEachMultiply(aint.getNObj(), aoutt.getNObj());
+        try {
+            mN.forEachMultiply(aint.getNObj(), aoutt.getNObj());
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public Script.KernelID getKernelIDMultiply() {
         Script.KernelID k = createKernelID(14, 3, null, null);
-        k.mN = mN.getKernelIDMultiply();
+        try {
+            k.mN = mN.getKernelIDMultiply();
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
         return k;
     }
 
@@ -209,12 +317,20 @@
         AllocationThunker aint = (AllocationThunker)ain;
         AllocationThunker aoutt = (AllocationThunker)aout;
 
-        mN.forEachAdd(aint.getNObj(), aoutt.getNObj());
+        try {
+            mN.forEachAdd(aint.getNObj(), aoutt.getNObj());
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public Script.KernelID getKernelIDAdd() {
         Script.KernelID k = createKernelID(34, 3, null, null);
-        k.mN = mN.getKernelIDAdd();
+        try {
+            k.mN = mN.getKernelIDAdd();
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
         return k;
     }
 
@@ -222,12 +338,20 @@
         AllocationThunker aint = (AllocationThunker)ain;
         AllocationThunker aoutt = (AllocationThunker)aout;
 
-        mN.forEachSubtract(aint.getNObj(), aoutt.getNObj());
+        try {
+            mN.forEachSubtract(aint.getNObj(), aoutt.getNObj());
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public Script.KernelID getKernelIDSubtract() {
         Script.KernelID k = createKernelID(35, 3, null, null);
-        k.mN = mN.getKernelIDSubtract();
+        try {
+            k.mN = mN.getKernelIDSubtract();
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
         return k;
     }
 
diff --git a/v8/renderscript/java/src/android/support/v8/renderscript/ScriptIntrinsicBlurThunker.java b/v8/renderscript/java/src/android/support/v8/renderscript/ScriptIntrinsicBlurThunker.java
index 9be99cb..31e22bb 100644
--- a/v8/renderscript/java/src/android/support/v8/renderscript/ScriptIntrinsicBlurThunker.java
+++ b/v8/renderscript/java/src/android/support/v8/renderscript/ScriptIntrinsicBlurThunker.java
@@ -37,35 +37,59 @@
         ElementThunker et = (ElementThunker) e;
 
         ScriptIntrinsicBlurThunker blur = new ScriptIntrinsicBlurThunker(0, rs);
-        blur.mN = android.renderscript.ScriptIntrinsicBlur.create(rst.mN, et.getNObj());
+        try {
+            blur.mN = android.renderscript.ScriptIntrinsicBlur.create(rst.mN, et.getNObj());
+        } catch (android.renderscript.RSRuntimeException exc) {
+            throw ExceptionThunker.convertException(exc);
+        }
         return blur;
     }
 
     public void setInput(Allocation ain) {
         AllocationThunker aint = (AllocationThunker) ain;
-        mN.setInput(aint.getNObj());
+        try {
+            mN.setInput(aint.getNObj());
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public void setRadius(float radius) {
-        mN.setRadius(radius);
+        try {
+            mN.setRadius(radius);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public void forEach(Allocation aout) {
         AllocationThunker aoutt = (AllocationThunker) aout;
         if (aoutt != null) {
-            mN.forEach(aoutt.getNObj());
+            try {
+                mN.forEach(aoutt.getNObj());
+            } catch (android.renderscript.RSRuntimeException e) {
+                throw ExceptionThunker.convertException(e);
+            }
         }
     }
 
     public Script.KernelID getKernelID() {
         Script.KernelID k = createKernelID(0, 2, null, null);
-        k.mN = mN.getKernelID();
+        try {
+            k.mN = mN.getKernelID();
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
         return k;
     }
 
     public Script.FieldID getFieldID_Input() {
         Script.FieldID f = createFieldID(1, null);
-        f.mN = mN.getFieldID_Input();
+        try {
+            f.mN = mN.getFieldID_Input();
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
         return f;
     }
 }
diff --git a/v8/renderscript/java/src/android/support/v8/renderscript/ScriptIntrinsicColorMatrixThunker.java b/v8/renderscript/java/src/android/support/v8/renderscript/ScriptIntrinsicColorMatrixThunker.java
index 28c2a7b..797c0e7 100644
--- a/v8/renderscript/java/src/android/support/v8/renderscript/ScriptIntrinsicColorMatrixThunker.java
+++ b/v8/renderscript/java/src/android/support/v8/renderscript/ScriptIntrinsicColorMatrixThunker.java
@@ -34,41 +34,73 @@
         ElementThunker et = (ElementThunker)e;
 
         ScriptIntrinsicColorMatrixThunker cm =  new ScriptIntrinsicColorMatrixThunker(0, rs);
-        cm.mN = android.renderscript.ScriptIntrinsicColorMatrix.create(rst.mN, et.getNObj());
+        try {
+            cm.mN = android.renderscript.ScriptIntrinsicColorMatrix.create(rst.mN, et.getNObj());
+        } catch (android.renderscript.RSRuntimeException exc) {
+            throw ExceptionThunker.convertException(exc);
+        }
         return cm;
 
     }
 
     public void setColorMatrix(Matrix4f m) {
-        mN.setColorMatrix(new android.renderscript.Matrix4f(m.getArray()));
+        try {
+            mN.setColorMatrix(new android.renderscript.Matrix4f(m.getArray()));
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public void setColorMatrix(Matrix3f m) {
-        mN.setColorMatrix(new android.renderscript.Matrix3f(m.getArray()));
+        try {
+            mN.setColorMatrix(new android.renderscript.Matrix3f(m.getArray()));
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public void setGreyscale() {
-        mN.setGreyscale();
+        try {
+            mN.setGreyscale();
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public void setYUVtoRGB() {
-        mN.setYUVtoRGB();
+        try {
+            mN.setYUVtoRGB();
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public void setRGBtoYUV() {
-        mN.setRGBtoYUV();
+        try {
+            mN.setRGBtoYUV();
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
 
     public void forEach(Allocation ain, Allocation aout) {
         AllocationThunker aint = (AllocationThunker)ain;
         AllocationThunker aoutt = (AllocationThunker)aout;
-        mN.forEach(aint.getNObj(), aoutt.getNObj());
+        try {
+            mN.forEach(aint.getNObj(), aoutt.getNObj());
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public Script.KernelID getKernelID() {
         Script.KernelID k = createKernelID(0, 3, null, null);
-        k.mN = mN.getKernelID();
+        try {
+            k.mN = mN.getKernelID();
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
         return k;
     }
 
diff --git a/v8/renderscript/java/src/android/support/v8/renderscript/ScriptIntrinsicConvolve3x3Thunker.java b/v8/renderscript/java/src/android/support/v8/renderscript/ScriptIntrinsicConvolve3x3Thunker.java
index 2645fbf..fa997c1 100644
--- a/v8/renderscript/java/src/android/support/v8/renderscript/ScriptIntrinsicConvolve3x3Thunker.java
+++ b/v8/renderscript/java/src/android/support/v8/renderscript/ScriptIntrinsicConvolve3x3Thunker.java
@@ -35,34 +35,58 @@
         ElementThunker et = (ElementThunker) e;
 
         ScriptIntrinsicConvolve3x3Thunker si = new ScriptIntrinsicConvolve3x3Thunker(0, rs);
-        si.mN = android.renderscript.ScriptIntrinsicConvolve3x3.create(rst.mN, et.getNObj());
+        try {
+            si.mN = android.renderscript.ScriptIntrinsicConvolve3x3.create(rst.mN, et.getNObj());
+        } catch (android.renderscript.RSRuntimeException exc) {
+            throw ExceptionThunker.convertException(exc);
+        }
         return si;
     }
 
     public void setInput(Allocation ain) {
         AllocationThunker aint = (AllocationThunker)ain;
-        mN.setInput(aint.getNObj());
+        try {
+            mN.setInput(aint.getNObj());
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public void setCoefficients(float v[]) {
-        mN.setCoefficients(v);
+        try {
+            mN.setCoefficients(v);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public void forEach(Allocation aout) {
         AllocationThunker aoutt = (AllocationThunker)aout;
-        mN.forEach(aoutt.getNObj());
+        try {
+            mN.forEach(aoutt.getNObj());
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
 
     }
 
     public Script.KernelID getKernelID() {
         Script.KernelID k = createKernelID(0, 2, null, null);
-        k.mN = mN.getKernelID();
+        try {
+            k.mN = mN.getKernelID();
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
         return k;
     }
 
     public Script.FieldID getFieldID_Input() {
         Script.FieldID f = createFieldID(1, null);
-        f.mN = mN.getFieldID_Input();
+        try {
+            f.mN = mN.getFieldID_Input();
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
         return f;
     }
 
diff --git a/v8/renderscript/java/src/android/support/v8/renderscript/ScriptIntrinsicConvolve5x5Thunker.java b/v8/renderscript/java/src/android/support/v8/renderscript/ScriptIntrinsicConvolve5x5Thunker.java
index 4430f9e..2071ddd 100644
--- a/v8/renderscript/java/src/android/support/v8/renderscript/ScriptIntrinsicConvolve5x5Thunker.java
+++ b/v8/renderscript/java/src/android/support/v8/renderscript/ScriptIntrinsicConvolve5x5Thunker.java
@@ -35,34 +35,58 @@
         ElementThunker et = (ElementThunker) e;
 
         ScriptIntrinsicConvolve5x5Thunker si = new ScriptIntrinsicConvolve5x5Thunker(0, rs);
-        si.mN = android.renderscript.ScriptIntrinsicConvolve5x5.create(rst.mN, et.getNObj());
+        try {
+            si.mN = android.renderscript.ScriptIntrinsicConvolve5x5.create(rst.mN, et.getNObj());
+        } catch (android.renderscript.RSRuntimeException exc) {
+            throw ExceptionThunker.convertException(exc);
+        }
         return si;
     }
 
     public void setInput(Allocation ain) {
         AllocationThunker aint = (AllocationThunker)ain;
-        mN.setInput(aint.getNObj());
+        try {
+            mN.setInput(aint.getNObj());
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public void setCoefficients(float v[]) {
-        mN.setCoefficients(v);
+        try {
+            mN.setCoefficients(v);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public void forEach(Allocation aout) {
         AllocationThunker aoutt = (AllocationThunker)aout;
-        mN.forEach(aoutt.getNObj());
+        try {
+            mN.forEach(aoutt.getNObj());
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
 
     }
 
     public Script.KernelID getKernelID() {
         Script.KernelID k = createKernelID(0, 2, null, null);
-        k.mN = mN.getKernelID();
+        try {
+            k.mN = mN.getKernelID();
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
         return k;
     }
 
     public Script.FieldID getFieldID_Input() {
         Script.FieldID f = createFieldID(1, null);
-        f.mN = mN.getFieldID_Input();
+        try {
+            f.mN = mN.getFieldID_Input();
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
         return f;
     }
 
diff --git a/v8/renderscript/java/src/android/support/v8/renderscript/ScriptIntrinsicLUTThunker.java b/v8/renderscript/java/src/android/support/v8/renderscript/ScriptIntrinsicLUTThunker.java
index 547b679..ecd17f2 100644
--- a/v8/renderscript/java/src/android/support/v8/renderscript/ScriptIntrinsicLUTThunker.java
+++ b/v8/renderscript/java/src/android/support/v8/renderscript/ScriptIntrinsicLUTThunker.java
@@ -34,35 +34,63 @@
         ElementThunker et = (ElementThunker) e;
 
         ScriptIntrinsicLUTThunker si = new ScriptIntrinsicLUTThunker(0, rs);
-        si.mN = android.renderscript.ScriptIntrinsicLUT.create(rst.mN, et.getNObj());
+        try {
+            si.mN = android.renderscript.ScriptIntrinsicLUT.create(rst.mN, et.getNObj());
+        } catch (android.renderscript.RSRuntimeException exc) {
+            throw ExceptionThunker.convertException(exc);
+        }
         return si;
     }
 
     public void setRed(int index, int value) {
-        mN.setRed(index, value);
+        try {
+            mN.setRed(index, value);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public void setGreen(int index, int value) {
-        mN.setGreen(index, value);
+        try {
+            mN.setGreen(index, value);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public void setBlue(int index, int value) {
-        mN.setBlue(index, value);
+        try {
+            mN.setBlue(index, value);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public void setAlpha(int index, int value) {
-        mN.setAlpha(index, value);
+        try {
+            mN.setAlpha(index, value);
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public void forEach(Allocation ain, Allocation aout) {
         AllocationThunker aint = (AllocationThunker)ain;
         AllocationThunker aoutt = (AllocationThunker)aout;
-        mN.forEach(aint.getNObj(), aoutt.getNObj());
+        try {
+            mN.forEach(aint.getNObj(), aoutt.getNObj());
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public Script.KernelID getKernelID() {
         Script.KernelID k = createKernelID(0, 3, null, null);
-        k.mN = mN.getKernelID();
+        try {
+            k.mN = mN.getKernelID();
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
         return k;
     }
 }
diff --git a/v8/renderscript/java/src/android/support/v8/renderscript/ScriptIntrinsicYuvToRGBThunker.java b/v8/renderscript/java/src/android/support/v8/renderscript/ScriptIntrinsicYuvToRGBThunker.java
index be97392..dd75591c 100644
--- a/v8/renderscript/java/src/android/support/v8/renderscript/ScriptIntrinsicYuvToRGBThunker.java
+++ b/v8/renderscript/java/src/android/support/v8/renderscript/ScriptIntrinsicYuvToRGBThunker.java
@@ -34,30 +34,50 @@
         ElementThunker et = (ElementThunker) e;
 
         ScriptIntrinsicYuvToRGBThunker si = new ScriptIntrinsicYuvToRGBThunker(0, rs);
-        si.mN = android.renderscript.ScriptIntrinsicYuvToRGB.create(rst.mN, et.getNObj());
+        try {
+            si.mN = android.renderscript.ScriptIntrinsicYuvToRGB.create(rst.mN, et.getNObj());
+        } catch (android.renderscript.RSRuntimeException exc) {
+            throw ExceptionThunker.convertException(exc);
+        }
         return si;
     }
 
 
     public void setInput(Allocation ain) {
         AllocationThunker aint = (AllocationThunker)ain;
-        mN.setInput(aint.getNObj());
+        try {
+            mN.setInput(aint.getNObj());
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public void forEach(Allocation aout) {
         AllocationThunker aoutt = (AllocationThunker)aout;
-        mN.forEach(aoutt.getNObj());
+        try {
+            mN.forEach(aoutt.getNObj());
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
     }
 
     public Script.KernelID getKernelID() {
         Script.KernelID k = createKernelID(0, 2, null, null);
-        k.mN = mN.getKernelID();
+        try {
+            k.mN = mN.getKernelID();
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
         return k;
     }
 
     public Script.FieldID getFieldID_Input() {
         Script.FieldID f = createFieldID(0, null);
-        f.mN = mN.getFieldID_Input();
+        try {
+            f.mN = mN.getFieldID_Input();
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
         return f;
     }
 }
diff --git a/v8/renderscript/java/src/android/support/v8/renderscript/TypeThunker.java b/v8/renderscript/java/src/android/support/v8/renderscript/TypeThunker.java
index 279d9ba..557c545 100644
--- a/v8/renderscript/java/src/android/support/v8/renderscript/TypeThunker.java
+++ b/v8/renderscript/java/src/android/support/v8/renderscript/TypeThunker.java
@@ -42,8 +42,12 @@
     TypeThunker(RenderScript rs, android.renderscript.Type t) {
         super(0, rs);
         mN = t;
-        internalCalc();
-        mElement = new ElementThunker(rs, t.getElement());
+        try {
+            internalCalc();
+            mElement = new ElementThunker(rs, t.getElement());
+        } catch (android.renderscript.RSRuntimeException e) {
+            throw ExceptionThunker.convertException(e);
+        }
 
         synchronized(mMap) {
             mMap.put(mN, this);
@@ -58,18 +62,22 @@
                        int dx, int dy, int dz, boolean dmip, boolean dfaces, int yuv) {
         ElementThunker et = (ElementThunker)e;
         RenderScriptThunker rst = (RenderScriptThunker)rs;
-        android.renderscript.Type.Builder tb =
-            new android.renderscript.Type.Builder(rst.mN, et.mN);
-        if (dx > 0) tb.setX(dx);
-        if (dy > 0) tb.setY(dy);
-        if (dz > 0) tb.setZ(dz);
-        if (dmip) tb.setMipmaps(dmip);
-        if (dfaces) tb.setFaces(dfaces);
-        if (yuv > 0) tb.setYuvFormat(yuv);
-        android.renderscript.Type nt = tb.create();
-        TypeThunker tt = new TypeThunker(rs, nt);
-        tt.internalCalc();
+        try {
+            android.renderscript.Type.Builder tb =
+                new android.renderscript.Type.Builder(rst.mN, et.mN);
+            if (dx > 0) tb.setX(dx);
+            if (dy > 0) tb.setY(dy);
+            if (dz > 0) tb.setZ(dz);
+            if (dmip) tb.setMipmaps(dmip);
+            if (dfaces) tb.setFaces(dfaces);
+            if (yuv > 0) tb.setYuvFormat(yuv);
+            android.renderscript.Type nt = tb.create();
+            TypeThunker tt = new TypeThunker(rs, nt);
+            tt.internalCalc();
 
-        return tt;
+            return tt;
+        } catch (android.renderscript.RSRuntimeException exc) {
+            throw ExceptionThunker.convertException(exc);
+        }
     }
 }