X-Git-Url: http://wien.tomnetworks.com/gitweb/?p=hs-java.git;a=blobdiff_plain;f=TestGen.hs;h=9d1bcd8caa43ae249056e1978970aee27106c8eb;hp=f21912c58e863481124923c72bbb70eddac2dea5;hb=HEAD;hpb=16e599a66ff843547b005beba38923869665efe8 diff --git a/TestGen.hs b/TestGen.hs index f21912c..9d1bcd8 100644 --- a/TestGen.hs +++ b/TestGen.hs @@ -1,23 +1,25 @@ -{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE OverloadedStrings, FlexibleContexts #-} +import Control.Monad.Exception import qualified Data.ByteString.Lazy as B import JVM.ClassFile import JVM.Converter import JVM.Assembler import JVM.Builder +import JVM.Exceptions import Java.ClassPath import qualified Java.Lang import qualified Java.IO -test :: Generate () +test :: (Throws ENotFound e, Throws ENotLoaded e, Throws UnexpectedEndMethod e) => GenerateIO e () test = do withClassPath $ do -- Add current directory (with Hello.class) to ClassPath addDirectory "." - -- Load method signature: Hello.hello() + -- Load method signature: Hello.hello() from Hello.class helloJava <- getClassMethod "./Hello" "hello" -- Initializer method. Just calls java.lang.Object. @@ -63,6 +65,6 @@ test = do main :: IO () main = do - testClass <- generate [] "Test" test + testClass <- generateIO [] "Test" test B.writeFile "Test.class" (encodeClass testClass)