diff --git a/jni.cabal b/jni.cabal
--- a/jni.cabal
+++ b/jni.cabal
@@ -1,5 +1,5 @@
 name:                jni
-version:             0.5.1
+version:             0.6.0
 synopsis:            Complete JNI raw bindings.
 description:         Please see README.md.
 homepage:            https://github.com/tweag/inline-java/tree/master/jni#readme
diff --git a/src/Foreign/JNI.hs b/src/Foreign/JNI.hs
--- a/src/Foreign/JNI.hs
+++ b/src/Foreign/JNI.hs
@@ -353,7 +353,7 @@
 attachCurrentThreadAsDaemon = do
     throwIfNotOK_
       [CU.exp| jint {
-        (*$(JavaVM* jvm))->AttachCurrentThreadAsDaemon($(JavaVM* jvm), &jniEnv, NULL)
+        (*$(JavaVM* jvm))->AttachCurrentThreadAsDaemon($(JavaVM* jvm), (void**)&jniEnv, NULL)
       } |]
 
 detachCurrentThread :: IO ()
diff --git a/src/Foreign/JNI/Types.hs b/src/Foreign/JNI/Types.hs
--- a/src/Foreign/JNI/Types.hs
+++ b/src/Foreign/JNI/Types.hs
@@ -134,8 +134,8 @@
   | Void                                       -- ^ Void special type
 
 -- | The class of Java types that are "unboxed".
-class IsPrimitiveType (ty :: JType)
-instance IsPrimitiveType ('Prim sym)
+class SingI ty => IsPrimitiveType (ty :: JType)
+instance KnownSymbol sym => IsPrimitiveType ('Prim sym)
 
 class IsReferenceType (ty :: JType)
 instance IsReferenceType ('Class sym)
