VerifyError?

4 views
Skip to first unread message

chrisichris

unread,
Feb 23, 2011, 3:57:22 PM2/23/11
to yeti-lang
Hi,

If I throw an excpetion which is created in a function I get an
java.lang.VerifyError "Can only throw Trowable Objects" however if I
create the exception directly everything works fine:

module org.yeb.validation;

validationException key msg lst value is string -> string ->
list<string> -> 'a -> ~ValidationException=(
msgO = message key msg lst;
new ValidationException(msgO, value unsafely_as ~Object); //
extends IllegalArgumentException
);

strToNum str =
try
number str
catch java.lang.Exception ex:
throw validationException "nonum" "%1$s is no number" [str]
str; //gives VerifyError
//this works fine: throw new ValidationException(message
"nonum" "%1$s is nonumber" [str], str);
yrt;

BTW: are java varargs supported or what is the best way to give an
array of arbitrary content ~Object[] to ~java.lang.String#format()
mixing numbers strings and all in an array list types?

The exception is.

Exception in thread "Timer-0" java.lang.VerifyError: (class:org/yeb/
validation$strFormatedToNum, method: _0 signature: (Lyeti/lang/
Fun;Ljava/lang/String;Lyeti/
lang/Tag;Lyeti/lang/Fun;)Ljava/lang/Object;) Can only throw Throwable
objects
at org.yeb.validation.eval(org/yeb/validation.yeti)
at code.apply(<>)
at yeti.lang.compiler.repl$$execClass._0(repl.yeti:81)
at yeti.lang.compiler.repl$$execClass.apply(repl.yeti:62)
at yeti.lang.compiler.repl$$evaluate._0(repl.yeti:109)
at yeti.lang.compiler.repl$$evaluate._0(repl.yeti:106)
at yeti.lang.compiler.repl$$evaluate.apply(repl.yeti:100)
at yeti.lang.Fun2_.apply(Unknown Source)
at
yeti.lang.compiler.YeticlCompileCtxt.eval(YeticlCompileCtxt.java:77)
at org.yeticl.YetiEvaluator.eval(YetiEvaluator.java:56)
at org.yeticl.shell$brancheWithDirs.apply(shell.yeti:167)
at org.yeticl.shell$branche.apply(shell.yeti:173)
at code$.apply(<>:1)
at org.yeticl.shell$MyTimerTask.run(shell.yeti:84)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)

Madis

unread,
Feb 23, 2011, 5:24:55 PM2/23/11
to yeti-lang

On Wed, 23 Feb 2011, chrisichris wrote:

> If I throw an excpetion which is created in a function I get an
> java.lang.VerifyError "Can only throw Trowable Objects" however if I
> create the exception directly everything works fine:
>
> module org.yeb.validation;
>
> validationException key msg lst value is string -> string ->
> list<string> -> 'a -> ~ValidationException=(
> msgO = message key msg lst;
> new ValidationException(msgO, value unsafely_as ~Object); // extends IllegalArgumentException
> );
>
> strToNum str =
> try
> number str
> catch java.lang.Exception ex:

> throw validationException "nonum" "%1$s is no number" [str] strB; //gives VerifyError

That's weird. It should give compilation error? It gives to me.

wtf.yeti:11:8: Not a Throwable instance (string -> string -> list<string> -> 'a -> ~wtf$ValidationException)

But after adding the parenthesis I got the VerifyError.

throw (validationException "nonum" "%1$s is no number" [str] strB);

> //this works fine: throw new ValidationException(message
> "nonum" "%1$s is nonumber" [str], str);
> yrt;
>

> The exception is.
>
> Exception in thread "Timer-0" java.lang.VerifyError: (class:org/yeb/
> validation$strFormatedToNum, method: _0 signature: (Lyeti/lang/
> Fun;Ljava/lang/String;Lyeti/
> lang/Tag;Lyeti/lang/Fun;)Ljava/lang/Object;) Can only throw Throwable
> objects

Looking the generated code I know why, missing checkcast. Should be fixed now.

> BTW: are java varargs supported or what is the best way to give an
> array of arbitrary content ~Object[] to ~java.lang.String#format()
> mixing numbers strings and all in an array list types?

list<~Object> is probably good for giving varargs (should be- Yeti is
unaware that varargs are special and sees what they are at the JVM level -
arrays).

> (~) x = x as ~Object
~ is 'a -> ~java.lang.Object = <code$$_>
> String#format("%2$s or %1$s", [2~, "kala"~])
"kala or 2" is string

chrisichris

unread,
Feb 24, 2011, 12:40:41 AM2/24/11
to yeti-lang
Thanks for the fast fix (and sorry again for the compile exception in
my code I had already changed everything to working version).

>
> list<~Object> is probably good for giving varargs (should be- Yeti is
> unaware that varargs are special and sees what they are at the JVM level -
> arrays).
>
> > (~) x = x as ~Object
>
> ~ is 'a -> ~java.lang.Object = <code$$_>> String#format("%2$s or %1$s", [2~, "kala"~])
>
> "kala or 2" is string

Wow this is a nice one.

Thanks
Reply all
Reply to author
Forward
0 new messages