Skip to content

Instantly share code, notes, and snippets.

Last active Sep 29, 2017
What would you like to do?
Example of Eta code that gives `java.lang.VerifyError: Bad type on operand stack` error.
{-# LANGUAGE FlexibleContexts #-}
module Main where
import Java
import Java.Do
main :: IO ()
main = putStrLn $
mconcat $
fmap (\x -> let _ = x :: JInteger in show x) $
fromJava $
funApply2 (toJavaFun mkList) $ toJava (3 :: Int)
mkList :: JInteger -> (List JInteger)
mkList x = toJava [x]
foreign import java unsafe "@interface apply" funApply2 :: (Extends t Object, Extends r Object) => Function t r -> t -> r

This comment has been minimized.

Copy link
Owner Author

@msgodf msgodf commented Sep 29, 2017

This gives the following output:

Exception in thread "main" java.lang.VerifyError: Bad type on operand stack
Exception Details:
    main/Main$lvl3_sEQG.thunkEnter(Leta/runtime/stg/StgContext;)Leta/runtime/stg/Closure; @10: invokespecial
    Type 'java/lang/Object' (current frame, stack[2]) is not assignable to 'java/lang/Integer'
  Current Frame:
    bci: @10
    flags: { }
    locals: { 'main/Main$lvl3_sEQG', 'eta/runtime/stg/StgContext', 'java/lang/Object' }
    stack: { uninitialized 5, uninitialized 5, 'java/lang/Object' }
    0x0000000: 2ab4 0021 4dbb 0009 592c b700 294e bb00
    0x0000010: 0e59 2db8 002e b700 343a 042b 05b8 0037
    0x0000020: b600 3a2b 06b8 003e b600 3a2b 07b8 0041
    0x0000030: b600 3a2b 0819 04b6 003a b800 442b b600
    0x0000040: 473a 0519 05c0 0013 59b4 004a 3a06 57bb
    0x0000050: 0016 5919 06b7 004f 3a07 1907 b0

	at main.Main$main3.enter(Main.hs)
	at eta.runtime.apply.Function.applyP(
	at eta.runtime.thunk.Ap2Upd.thunkEnter(
	at eta.runtime.thunk.UpdatableThunk.enter(
	at eta.runtime.thunk.Thunk.applyO(
	at eta.runtime.apply.PAP.apply(
	at eta.runtime.apply.PAP.applyO(
	at eta.runtime.stg.Closures$EvalJava.enter(
	at eta.runtime.stg.Capability.schedule(
	at eta.runtime.stg.Capability.scheduleClosure(
	at eta.runtime.Runtime.evalJava(
	at$Eta.apply(Unknown Source)
	at main.Main$main2.thunkEnter(Main.hs)
	at eta.runtime.thunk.CAF.enter(
	at eta.runtime.stg.Closure.evaluate(
	at main.Main$main1.enter(Main.hs)
	at main.Main$DZCmain.enter(Main.hs)
	at eta.runtime.apply.Function.applyV(
	at eta.runtime.stg.Closures$EvalLazyIO.enter(
	at eta.runtime.stg.Capability.schedule(
	at eta.runtime.stg.Capability.scheduleClosure(
	at eta.runtime.Runtime.evalLazyIO(
	at eta.runtime.Runtime.main(
	at eta.main.main(Unknown Source)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment