typelead/eta

Improve handling of java files in repl

jneira opened this issue · 1 comments

Follow up of #805 (fixed with #905)

Although the repl is able to load java object files the handling could be improved:

  • Allow reload of .java, .class and .jar files
    • Actually .java and .class are compiled in a auto generated __extra.jar
    • The jar files are being locked by eta (it should be unlocked after create and use it) and cant be changed
    • But likely the eta-serv classloader will not see the updated jars
    • The solution could be load directly the classes contained in those jars to use class reloading of eta-serv
      • Although it could be expensive for big jars
  • Load the classes of java files informed in params (i.e. the files listed in cabal java-sources) when initialize the dynamic linker: https://github.com/typelead/eta/blob/master/compiler/Eta/REPL/Linker.hs#L150-L172
    • It already loads the package jars
    • Avoid loading them in the first load but dont remove the feature of :load path/to/my.jar on the fly
  • In general, as rahulmut suggested in #805, try to not load java files that have not changed since last load.

The solution could be load directly the classes contained in those jars to use class reloading of eta-serv

i guess we should read the classes from jar and use from Eta.REPL

loadClasses :: HscEnv -> [(String, String, ByteString)] -> IO ()

It needs the class name, the class info and the actual contents.

@rahulmutt i see that Eta.Utils.JARhas methods to read entries, but is there some existing way to read classes from? Getting [(String, String, ByteString)]or ClassFile