-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Bindings to the JNI and a high level interface generator. -- -- This package offers bindings to the Java Native Interface and a -- high level interface generator. -- -- -- --
--   >>> INSTALLATION / USAGE
--   
-- -- It should suffice to do cabal install (or cabal install -- java-bridge when installing from hackageDB). /You need to have a -- JDK installed prior to installing this library/. -- -- Setup will try to find the location of your java installation -- automatically. This is needed in order to load libjvm. Note -- that this library is loaded dynamically, which means that linking -- errors might not show up during installation. -- -- You can specify the location of libjvm manually using the -- environment variable FFIJNI_LIBJVM. This environment variable -- is consulted by Setup.hs as well as by the library each time -- libjvm is loaded - which means that you can override the path -- to libjvm at any time. The function -- getCompiledLibjvmPath in Foreign.Java.JNI.Safe will -- tell you what path to libjvm has been set during compilation -- of the library. -- --
--   >>> FUN WITH (cabal-) FLAGS
--   
-- -- The following cabal flags are available to you for configuring your -- installation: -- -- -- -- Use for example cabal install -f OSX_FRAMEWORK -f EXAMPLES or -- cabal configure -f DEBUG. -- --
--   >>> HACKING
--   
-- -- See HACKING.txt and ISSUES.txt in the -- tar.gz-package. @package java-bridge @version 0.20130606.3 module Foreign.Java.Tutorial -- | Utilities to ease IO operations in the Java monad. module Foreign.Java.IO class PrintLn a println :: (PrintLn a, MonadIO m) => a -> m () print :: (PrintLn a, MonadIO m) => a -> m () instance [overlap ok] Show a => PrintLn a instance [overlap ok] PrintLn String -- | Utilities for controlling actions inside the Java monad. module Foreign.Java.Control -- | Execute an action if the given predicate evaluates to True. when :: Monad m => m Bool -> m () -> m () -- | Execute an action if the given predicate evaluates to False. unless :: Monad m => m Bool -> m () -> m () -- | Execute either the first or the second action, depending on whether -- the given predicate evaluates to True or False. whether :: Monad m => m Bool -> m a -> m a -> m a -- | Run a computation as long as the given predicate evaluates to -- True. while :: Monad m => m Bool -> m () -> m () -- | Reiterate a computation on a given value as long as a condition is -- True. for :: Monad m => a -> (a -> m Bool) -> (a -> m a) -> m a -- | Reiterate a computation on a given value until a condition is -- True. until :: Monad m => a -> (a -> m (Bool, a)) -> m a module Foreign.Java.Bindings.HaskellTypes data HaskellModule HaskellModule :: String -> [HaskellFunction] -> [HaskellData] -> HaskellModule moduleName :: HaskellModule -> String moduleFunctions :: HaskellModule -> [HaskellFunction] moduleData :: HaskellModule -> [HaskellData] data HaskellData HaskellData :: String -> [HaskellConstructor] -> HaskellData dataName :: HaskellData -> String dataConstructors :: HaskellData -> [HaskellConstructor] data HaskellFunction HaskellFunction :: String -> [HaskellType] -> HaskellType -> HaskellFunction functionName :: HaskellFunction -> String functionArgs :: HaskellFunction -> [HaskellType] functionReturn :: HaskellFunction -> HaskellType data HaskellConstructor HaskellConstructor :: String -> (String, HaskellType) -> HaskellConstructor constructorName :: HaskellConstructor -> String constructorField :: HaskellConstructor -> (String, HaskellType) data HaskellType HaskellType :: HaskellType instance Show HaskellType instance Eq HaskellType instance Show HaskellConstructor instance Eq HaskellConstructor instance Show HaskellData instance Eq HaskellData instance Show HaskellFunction instance Eq HaskellFunction instance Show HaskellModule instance Eq HaskellModule -- | Utilities for dealing with Class, Package, and Module names in the -- Java and Haskell languages. module Foreign.Java.Utils javaKeywords :: [String] haskellKeywords :: [String] -- | Build the name of a class based on maybe a package and a class name. makeName :: Maybe String -> String -> String -- | Translates a package name into a module name. makePackageModuleName :: String -> String -- | Translates a class name into a module name. makeClassModuleName :: String -> String -- | Splits a class name into package name and class name. -- -- If the name does not contain a package component, the first string is -- empty. -- -- See also joinClassName. splitClassName :: String -> (String, String) -- | Pendant to splitClassName. joinClassName :: (String, String) -> String -- | Retrieve the package name form a simple name of a class. -- --
--   >>> takePackageName "java.lang.A$B"
--   Just "java.lang"
--   
-- --
--   >>> takePackageName "Test"
--   Nothing
--   
takePackageName :: String -> Maybe String -- | Retrieve the class name form a simple name of a class. This also -- contains the name of the enclosing class(es). -- --
--   >>> takeClassName "java.lang.A$B"
--   "A$B"
--   
-- --
--   >>> takeClassName "Thread$State"
--   "Thread$State"
--   
takeClassName :: String -> String -- | Retrieve the class name form a simple name of a class. This contains -- only the name of the class itself. -- --
--   >>> takeBaseClassName "java.lang.A$B"
--   "B"
--   
takeBaseClassName :: String -> String -- | Retrieve the names of the enclosing classes from a simple class name. -- --
--   >>> takeEnclosingClasses "java.lang.Map$EntrySet"
--   ["java.lang.Map"]
--   
-- --
--   >>> takeEnclosingClasses "package.A$B$C"
--   ["package.A", "package.A$B"]
--   
takeEnclosingClasses :: String -> [String] -- | Data structures that describe the interface of Java structures such as -- classes, generic types, their methods, etc. -- -- All types are instances of Data and Typeable and can -- therefor be used with Scrap Your Boilerplate combinators (see -- Data.Generics). module Foreign.Java.Bindings.JavaTypes -- | A JavaType is either a Primitive Type, an Array, or an Object. data JavaType JBoolean :: JavaType JChar :: JavaType JByte :: JavaType JShort :: JavaType JInt :: JavaType JLong :: JavaType JFloat :: JavaType JDouble :: JavaType JObj :: String -> JavaType typeName :: JavaType -> String JArr :: JavaType -> JavaType componentType :: JavaType -> JavaType printJavaType :: JavaType -> String -- | The interface of a Java class. data JavaClass JavaClass :: String -> Maybe String -> String -> [String] -> [String] -> [JavaConstructor] -> [JavaMethod] -> [JavaTypeParam] -> Bool -> [(Int32, String)] -> Bool -> Bool -> Bool -> Bool -> JavaClass className :: JavaClass -> String classPackage :: JavaClass -> Maybe String classModName :: JavaClass -> String classParents :: JavaClass -> [String] classIfaces :: JavaClass -> [String] classConstructors :: JavaClass -> [JavaConstructor] classMethods :: JavaClass -> [JavaMethod] classTypeParams :: JavaClass -> [JavaTypeParam] classEnum :: JavaClass -> Bool classEnumConstants :: JavaClass -> [(Int32, String)] classIface :: JavaClass -> Bool classAnnotation :: JavaClass -> Bool classAbstract :: JavaClass -> Bool classFinal :: JavaClass -> Bool data JavaClassType Annotation :: JavaClassType Interface :: JavaClassType Enum :: JavaClassType Class :: JavaClassType Exception :: JavaClassType Error :: JavaClassType -- | Determines the JavaClassType of a JavaClass. classType :: JavaClass -> JavaClassType -- | Calculate all classes that are referenced in any way by this class. classDependencies :: JavaClass -> [String] -- | Derive the full name from a class definition. See also -- makeName. classFullName :: JavaClass -> String -- | A Type variable declaration. data JavaTypeParam JavaTypeParam :: TyVar -> [JavaGenericType] -> JavaTypeParam paramName :: JavaTypeParam -> TyVar paramBounds :: JavaTypeParam -> [JavaGenericType] -- | A Type variable. This is merely a name. newtype TyVar TyVar :: String -> TyVar tyVarName :: TyVar -> String data JavaGenericType -- | super X, extends X Wildcard :: [JavaGenericType] -> [JavaGenericType] -> JavaGenericType jgtBounds :: JavaGenericType -> [JavaGenericType] jgtLowerBounds :: JavaGenericType -> [JavaGenericType] -- |
--   java.util.ListX
--   
Parameterized :: String -> [JavaGenericType] -> JavaGenericType -- | A plain type, full name. Used for example in a Parameterized -- type, which may be parameterized by a plain type (like -- ClassNumber. -- -- The full name of the base type, e.g. java.lang.Class. jgtBasetype :: JavaGenericType -> String -- | The parameters. jgtParameters :: JavaGenericType -> [JavaGenericType] -- |
--   X[]
--   
GenericArray :: JavaGenericType -> JavaGenericType -- | The base type of the generic array, e.g. java.lang.Number. jgtComponentType :: JavaGenericType -> JavaGenericType -- |
--   X
--   
TypeVarReference :: TyVar -> JavaGenericType -- | The name of the type variable, e.g. E or X. jgtName :: JavaGenericType -> TyVar NotSoGeneric :: String -> JavaGenericType -- | A plain type, full name. Used for example in a Parameterized -- type, which may be parameterized by a plain type (like -- ClassNumber. -- -- The full name of the base type, e.g. java.lang.Class. jgtBasetype :: JavaGenericType -> String -- | The type of a generic type. data JavaGenericTypeType WildcardT :: JavaGenericTypeType ParameterizedT :: JavaGenericTypeType GenericArrayT :: JavaGenericTypeType TypeVarReferenceT :: JavaGenericTypeType NotSoGenericT :: JavaGenericTypeType -- | Get the type of a generic type. jgtType :: JavaGenericType -> JavaGenericTypeType -- | The interface to a method in the Java language. data JavaMethod JavaMethod :: String -> String -> [JavaType] -> [JavaGenericType] -> Maybe JavaType -> JavaGenericType -> [JavaTypeParam] -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> JavaMethod methodName :: JavaMethod -> String methodName' :: JavaMethod -> String methodParams :: JavaMethod -> [JavaType] methodGenericParams :: JavaMethod -> [JavaGenericType] methodReturnType :: JavaMethod -> Maybe JavaType methodGenericReturnType :: JavaMethod -> JavaGenericType methodTypeParams :: JavaMethod -> [JavaTypeParam] methodStatic :: JavaMethod -> Bool methodAbstract :: JavaMethod -> Bool methodPublic :: JavaMethod -> Bool methodFinal :: JavaMethod -> Bool methodNative :: JavaMethod -> Bool methodSynchronized :: JavaMethod -> Bool -- | Return the full names of all classes that this method references in -- its definition. methodDependencies :: JavaMethod -> [String] -- | A Constructor in the Java language. data JavaConstructor JavaConstructor :: [JavaType] -> [JavaGenericType] -> [JavaTypeParam] -> JavaConstructor constructorParams :: JavaConstructor -> [JavaType] constructorGenericParams :: JavaConstructor -> [JavaGenericType] constructorTypeParams :: JavaConstructor -> [JavaTypeParam] -- | Retrieve all classes that this constructor definition references in -- its parameters or generic declaration. constructorDependencies :: JavaConstructor -> [String] instance Typeable JavaType instance Typeable JavaClassType instance Typeable TyVar instance Typeable JavaGenericType instance Typeable JavaTypeParam instance Typeable JavaMethod instance Typeable JavaConstructor instance Typeable JavaClass instance Eq JavaType instance Ord JavaType instance Show JavaType instance Read JavaType instance Data JavaType instance Eq JavaClassType instance Ord JavaClassType instance Show JavaClassType instance Read JavaClassType instance Data JavaClassType instance Eq TyVar instance Ord TyVar instance Show TyVar instance Read TyVar instance Data TyVar instance Eq JavaGenericType instance Ord JavaGenericType instance Show JavaGenericType instance Read JavaGenericType instance Data JavaGenericType instance Eq JavaTypeParam instance Ord JavaTypeParam instance Show JavaTypeParam instance Read JavaTypeParam instance Data JavaTypeParam instance Eq JavaMethod instance Show JavaMethod instance Read JavaMethod instance Data JavaMethod instance Eq JavaConstructor instance Show JavaConstructor instance Read JavaConstructor instance Data JavaConstructor instance Eq JavaClass instance Show JavaClass instance Read JavaClass instance Data JavaClass -- | Low level interface to the Java Virtual Machine. This module is a very -- thin wrapper over the Java Native Interface. -- -- Note that all functions that return references (of type Ptr -- JObjectRef) return global references which you will need to free -- manually. -- -- This module contains unsafe bindings, see also -- Foreign.Java.JNI.Safe. -- -- Read the The Java Native Interface - Programmer's Guide and -- Specification for further information on the Java Native Interface -- (available at -- http://www.soi.city.ac.uk/~kloukin/IN2P3/material/jni.pdf, and -- http://192.9.162.55/docs/books/jni/). module Foreign.Java.JNI.Unsafe data JVM createVM :: IO (Ptr JVM) createVM' :: Word32 -> Ptr CString -> IO (Ptr JVM) destroyVM :: Ptr JVM -> IO () persistVM :: Ptr JVM -> IO () data JClassRef findClass :: Ptr JVM -> CString -> IO (Ptr JClassRef) data JConstructorID data JObjectRef getConstructorID :: Ptr JVM -> Ptr JClassRef -> CString -> IO (Ptr JConstructorID) newObject :: Ptr JVM -> Ptr JClassRef -> Ptr JConstructorID -> Ptr JValues -> IO (Ptr JObjectRef) data JStaticMethodID data JMethodID getStaticMethodID :: Ptr JVM -> Ptr JClassRef -> CString -> CString -> IO (Ptr JStaticMethodID) getMethodID :: Ptr JVM -> Ptr JClassRef -> CString -> CString -> IO (Ptr JMethodID) callStaticVoidMethod :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticMethodID -> Ptr JValues -> IO () callStaticBooleanMethod :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticMethodID -> Ptr JValues -> IO Bool callStaticCharMethod :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticMethodID -> Ptr JValues -> IO Word16 callStaticByteMethod :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticMethodID -> Ptr JValues -> IO Int8 callStaticShortMethod :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticMethodID -> Ptr JValues -> IO Int16 callStaticIntMethod :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticMethodID -> Ptr JValues -> IO Int32 callStaticLongMethod :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticMethodID -> Ptr JValues -> IO Int64 callStaticFloatMethod :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticMethodID -> Ptr JValues -> IO CFloat callStaticDoubleMethod :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticMethodID -> Ptr JValues -> IO CDouble callStaticObjectMethod :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticMethodID -> Ptr JValues -> IO (Ptr JObjectRef) callStaticStringMethod :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticMethodID -> Ptr JValues -> IO CString callVoidMethod :: Ptr JVM -> Ptr JObjectRef -> Ptr JMethodID -> Ptr JValues -> IO () callBooleanMethod :: Ptr JVM -> Ptr JObjectRef -> Ptr JMethodID -> Ptr JValues -> IO Bool callCharMethod :: Ptr JVM -> Ptr JObjectRef -> Ptr JMethodID -> Ptr JValues -> IO Word16 callByteMethod :: Ptr JVM -> Ptr JObjectRef -> Ptr JMethodID -> Ptr JValues -> IO Int8 callShortMethod :: Ptr JVM -> Ptr JObjectRef -> Ptr JMethodID -> Ptr JValues -> IO Int16 callIntMethod :: Ptr JVM -> Ptr JObjectRef -> Ptr JMethodID -> Ptr JValues -> IO Int32 callLongMethod :: Ptr JVM -> Ptr JObjectRef -> Ptr JMethodID -> Ptr JValues -> IO Int64 callFloatMethod :: Ptr JVM -> Ptr JObjectRef -> Ptr JMethodID -> Ptr JValues -> IO CFloat callDoubleMethod :: Ptr JVM -> Ptr JObjectRef -> Ptr JMethodID -> Ptr JValues -> IO CDouble callObjectMethod :: Ptr JVM -> Ptr JObjectRef -> Ptr JMethodID -> Ptr JValues -> IO (Ptr JObjectRef) callStringMethod :: Ptr JVM -> Ptr JObjectRef -> Ptr JMethodID -> Ptr JValues -> IO CString data JFieldID data JStaticFieldID getFieldID :: Ptr JVM -> Ptr JClassRef -> CString -> CString -> IO (Ptr JFieldID) getStaticFieldID :: Ptr JVM -> Ptr JClassRef -> CString -> CString -> IO (Ptr JStaticFieldID) getStaticBooleanField :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticFieldID -> IO Bool getStaticCharField :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticFieldID -> IO Word16 getStaticByteField :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticFieldID -> IO Int8 getStaticShortField :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticFieldID -> IO Int16 getStaticIntField :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticFieldID -> IO Int32 getStaticLongField :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticFieldID -> IO Int64 getStaticFloatField :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticFieldID -> IO CFloat getStaticDoubleField :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticFieldID -> IO CDouble getStaticObjectField :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticFieldID -> IO (Ptr JObjectRef) getStaticStringField :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticFieldID -> IO CString setStaticBooleanField :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticFieldID -> Bool -> IO () setStaticCharField :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticFieldID -> Word16 -> IO () setStaticByteField :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticFieldID -> Int8 -> IO () setStaticShortField :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticFieldID -> Int16 -> IO () setStaticIntField :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticFieldID -> Int32 -> IO () setStaticLongField :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticFieldID -> Int64 -> IO () setStaticFloatField :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticFieldID -> CFloat -> IO () setStaticDoubleField :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticFieldID -> CDouble -> IO () setStaticObjectField :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticFieldID -> Ptr JObjectRef -> IO () setStaticStringField :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticFieldID -> CString -> IO () getBooleanField :: Ptr JVM -> Ptr JObjectRef -> Ptr JFieldID -> IO Bool getCharField :: Ptr JVM -> Ptr JObjectRef -> Ptr JFieldID -> IO Word16 getByteField :: Ptr JVM -> Ptr JObjectRef -> Ptr JFieldID -> IO Int8 getShortField :: Ptr JVM -> Ptr JObjectRef -> Ptr JFieldID -> IO Int16 getIntField :: Ptr JVM -> Ptr JObjectRef -> Ptr JFieldID -> IO Int32 getLongField :: Ptr JVM -> Ptr JObjectRef -> Ptr JFieldID -> IO Int64 getFloatField :: Ptr JVM -> Ptr JObjectRef -> Ptr JFieldID -> IO CFloat getDoubleField :: Ptr JVM -> Ptr JObjectRef -> Ptr JFieldID -> IO CDouble getObjectField :: Ptr JVM -> Ptr JObjectRef -> Ptr JFieldID -> IO (Ptr JObjectRef) getStringField :: Ptr JVM -> Ptr JObjectRef -> Ptr JFieldID -> IO CString setBooleanField :: Ptr JVM -> Ptr JObjectRef -> Ptr JFieldID -> Bool -> IO () setCharField :: Ptr JVM -> Ptr JObjectRef -> Ptr JFieldID -> Word16 -> IO () setByteField :: Ptr JVM -> Ptr JObjectRef -> Ptr JFieldID -> Int8 -> IO () setShortField :: Ptr JVM -> Ptr JObjectRef -> Ptr JFieldID -> Int16 -> IO () setIntField :: Ptr JVM -> Ptr JObjectRef -> Ptr JFieldID -> Int32 -> IO () setLongField :: Ptr JVM -> Ptr JObjectRef -> Ptr JFieldID -> Int64 -> IO () setFloatField :: Ptr JVM -> Ptr JObjectRef -> Ptr JFieldID -> CFloat -> IO () setDoubleField :: Ptr JVM -> Ptr JObjectRef -> Ptr JFieldID -> CDouble -> IO () setObjectField :: Ptr JVM -> Ptr JObjectRef -> Ptr JFieldID -> Ptr JObjectRef -> IO () setStringField :: Ptr JVM -> Ptr JObjectRef -> Ptr JFieldID -> CString -> IO () data JValues data JArg BooleanA :: Bool -> JArg CharA :: Word16 -> JArg ByteA :: Int8 -> JArg ShortA :: Int16 -> JArg IntA :: Int32 -> JArg LongA :: Int64 -> JArg FloatA :: Float -> JArg DoubleA :: Double -> JArg StringA :: String -> JArg ObjectA :: (Maybe JObject) -> JArg ArrayA :: (Maybe (JArray e)) -> JArg -- | Create a JValues Array which can be used for argument passing to a -- multi parameter method. You need to free the Ptr object manually using -- free. -- -- This method is implemented using calloc internally. See the -- native implementation of newJValues. mkJValues :: Ptr JVM -> [JArg] -> IO (Ptr JValues) newJValues :: CInt -> IO (Ptr JValues) setJValueByte :: Ptr JValues -> CInt -> Int8 -> IO () setJValueShort :: Ptr JValues -> CInt -> Int16 -> IO () setJValueInt :: Ptr JValues -> CInt -> Int32 -> IO () setJValueLong :: Ptr JValues -> CInt -> Int64 -> IO () setJValueFloat :: Ptr JValues -> CInt -> CFloat -> IO () setJValueDouble :: Ptr JValues -> CInt -> CDouble -> IO () setJValueObject :: Ptr JValues -> CInt -> Ptr JObjectRef -> IO () setJValueString :: Ptr JVM -> Ptr JValues -> CInt -> CString -> IO () releaseJObjectRef :: Ptr JVM -> Ptr JObjectRef -> IO () releaseJClassRef :: Ptr JVM -> Ptr JClassRef -> IO () releaseJThrowableRef :: Ptr JVM -> Ptr JThrowableRef -> IO () -- | release is a special function which can be used to create a -- ForeignPtr. A ForeignPtr does not carry a reference to a -- virtual machine (no Ptr JVM), thus this function will lookup -- the current virtual machine or do nothing if it can not find one. It -- is realised as a FunPtr as this is what newForeignPtr -- expects. release :: ReleaseGlobalReference a => FunPtr (Ptr a -> IO ()) data JChars data JBytes newJString :: Ptr JVM -> CString -> IO (Ptr JObjectRef) charsFromJString :: Ptr JVM -> Ptr JObjectRef -> IO (Ptr JChars) bytesFromJString :: Ptr JVM -> Ptr JObjectRef -> IO (Ptr JBytes) releaseJChars :: Ptr JVM -> Ptr JObjectRef -> CString -> IO () releaseJBytes :: Ptr JVM -> Ptr JObjectRef -> CString -> IO () jStringToCString :: Ptr JVM -> Ptr JObjectRef -> CString -> IO () getArrayLength :: Ptr JVM -> Ptr JObjectRef -> IO Int32 getObjectClass :: Ptr JVM -> Ptr JObjectRef -> IO (Ptr JClassRef) isInstanceOf :: Ptr JVM -> Ptr JObjectRef -> Ptr JClassRef -> IO Bool data JThrowableRef -- | Checks whether an exception has occured in the virtual machine or not. exceptionCheck :: Ptr JVM -> IO Bool -- | Checks whether an exception occured and return that exception. If no -- exception occured, the returned pointer will be the nullPtr. -- This method will return a local reference only, so beware that the -- obtained Ptr will not be valid for too long. exceptionOccurred :: Ptr JVM -> IO (Ptr JThrowableRef) -- | Checks whether an exception occured and return that exception. If no -- exception occured, the returned pointer will be the nullPtr. -- This method will also call exceptionClear which means that it can not -- be called twice. This method will return a global reference - as -- opposed to exceptionOccurred, which will return a local -- reference only. exceptionOccurredClear :: Ptr JVM -> IO (Ptr JThrowableRef) exceptionClear :: Ptr JVM -> IO () exceptionDescribe :: Ptr JVM -> IO () getDebugStatus :: IO Bool setDebugStatus :: Bool -> IO () -- | Returns the path to libjvm that is used by this library. Note that -- this will return the nullPtr if the library has not yet been -- initialized. The library is lazily initialized the first time that -- runJava' is used. runJava is implemented in terms of -- runJava, as is initJava. -- -- You are not allowed to invoke free on the returned cstring. getLibjvmPath :: IO CString -- | Returns the path to libjvm with which this library has been compiled. -- This is guaranteed to never return nullPtr. -- -- You are not allowed to invoke free on the returned cstring. getCompiledLibjvmPath :: IO CString -- | Sets the path to libjvm. Note that this will only have an effect if -- the library has not yet been initialized, that is before any of the -- following functions is used: runJava, runJava', and -- initJava. -- -- Do not invoke free on the cstring passed to this function, as -- this function will not set a copy but the object given. It is only -- ever used once during the lifecycle of your application. setLibjvmPath :: CString -> IO () registerCallbacks :: Ptr JVM -> Ptr JClassRef -> IO Bool runCocoaMain :: IO () instance ReleaseGlobalReference JThrowableRef instance ReleaseGlobalReference JClassRef instance ReleaseGlobalReference JObjectRef -- | Low level interface to the Java Virtual Machine. This module is a very -- thin wrapper over the Java Native Interface. -- -- Note that all functions that return references (of type Ptr -- JObjectRef) return global references which you will need to free -- manually. -- -- This module contains safe bindings, see also -- Foreign.Java.JNI.Unsafe. -- -- Read the The Java Native Interface - Programmer's Guide and -- Specification for further information on the Java Native Interface -- (available at -- http://www.soi.city.ac.uk/~kloukin/IN2P3/material/jni.pdf, and -- http://192.9.162.55/docs/books/jni/). module Foreign.Java.JNI.Safe data JVM createVM :: IO (Ptr JVM) createVM' :: Word32 -> Ptr CString -> IO (Ptr JVM) destroyVM :: Ptr JVM -> IO () persistVM :: Ptr JVM -> IO () data JClassRef findClass :: Ptr JVM -> CString -> IO (Ptr JClassRef) data JConstructorID data JObjectRef getConstructorID :: Ptr JVM -> Ptr JClassRef -> CString -> IO (Ptr JConstructorID) newObject :: Ptr JVM -> Ptr JClassRef -> Ptr JConstructorID -> Ptr JValues -> IO (Ptr JObjectRef) data JStaticMethodID data JMethodID getStaticMethodID :: Ptr JVM -> Ptr JClassRef -> CString -> CString -> IO (Ptr JStaticMethodID) getMethodID :: Ptr JVM -> Ptr JClassRef -> CString -> CString -> IO (Ptr JMethodID) callStaticVoidMethod :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticMethodID -> Ptr JValues -> IO () callStaticBooleanMethod :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticMethodID -> Ptr JValues -> IO Bool callStaticCharMethod :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticMethodID -> Ptr JValues -> IO Word16 callStaticByteMethod :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticMethodID -> Ptr JValues -> IO Int8 callStaticShortMethod :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticMethodID -> Ptr JValues -> IO Int16 callStaticIntMethod :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticMethodID -> Ptr JValues -> IO Int32 callStaticLongMethod :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticMethodID -> Ptr JValues -> IO Int64 callStaticFloatMethod :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticMethodID -> Ptr JValues -> IO CFloat callStaticDoubleMethod :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticMethodID -> Ptr JValues -> IO CDouble callStaticObjectMethod :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticMethodID -> Ptr JValues -> IO (Ptr JObjectRef) callStaticStringMethod :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticMethodID -> Ptr JValues -> IO CString callVoidMethod :: Ptr JVM -> Ptr JObjectRef -> Ptr JMethodID -> Ptr JValues -> IO () callBooleanMethod :: Ptr JVM -> Ptr JObjectRef -> Ptr JMethodID -> Ptr JValues -> IO Bool callCharMethod :: Ptr JVM -> Ptr JObjectRef -> Ptr JMethodID -> Ptr JValues -> IO Word16 callByteMethod :: Ptr JVM -> Ptr JObjectRef -> Ptr JMethodID -> Ptr JValues -> IO Int8 callShortMethod :: Ptr JVM -> Ptr JObjectRef -> Ptr JMethodID -> Ptr JValues -> IO Int16 callIntMethod :: Ptr JVM -> Ptr JObjectRef -> Ptr JMethodID -> Ptr JValues -> IO Int32 callLongMethod :: Ptr JVM -> Ptr JObjectRef -> Ptr JMethodID -> Ptr JValues -> IO Int64 callFloatMethod :: Ptr JVM -> Ptr JObjectRef -> Ptr JMethodID -> Ptr JValues -> IO CFloat callDoubleMethod :: Ptr JVM -> Ptr JObjectRef -> Ptr JMethodID -> Ptr JValues -> IO CDouble callObjectMethod :: Ptr JVM -> Ptr JObjectRef -> Ptr JMethodID -> Ptr JValues -> IO (Ptr JObjectRef) callStringMethod :: Ptr JVM -> Ptr JObjectRef -> Ptr JMethodID -> Ptr JValues -> IO CString data JFieldID data JStaticFieldID getFieldID :: Ptr JVM -> Ptr JClassRef -> CString -> CString -> IO (Ptr JFieldID) getStaticFieldID :: Ptr JVM -> Ptr JClassRef -> CString -> CString -> IO (Ptr JStaticFieldID) getStaticBooleanField :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticFieldID -> IO Bool getStaticCharField :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticFieldID -> IO Word16 getStaticByteField :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticFieldID -> IO Int8 getStaticShortField :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticFieldID -> IO Int16 getStaticIntField :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticFieldID -> IO Int32 getStaticLongField :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticFieldID -> IO Int64 getStaticFloatField :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticFieldID -> IO CFloat getStaticDoubleField :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticFieldID -> IO CDouble getStaticObjectField :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticFieldID -> IO (Ptr JObjectRef) getStaticStringField :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticFieldID -> IO CString setStaticBooleanField :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticFieldID -> Bool -> IO () setStaticCharField :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticFieldID -> Word16 -> IO () setStaticByteField :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticFieldID -> Int8 -> IO () setStaticShortField :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticFieldID -> Int16 -> IO () setStaticIntField :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticFieldID -> Int32 -> IO () setStaticLongField :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticFieldID -> Int64 -> IO () setStaticFloatField :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticFieldID -> CFloat -> IO () setStaticDoubleField :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticFieldID -> CDouble -> IO () setStaticObjectField :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticFieldID -> Ptr JObjectRef -> IO () setStaticStringField :: Ptr JVM -> Ptr JClassRef -> Ptr JStaticFieldID -> CString -> IO () getBooleanField :: Ptr JVM -> Ptr JObjectRef -> Ptr JFieldID -> IO Bool getCharField :: Ptr JVM -> Ptr JObjectRef -> Ptr JFieldID -> IO Word16 getByteField :: Ptr JVM -> Ptr JObjectRef -> Ptr JFieldID -> IO Int8 getShortField :: Ptr JVM -> Ptr JObjectRef -> Ptr JFieldID -> IO Int16 getIntField :: Ptr JVM -> Ptr JObjectRef -> Ptr JFieldID -> IO Int32 getLongField :: Ptr JVM -> Ptr JObjectRef -> Ptr JFieldID -> IO Int64 getFloatField :: Ptr JVM -> Ptr JObjectRef -> Ptr JFieldID -> IO CFloat getDoubleField :: Ptr JVM -> Ptr JObjectRef -> Ptr JFieldID -> IO CDouble getObjectField :: Ptr JVM -> Ptr JObjectRef -> Ptr JFieldID -> IO (Ptr JObjectRef) getStringField :: Ptr JVM -> Ptr JObjectRef -> Ptr JFieldID -> IO CString setBooleanField :: Ptr JVM -> Ptr JObjectRef -> Ptr JFieldID -> Bool -> IO () setCharField :: Ptr JVM -> Ptr JObjectRef -> Ptr JFieldID -> Word16 -> IO () setByteField :: Ptr JVM -> Ptr JObjectRef -> Ptr JFieldID -> Int8 -> IO () setShortField :: Ptr JVM -> Ptr JObjectRef -> Ptr JFieldID -> Int16 -> IO () setIntField :: Ptr JVM -> Ptr JObjectRef -> Ptr JFieldID -> Int32 -> IO () setLongField :: Ptr JVM -> Ptr JObjectRef -> Ptr JFieldID -> Int64 -> IO () setFloatField :: Ptr JVM -> Ptr JObjectRef -> Ptr JFieldID -> CFloat -> IO () setDoubleField :: Ptr JVM -> Ptr JObjectRef -> Ptr JFieldID -> CDouble -> IO () setObjectField :: Ptr JVM -> Ptr JObjectRef -> Ptr JFieldID -> Ptr JObjectRef -> IO () setStringField :: Ptr JVM -> Ptr JObjectRef -> Ptr JFieldID -> CString -> IO () data JValues data JArg BooleanA :: Bool -> JArg CharA :: Word16 -> JArg ByteA :: Int8 -> JArg ShortA :: Int16 -> JArg IntA :: Int32 -> JArg LongA :: Int64 -> JArg FloatA :: Float -> JArg DoubleA :: Double -> JArg StringA :: String -> JArg ObjectA :: (Maybe JObject) -> JArg ArrayA :: (Maybe (JArray e)) -> JArg -- | Create a JValues Array which can be used for argument passing to a -- multi parameter method. You need to free the Ptr object manually using -- free. -- -- This method is implemented using calloc internally. See the -- native implementation of newJValues. mkJValues :: Ptr JVM -> [JArg] -> IO (Ptr JValues) newJValues :: CInt -> IO (Ptr JValues) setJValueByte :: Ptr JValues -> CInt -> Int8 -> IO () setJValueShort :: Ptr JValues -> CInt -> Int16 -> IO () setJValueInt :: Ptr JValues -> CInt -> Int32 -> IO () setJValueLong :: Ptr JValues -> CInt -> Int64 -> IO () setJValueFloat :: Ptr JValues -> CInt -> CFloat -> IO () setJValueDouble :: Ptr JValues -> CInt -> CDouble -> IO () setJValueObject :: Ptr JValues -> CInt -> Ptr JObjectRef -> IO () setJValueString :: Ptr JVM -> Ptr JValues -> CInt -> CString -> IO () releaseJObjectRef :: Ptr JVM -> Ptr JObjectRef -> IO () releaseJClassRef :: Ptr JVM -> Ptr JClassRef -> IO () releaseJThrowableRef :: Ptr JVM -> Ptr JThrowableRef -> IO () -- | release is a special function which can be used to create a -- ForeignPtr. A ForeignPtr does not carry a reference to a -- virtual machine (no Ptr JVM), thus this function will lookup -- the current virtual machine or do nothing if it can not find one. It -- is realised as a FunPtr as this is what newForeignPtr -- expects. release :: ReleaseGlobalReference a => FunPtr (Ptr a -> IO ()) data JChars data JBytes newJString :: Ptr JVM -> CString -> IO (Ptr JObjectRef) charsFromJString :: Ptr JVM -> Ptr JObjectRef -> IO (Ptr JChars) bytesFromJString :: Ptr JVM -> Ptr JObjectRef -> IO (Ptr JBytes) releaseJChars :: Ptr JVM -> Ptr JObjectRef -> CString -> IO () releaseJBytes :: Ptr JVM -> Ptr JObjectRef -> CString -> IO () jStringToCString :: Ptr JVM -> Ptr JObjectRef -> CString -> IO () getArrayLength :: Ptr JVM -> Ptr JObjectRef -> IO Int32 getObjectClass :: Ptr JVM -> Ptr JObjectRef -> IO (Ptr JClassRef) isInstanceOf :: Ptr JVM -> Ptr JObjectRef -> Ptr JClassRef -> IO Bool data JThrowableRef -- | Checks whether an exception has occured in the virtual machine or not. exceptionCheck :: Ptr JVM -> IO Bool -- | Checks whether an exception occured and return that exception. If no -- exception occured, the returned pointer will be the nullPtr. -- This method will return a local reference only, so beware that the -- obtained Ptr will not be valid for too long. exceptionOccurred :: Ptr JVM -> IO (Ptr JThrowableRef) -- | Checks whether an exception occured and return that exception. If no -- exception occured, the returned pointer will be the nullPtr. -- This method will also call exceptionClear which means that it can not -- be called twice. This method will return a global reference - as -- opposed to exceptionOccurred, which will return a local -- reference only. exceptionOccurredClear :: Ptr JVM -> IO (Ptr JThrowableRef) exceptionClear :: Ptr JVM -> IO () exceptionDescribe :: Ptr JVM -> IO () getDebugStatus :: IO Bool setDebugStatus :: Bool -> IO () -- | Returns the path to libjvm that is used by this library. Note that -- this will return the nullPtr if the library has not yet been -- initialized. The library is lazily initialized the first time that -- runJava' is used. runJava is implemented in terms of -- runJava, as is initJava. -- -- You are not allowed to invoke free on the returned cstring. getLibjvmPath :: IO CString -- | Returns the path to libjvm with which this library has been compiled. -- This is guaranteed to never return nullPtr. -- -- You are not allowed to invoke free on the returned cstring. getCompiledLibjvmPath :: IO CString -- | Sets the path to libjvm. Note that this will only have an effect if -- the library has not yet been initialized, that is before any of the -- following functions is used: runJava, runJava', and -- initJava. -- -- Do not invoke free on the cstring passed to this function, as -- this function will not set a copy but the object given. It is only -- ever used once during the lifecycle of your application. setLibjvmPath :: CString -> IO () registerCallbacks :: Ptr JVM -> Ptr JClassRef -> IO Bool runCocoaMain :: IO () instance ReleaseGlobalReference JThrowableRef instance ReleaseGlobalReference JClassRef instance ReleaseGlobalReference JObjectRef -- | This module contains information about the java bridge on your system. -- For the low level interface use Foreign.Java.JNI.Safe or -- Foreign.Java.JNI.Unsafe, for the medium level interface use -- Foreign.Java. -- -- For creating high level bindings between Haskell and Java use -- Foreign.Java.Bindings. module Foreign.Java.JNI data JniFlag -- | The java bridge was compiled with only the core modules (low level -- interface). ONLY_CORE :: JniFlag -- | The java bridge was compiled with debug symbols. DEBUG :: JniFlag -- | The java bridge was compiled with special support for Cocoa on Mac OS -- X. OSX_GUI :: JniFlag -- | The java bridge was linked with the Java framework on OS X. Otherwise -- libjvm is loaded dynamically. OSX_FRAMEWORK :: JniFlag -- | Returns a list of flags which the java bridge was compiled with. jniFlags :: [JniFlag] -- | The version of the java bridge. javaBridgeVersion :: String instance Show JniFlag instance Eq JniFlag -- | The ternary value type, which can treither hold a value, -- nothing, or a special value describing an error condition. module Foreign.Java.Value -- | A ternary value type to hold one of two possible value types or none -- at all. data Value e a -- | An actual value Value :: a -> Value e a -- | No value NoValue :: Value e a -- | A value describing the error Fail :: e -> Value e a -- | fold on a Value, like either for Either or -- maybe for Maybe. value :: b -> (e -> b) -> (a -> b) -> Value e a -> b -- | This module contains the medium level interface to the Java Bridge. -- -- See Foreign.Java.JNI.Safe and Foreign.Java.JNI.Unsafe -- for the low level interface which is a plain translation of the Java -- Native Interface. Information about the library can be retrieved using -- Foreign.Java.JNI. -- -- High level bindings can be generated using -- Foreign.Java.Bindings. module Foreign.Java -- | Every computation in the Java Virtual Machine happens inside the Java -- monad. The Java monad is mightier than the IO monad, i.e. IO -- operations can be performed in both the IO monad as well as in the -- Java monad, but Java operations can be performed in the Java monad -- only and not in the IO monad. -- -- Use one of runJava or runJava' to perform operations in -- the Java monad. data Java a -- | Run a computation with support by a Java Virtual Machine. runJava :: Java a -> IO a -- | Run a computation with support by a Java Virtual Machine, initialized -- with the given parameters. -- -- This function may be used only once. If you intend to call it multiple -- times, you need to initialize the Java subsystem once before. If you -- fail to do so, this function will tear down the virtual machine once -- it is done. -- -- By using initJava the virtual machine will be alive during the -- whole lifetime of your process and runJava' will never tear -- down the machine. -- -- NOTE: According to the Java Native Interface specification it may -- be possible to create multiple virtual machines within a single -- process. However, no implementation of the JNI seems to be capable of -- doing so. -- -- This function can be used to set for example the classpath of the -- virtual machine: -- --
--   runJava' ["-Djava.class.path=java-library-dir"] $ do
--       doSomething
--   
-- -- NOTE: java.class.path does support relative paths. runJava' :: [String] -> Java a -> IO a -- | Initializes the Java Virtual Machine so that it can be used by -- subsequent invocations of runJava. Note that once you start the -- virtual machine it will be runing throughout the whole lifetime of the -- main thread of your application. initJava :: [String] -> IO () -- | By default java methods are invoked via the FFI using safe calls. Safe -- calls are slower than unsafe calls. This function controls whether -- safe or unsafe calls are being used to communicate with the JVM. -- -- If your application does not invoke the JVM concurrently it is mostly -- safe to use unsafe calls. -- --
--   runJava (setUnsafe True >> doSomething)
--   
-- -- will perform doSomething using unsafe calls. setUnsafe :: MonadState JVMState m => Bool -> m () -- | Short hand for runJavaGui' []. runJavaGui :: Java a -> IO () -- | Mac OS X needs some special treatment for initializing graphical -- applications, namely a Cocoa Runloop needs to be present on the main -- thread. Since the main thread is the application that the JVM was -- invoked from this has two consequences: (1) A runloop needs to be -- created on the main thread manually and (2) the main thread is not -- usable for your application. -- -- On Mac OS X this function will fork an os thread using forkJava -- and start the Cocoa main event loop. This means that this function -- must be called on the main thread and that it will never terminate -- (since the cocoa event queue will be running there forever). -- -- Note that this implies that you link your application with the -- threaded runtime (`-threaded` in GHC). -- -- Typically your application should look like this: -- --
--   main = runJavaGui $ do
--       stuffYourApplicationDoes
--   
-- -- On all other platforms this is exactly the same as runJava' -- (minus the fact that it returns ()). runJavaGui' :: [String] -> Java a -> IO () -- | Finds and loads a class. -- -- Note that this function can indeed fail with an exception and may -- execute code from the class to be loaded inside the virtual machine. -- -- This is due to the fact that getClass is a translation of the -- findClass function in the JNI which loads *and* resolves the -- class. If you want to get a class definition without resolving the -- class, use the method loadClass(String,boolean) on a -- ClassLoader. -- -- Here is an example of how to do that: -- --
--   main' = runJava $ do
--       (Just classLoader) <- getClass "java.lang.ClassLoader"
--       getSystemClassLoader <- classLoader `bindStaticMethod` "getSystemClassLoader"
--           ::= object "java.lang.ClassLoader"
--       (Just systemClassLoader) <- getSystemClassLoader
--   
--       loadClass <- classLoader `bindMethod` "loadClass"
--           ::= string --> boolean --> object "java.lang.Class"
--       (Just clazz) <- loadClass systemClassLoader "java.awt.EventQueue" False
--       io$ print clazz
--   
getClass :: String -> Java (Maybe JClass) getConstructor :: (Monad m, Constructor (a -> String)) => JClass -> a -> Java (m (JConstructor a)) newObject :: JClass -> Java (Maybe JObject) newObjectE :: JClass -> Java (Either JThrowable (Maybe JObject)) newObjectX :: JClass -> Java (Maybe JObject) newObjectFrom :: NewObject p b => JConstructor p -> b newObjectFromE :: NewObjectE p b => JConstructor p -> b newObjectFromX :: NewObjectX p b => JConstructor p -> b getMethod :: Method (p -> String) => JClass -> MethodDescriptor p -> Java (Maybe (JMethod p)) getStaticMethod :: Method (p -> String) => JClass -> MethodDescriptor p -> Java (Maybe (JStaticMethod p)) bindMethod :: (Method (p -> String), MethodCall p b) => JClass -> MethodDescriptor p -> Java (JObject -> b) bindStaticMethod :: (Method (p -> String), StaticCall p b) => JClass -> MethodDescriptor p -> Java b callMethod :: MethodCall p b => JMethod p -> JObject -> b callMethodE :: MethodCallE p b => JMethod p -> JObject -> b callMethodX :: MethodCallX p b => JMethod p -> JObject -> b callStaticMethod :: StaticCall p b => JStaticMethod p -> b callStaticMethodE :: StaticCallE p b => JStaticMethod p -> b callStaticMethodX :: StaticCallX p b => JStaticMethod p -> b getField :: Param a => JClass -> String -> a -> Java (Maybe (JField a)) getStaticField :: Param a => JClass -> String -> a -> Java (Maybe (JStaticField a)) readField :: Field a b => JField a -> JObject -> Java b readStaticField :: Field a b => JStaticField a -> Java b writeField :: Field a b => JField a -> JObject -> b -> Java () writeStaticField :: Field a b => JStaticField a -> b -> Java () -- | Return the length of an JArray. arrayLength :: JArray e -> Java Int32 class JavaArray e a | e -> a where toList arr@(JArray size _) = forM [0 .. size - 1] (arr `at`) at :: JavaArray e a => JArray e -> Int32 -> Java a write :: JavaArray e a => JArray e -> Int32 -> a -> Java () toList :: JavaArray e a => JArray e -> Java [a] -- | Provides basic functions that every Java Object supports. There are -- instances for JObject, JClass, JThrowable, and -- JArray (which are all references to objects in the virtual -- machine). -- -- Minimal complete definition: asObject. class JavaObject a where toString obj = asObject obj >>= toString hashCode obj = asObject obj >>= hashCode classOf obj = asObject obj >>= classOf equals this obj = do { this' <- asObject this; object <- asObject obj; this' `equals` object } toString :: JavaObject a => a -> Java String hashCode :: JavaObject a => a -> Java Int32 asObject :: JavaObject a => a -> Java JObject classOf :: JavaObject a => a -> Java JClass equals :: (JavaObject a, JavaObject b) => a -> b -> Java Bool -- | Check whether the given object is an instance of the given class. isInstanceOf :: JObject -> JClass -> Java Bool -- | Short for liftIO and restricted to the Java monad. io :: IO a -> Java a -- | Lift a computation from the IO monad. liftIO :: MonadIO m => forall a. IO a -> m a -- | A utility function for forking an OS thread which runs in the Java -- Monad. It will return a JavaThreadId which you can wait on -- using waitJava. forkJava :: Java a -> Java (JavaThreadId a) -- | Wait for a Java Thread to exit. If the thread exits abnormally (that -- is, if an exception occurred), this function will return Left -- SomeException. Otherwise it will return the result of the -- computation as Right a. waitJava :: JavaThreadId a -> Java (Either SomeException a) -- | A reference to an instance of a Java Virtual Machine. data JVM -- | A reference to a Class object. data JClass -- | A reference to an arbitrary Object. data JObject -- | A reference to an Array in the JVM. data JArray e data JField a data JStaticField a data JMethod a data JStaticMethod a data JConstructor a -- | A reference to an Exception. data JThrowable data JavaThreadId a data MethodDescriptor p (::=) :: String -> p -> MethodDescriptor p (-->) :: a -> x -> P a x void :: V boolean :: Z char :: C byte :: B short :: S int :: I long :: J float :: F double :: D object :: String -> L string :: X array :: x -> A x instance Show a => Show (JConstructor a) instance Show ConstructorH instance Show a => Show (JStaticMethod a) instance Show a => Show (JMethod a) instance Show StaticH instance Show MethodH instance Show (JField a) instance Show (JStaticField a) instance Field L (Maybe JObject) instance Field F Float instance Field D Double instance Field J Int64 instance Field I Int32 instance Field S Int16 instance Field B Int8 instance Field C Word16 instance Field Z Bool instance MethodCallX (A e) (Java (Maybe (JArray e))) instance MethodCallE (A e) (Java (Either JThrowable (Maybe (JArray e)))) instance MethodCall (A e) (Java (Maybe (JArray e))) instance MethodCallX Q (Java (Maybe JObject)) instance MethodCallE Q (Java (Either JThrowable (Maybe JObject))) instance MethodCall Q (Java (Maybe JObject)) instance MethodCallX L (Java (Maybe JObject)) instance MethodCallE L (Java (Either JThrowable (Maybe JObject))) instance MethodCall L (Java (Maybe JObject)) instance MethodCallX X (Java (Maybe String)) instance MethodCallE X (Java (Either JThrowable (Maybe String))) instance MethodCall X (Java (Maybe String)) instance MethodCallX D (Java Double) instance MethodCallE D (Java (Either JThrowable Double)) instance MethodCall D (Java Double) instance MethodCallX F (Java Float) instance MethodCallE F (Java (Either JThrowable Float)) instance MethodCall F (Java Float) instance MethodCallX J (Java Int64) instance MethodCallE J (Java (Either JThrowable Int64)) instance MethodCall J (Java Int64) instance MethodCallX I (Java Int32) instance MethodCallE I (Java (Either JThrowable Int32)) instance MethodCall I (Java Int32) instance MethodCallX S (Java Int16) instance MethodCallE S (Java (Either JThrowable Int16)) instance MethodCall S (Java Int16) instance MethodCallX B (Java Int8) instance MethodCallE B (Java (Either JThrowable Int8)) instance MethodCall B (Java Int8) instance MethodCallX C (Java Word16) instance MethodCallE C (Java (Either JThrowable Word16)) instance MethodCall C (Java Word16) instance MethodCallX Z (Java Bool) instance MethodCallE Z (Java (Either JThrowable Bool)) instance MethodCall Z (Java Bool) instance MethodCallX V (Java ()) instance MethodCallE V (Java (Either JThrowable ())) instance MethodCall V (Java ()) instance (JArg t v, MethodCallX x b) => MethodCallX (P t x) (v -> b) instance (JArg t v, MethodCallE x b) => MethodCallE (P t x) (v -> b) instance (JArg t v, MethodCall x b) => MethodCall (P t x) (v -> b) instance StaticCallX (A e) (Java (Maybe (JArray e))) instance StaticCallE (A e) (Java (Either JThrowable (Maybe (JArray e)))) instance StaticCall (A e) (Java (Maybe (JArray e))) instance StaticCallX Q (Java (Maybe JObject)) instance StaticCallE Q (Java (Either JThrowable (Maybe JObject))) instance StaticCall Q (Java (Maybe JObject)) instance StaticCallX L (Java (Maybe JObject)) instance StaticCallE L (Java (Either JThrowable (Maybe JObject))) instance StaticCall L (Java (Maybe JObject)) instance StaticCallX X (Java (Maybe String)) instance StaticCallE X (Java (Either JThrowable (Maybe String))) instance StaticCall X (Java (Maybe String)) instance StaticCallX D (Java Double) instance StaticCallE D (Java (Either JThrowable Double)) instance StaticCall D (Java Double) instance StaticCallX F (Java Float) instance StaticCallE F (Java (Either JThrowable Float)) instance StaticCall F (Java Float) instance StaticCallX J (Java Int64) instance StaticCallE J (Java (Either JThrowable Int64)) instance StaticCall J (Java Int64) instance StaticCallX I (Java Int32) instance StaticCallE I (Java (Either JThrowable Int32)) instance StaticCall I (Java Int32) instance StaticCallX S (Java Int16) instance StaticCallE S (Java (Either JThrowable Int16)) instance StaticCall S (Java Int16) instance StaticCallX B (Java Int8) instance StaticCallE B (Java (Either JThrowable Int8)) instance StaticCall B (Java Int8) instance StaticCallX C (Java Word16) instance StaticCallE C (Java (Either JThrowable Word16)) instance StaticCall C (Java Word16) instance StaticCallX Z (Java Bool) instance StaticCallE Z (Java (Either JThrowable Bool)) instance StaticCall Z (Java Bool) instance StaticCallX V (Java ()) instance StaticCallE V (Java (Either JThrowable ())) instance StaticCall V (Java ()) instance (JArg t v, StaticCallX x b) => StaticCallX (P t x) (v -> b) instance (JArg t v, StaticCallE x b) => StaticCallE (P t x) (v -> b) instance (JArg t v, StaticCall x b) => StaticCall (P t x) (v -> b) instance NewObjectE (A e) (Maybe (JArray e) -> Java (Either JThrowable (Maybe JObject))) instance NewObjectX (A e) (Maybe (JArray e) -> Java (Maybe JObject)) instance NewObject (A e) (Maybe (JArray e) -> Java (Maybe JObject)) instance NewObjectE X (String -> Java (Either JThrowable (Maybe JObject))) instance NewObjectX X (String -> Java (Maybe JObject)) instance NewObject X (String -> Java (Maybe JObject)) instance NewObjectE Q (Maybe JObject -> Java (Either JThrowable (Maybe JObject))) instance NewObjectX Q (Maybe JObject -> Java (Maybe JObject)) instance NewObject Q (Maybe JObject -> Java (Maybe JObject)) instance NewObjectE L (Maybe JObject -> Java (Either JThrowable (Maybe JObject))) instance NewObjectX L (Maybe JObject -> Java (Maybe JObject)) instance NewObject L (Maybe JObject -> Java (Maybe JObject)) instance NewObjectE D (Double -> Java (Either JThrowable (Maybe JObject))) instance NewObjectX D (Double -> Java (Maybe JObject)) instance NewObject D (Double -> Java (Maybe JObject)) instance NewObjectE F (Float -> Java (Either JThrowable (Maybe JObject))) instance NewObjectX F (Float -> Java (Maybe JObject)) instance NewObject F (Float -> Java (Maybe JObject)) instance NewObjectE J (Int64 -> Java (Either JThrowable (Maybe JObject))) instance NewObjectX J (Int64 -> Java (Maybe JObject)) instance NewObject J (Int64 -> Java (Maybe JObject)) instance NewObjectE I (Int32 -> Java (Either JThrowable (Maybe JObject))) instance NewObjectX I (Int32 -> Java (Maybe JObject)) instance NewObject I (Int32 -> Java (Maybe JObject)) instance NewObjectE S (Int16 -> Java (Either JThrowable (Maybe JObject))) instance NewObjectX S (Int16 -> Java (Maybe JObject)) instance NewObject S (Int16 -> Java (Maybe JObject)) instance NewObjectE B (Int8 -> Java (Either JThrowable (Maybe JObject))) instance NewObjectX B (Int8 -> Java (Maybe JObject)) instance NewObject B (Int8 -> Java (Maybe JObject)) instance NewObjectE C (Word16 -> Java (Either JThrowable (Maybe JObject))) instance NewObjectX C (Word16 -> Java (Maybe JObject)) instance NewObject C (Word16 -> Java (Maybe JObject)) instance NewObjectE Z (Bool -> Java (Either JThrowable (Maybe JObject))) instance NewObjectX Z (Bool -> Java (Maybe JObject)) instance NewObject Z (Bool -> Java (Maybe JObject)) instance (JArg t v, NewObjectX x b) => NewObjectX (P t x) (v -> b) instance (JArg t v, NewObjectE x b) => NewObjectE (P t x) (v -> b) instance (JArg t v, NewObject x b) => NewObject (P t x) (v -> b) instance JavaArray (A e) (Maybe (JArray e)) instance JavaArray L (Maybe JObject) instance JavaObject (JArray F) instance JavaArray F Float instance JavaObject (JArray D) instance JavaArray D Double instance JavaObject (JArray J) instance JavaArray J Int64 instance JavaObject (JArray I) instance JavaArray I Int32 instance JavaObject (JArray S) instance JavaArray S Int16 instance JavaObject (JArray B) instance JavaArray B Int8 instance JavaObject (JArray C) instance JavaArray C Word16 instance JavaObject (JArray Z) instance JavaArray Z Bool instance JavaObject JThrowable instance JavaObject JClass instance JavaObject (JArray L) instance JavaObject JObject -- | Functions for generating glue code between Haskell and Java. module Foreign.Java.Bindings printJavaPackageModule :: String -> String -> Map String JavaClass -> [JavaClass] -> String printJavaClassModule :: JavaClass -> String -> Map String JavaClass -> String printJavaClassBootfile :: JavaClass -> String -> Map String JavaClass -> String printJavaClassModule' :: JavaClass -> String -> Map String JavaClass -> String printJavaClassBootfile' :: JavaClass -> String -> Map String JavaClass -> String -- | Retrieve information about the given Java classes from the Java -- Virtual Machine. reflectJavaClasses :: [String] -> Java [JavaClass] -- | Find all classes that the given classes depend on. -- -- In order to provide proper bindings for a class, bindings for all -- classes which a class depends on need to exist too. A class depends on -- all classes which it inherits from or which are used as arguments, -- return types, or parameters. -- -- This functions returns all the class names of the classes on which the -- given classes depend on. No duplicates are reported and the resulting -- list is sorted. findJavaClasses :: Word32 -> [String] -> Java [String] -- | The names of all Java Classes part of Java SE 6. javaClassesSE6 :: [String] -- | This module provides type classes and instances for supporting the -- high level bindings. This module should not be imported directly. module Foreign.Java.Bindings.Support object' :: String -> Q class JBoolean a toBoolean :: JBoolean a => a -> Java Bool class JChar a toChar :: JChar a => a -> Java Word16 class JByte a toByte :: JByte a => a -> Java Int8 class JShort a toShort :: JShort a => a -> Java Int16 class JInt a toInt :: JInt a => a -> Java Int32 class JLong a toLong :: JLong a => a -> Java Int64 class JFloat a toFloat :: JFloat a => a -> Java Float class JDouble a toDouble :: JDouble a => a -> Java Double class Array a asMaybeArrayObject :: Array a => a -> Java (Maybe JObject) -- | The result of a function call that is of type boolean. class BooleanResult m toBooleanResult :: BooleanResult m => Either JThrowable Bool -> Java m -- | The result of a function call that is of type char. class CharResult m toCharResult :: CharResult m => Either JThrowable Word16 -> Java m -- | The result of a function call that is of type byte. class ByteResult m toByteResult :: ByteResult m => Either JThrowable Int8 -> Java m -- | The result of a function call that is of type short. class ShortResult m toShortResult :: ShortResult m => Either JThrowable Int16 -> Java m -- | The result of a function call that is of type int. class IntResult m toIntResult :: IntResult m => Either JThrowable Int32 -> Java m -- | The result of a function call that is of type long. class LongResult m toLongResult :: LongResult m => Either JThrowable Int64 -> Java m -- | The result of a function call that is of type float. class FloatResult m toFloatResult :: FloatResult m => Either JThrowable Float -> Java m -- | The result of a function call that is of type double. class DoubleResult m toDoubleResult :: DoubleResult m => Either JThrowable Double -> Java m -- | The result of a function call that is of type void. class VoidResult m toVoidResult :: VoidResult m => Either JThrowable () -> Java m -- | An array result of a function call. class JavaArray (ArrayResultType m) (ArrayResultComponent m) => ArrayResult m where type family ArrayResultType m type family ArrayResultComponent m toArrayResult :: ArrayResult m => Either JThrowable (Maybe (JArray (ArrayResultType m))) -> Java m -- | The result of a function call that is of type object. class ObjectResult m toObjectResult :: ObjectResult m => Either JThrowable (Maybe JObject) -> Java m -- | A convenient alternative to isInstanceOf. -- -- Minimal complete definition: coerce or whenInstanceOf. class InstanceOf a where type family CoercedType a instanceOf o t = whenInstanceOf o t (return . const ()) >>= return . maybe False (const True) whenInstanceOf o t a = coerce o t >>= maybe (return Nothing) (fmap Just . a) coerce o t = whenInstanceOf o t return instanceOf :: (InstanceOf a, JavaObject o) => o -> a -> Java Bool whenInstanceOf :: (InstanceOf a, JavaObject o) => o -> a -> (CoercedType a -> Java d) -> Java (Maybe d) coerce :: (InstanceOf a, JavaObject o) => o -> a -> Java (Maybe (CoercedType a)) -- | For INTERNAL use only. Is however not in a hidden module, so that -- other libraries can link against it. class UnsafeCast a unsafeFromJObject :: UnsafeCast a => JObject -> Java a -- | Yepp. Register callbacks. Do it. registerCallbacks :: JClass -> Java Bool type WrappedFun = Ptr JVM -> Ptr JObjectRef -> Ptr JObjectRef -> Ptr JObjectRef -> IO (Ptr JObjectRef) runJava_ :: Ptr JVM -> Java a -> IO a wrap_ :: WrappedFun -> IO (FunPtr WrappedFun) freeFunPtr :: FunPtr WrappedFun -> IO () wrap :: Java () -> IO (FunPtr WrappedFun) intify :: Java () -> IO Int64 sushimaki :: String -> Java () -> Java JObject delete :: JObject -> Java () instance ObjectResult [Char] instance UnsafeCast a => ObjectResult (Maybe a) instance UnsafeCast a => ObjectResult (Either JThrowable (Maybe a)) instance UnsafeCast a => ObjectResult (Either (Maybe JThrowable) a) instance UnsafeCast a => ObjectResult (Value JThrowable a) instance ArrayResult [String] instance ArrayResult [Char] instance ArrayResult [Double] instance ArrayResult [Float] instance ArrayResult [Int64] instance ArrayResult [Int32] instance ArrayResult [Int16] instance ArrayResult [Int8] instance ArrayResult [Word16] instance ArrayResult [Bool] instance ArrayResult a => ArrayResult (Either JThrowable a) instance VoidResult (Maybe JThrowable) instance VoidResult (Either JThrowable ()) instance VoidResult () instance DoubleResult (Either JThrowable Double) instance DoubleResult Double instance FloatResult (Either JThrowable Float) instance FloatResult Float instance LongResult (Either JThrowable Int64) instance LongResult Int64 instance IntResult (Either JThrowable Int32) instance IntResult Int32 instance ShortResult (Either JThrowable Int16) instance ShortResult Int16 instance ByteResult (Either JThrowable Int8) instance ByteResult Int8 instance CharResult (Either JThrowable Word16) instance CharResult Word16 instance BooleanResult (Either JThrowable Bool) instance BooleanResult Bool instance JDouble Double instance JDouble CDouble instance JFloat Float instance JFloat CFloat instance JLong Int64 instance JLong Word32 instance JLong Int32 instance JLong Word16 instance JLong Int16 instance JLong Word8 instance JLong Int8 instance JLong Int instance JInt Int32 instance JInt Word16 instance JInt Int16 instance JInt Word8 instance JInt Int8 instance JInt Int instance JShort Int16 instance JShort Word8 instance JShort Int8 instance JByte Int8 instance JChar Word16 instance JChar Int8 instance JChar Char instance JBoolean Bool -- | Every java methods returns in priniciple either Nothing or Just a -- value. This is quite cumbersome to work with. This module contains -- utility functions for working with Maybe values in the java monad. -- -- This module offers the orphan instance (!) -- --
--   instance JavaObject a => JavaObject (Maybe a)
--   
-- -- This instance allows you to apply toString and the like without -- unwrapping a Maybe value. -- -- Note that the asObject function provided by this instance is -- undefined (since null is not an object). This is also the -- reason why this instance is not included in Foreign.Java by -- default. Invoking it will call error -- NullPointerException. In other words: This fine module -- will bring back all the joy of Java you might miss in Haskell :-) -- -- toString will return null for Nothing. -- -- hashCode will return 0 for Nothing. -- -- classOf will return the class for java.lang.Void on -- Nothing, as this is a class for which there gare no object -- instances. This is only a stopgap and slightly incorrect, as null is -- not an object, and does therefor not have a class. module Foreign.Java.Maybe instance JavaObject a => JavaObject (Maybe a)