eta icon indicating copy to clipboard operation
eta copied to clipboard

ClassCastException on converting JByteArray to [Byte]

Open jyothsnamutt opened this issue 9 years ago • 1 comments

Repro code:


{-# LANGUAGE OverloadedStrings #-}

import Java

foreign import java unsafe getBytes :: JString -> JByteArray

main :: IO ()
main = do
  let url = "http://github.org/typelead/eta"
      bytes = fromJava $ getBytes url :: [Byte]

  print bytes

Stack trace:


at base.java.Array$zdfJavaConverterZMZNczuzdcfromJava.enter(Unknown Source)
	at main.Main$main3.thunkEnter(Unknown Source)
	at eta.runtime.thunk.StgIndStatic.enter(StgIndStatic.java:27)
	at eta.runtime.stg.StgClosure.evaluate(StgClosure.java:23)
	at base.ghc.Show$showListzuzu.enter(Unknown Source)
	at main.Main$main2.thunkEnter(Unknown Source)
	at eta.runtime.thunk.StgIndStatic.enter(StgIndStatic.java:27)
	at eta.runtime.stg.StgClosure.evaluate(StgClosure.java:23)
	at base.ghc.io.handle.Text$zdwa7.enter(Unknown Source)
	at base.ghc.io.handle.Text$hPutStr2.enter(Unknown Source)
	at main.Main$main1.enter(Unknown Source)
	at eta.runtime.apply.StgFun.apply(StgFun.java:19)
	at eta.runtime.apply.Apply$ApVFast.enter(Apply.java:42)
	at eta.runtime.exception.StgException$Catch.enter(StgException.java:194)
	at main.Main$main6.enter(Unknown Source)
	at main.Main$DZCmain.enter(Unknown Source)
	at eta.runtime.apply.StgFun.apply(StgFun.java:19)
	at eta.runtime.apply.ApV.stackEnter(ApV.java:12)
	at eta.runtime.stg.StackFrame.enter(StackFrame.java:43)
	at eta.runtime.stg.StackFrame.enter(StackFrame.java:26)
	at eta.runtime.stg.Capability.schedule(Capability.java:260)
	at eta.runtime.RtsScheduler.scheduleWaitThread(RtsScheduler.java:57)
	at eta.runtime.Rts.evalLazyIO(Rts.java:95)
	at eta.runtime.Rts.hsMain(Rts.java:38)
	at eta.main.main(Unknown Source)

jyothsnamutt avatar Mar 17 '17 14:03 jyothsnamutt

Fixed in https://github.com/typelead/eta/commit/31de50bd7f841b33b6a51bd7e1d186ec72c7bbb7

rahulmutt avatar Apr 26 '17 03:04 rahulmutt