diff --git a/.gitignore b/.gitignore
index d39a0a4a07f33856d938f8873ce7daafa0d520c1..b674588e27e55b7c7690d835b67f04c65df94d1f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,6 +15,7 @@
 /com.oracle.truffle.r.native/builtinlibs/lib/*
 /com.oracle.truffle.r.native/library/*/lib/*
 /com.oracle.truffle.r.native/library/stats/src/fft.c
+/com.oracle.truffle.r.native/library/tools/src/gramRd.c
 /com.oracle.truffle.r.native/platform.mk
 /com.oracle.truffle.r.native/gnur/Makeconf.done
 /com.oracle.truffle.r.native/gnur/platform.mk.temp*
@@ -26,6 +27,8 @@
 /com.oracle.truffle.r.test.native/packages/*/lib/*
 /com.oracle.truffle.r.test/rpackages/testrlibs_user
 /com.oracle.truffle.r.test.native/urand/lib/liburand.so
+/com.oracle.truffle.r.release/lib/
+/com.oracle.truffle.r.release/library/
 /DEPARSE_ERROR
 /Rpkgsource/*
 /install.cran.logs/
diff --git a/com.oracle.truffle.r.native/library/tools/src/gramRd_fastr.h b/com.oracle.truffle.r.native/library/tools/src/gramRd_fastr.h
new file mode 100644
index 0000000000000000000000000000000000000000..9a24cdf2bd15873b395e078951e793bfcd659f37
--- /dev/null
+++ b/com.oracle.truffle.r.native/library/tools/src/gramRd_fastr.h
@@ -0,0 +1,6 @@
+#ifndef GRAMRD_FASTR_H
+#define GRAMRD_FASTR_H
+
+int callGetCMethod(void *conn);
+
+#endif //GRAMRD_FASTR_H
diff --git a/com.oracle.truffle.r.native/library/tools/src/gramRd_jni.c b/com.oracle.truffle.r.native/library/tools/src/gramRd_jni.c
new file mode 100644
index 0000000000000000000000000000000000000000..72a695e0130f2496c3062656207c696bd8189e09
--- /dev/null
+++ b/com.oracle.truffle.r.native/library/tools/src/gramRd_jni.c
@@ -0,0 +1,20 @@
+#include "gramRd_fastr.h"
+#include <jni.h>
+
+extern JNIEnv *getEnv();
+
+static jmethodID getcMethodID = NULL;
+
+static void findGetCMethod(JNIEnv *env) {
+    jclass klass = (*env)->FindClass(env, "com/oracle/truffle/r/runtime/conn/RConnection");
+    getcMethodID = (*env)->GetMethodID(env, klass, "getc", "()I");
+}
+
+int callGetCMethod(void *conn) {
+    JNIEnv *env = getEnv();
+	if (getcMethodID == NULL) {
+		findGetCMethod(env);
+	}
+    int c = (*env)->CallIntMethod(env, conn, getcMethodID, conn);
+    return c;
+}