Java Annotations

51 views
Skip to first unread message

brasten

unread,
Aug 14, 2010, 7:21:11 PM8/14/10
to The Mirah Programming Language
Does Mirah currently support Java annotations in any way?

Started playing with Mirah a week ago, really really liking it!

Rib Rdb

unread,
Aug 16, 2010, 11:57:17 AM8/16/10
to mi...@googlegroups.com
Yes. We use $ instead of @. For example

$Deprecated
def foobar; end

The source code compiler doesn't support annotation values, but the
bytecode backend should support string, class, and annotation values,
as well as arrays of those types. We use square brackets instead of
parens around the values:

$Foo["xyz"]
$Bar["a" => "A"]

brasten

unread,
Aug 16, 2010, 2:11:14 PM8/16/10
to The Mirah Programming Language
Awesome!

No parameter annotations yet? Does anyone know if that's being looked
into?

Rib Rdb

unread,
Aug 16, 2010, 2:16:33 PM8/16/10
to mi...@googlegroups.com
On Mon, Aug 16, 2010 at 11:11 AM, brasten <bra...@gmail.com> wrote:
> Awesome!
>
> No parameter annotations yet?  Does anyone know if that's being looked
> into?

Nope. I'm not sure what the syntax for that would be. Right now I
believe we support class, method and field annotations. For fields
you have to put the annotation on the first use of the field. Eg

def initialize
$Deprecated
@foo = String(nil)
end

Ian Dees

unread,
Sep 21, 2010, 1:08:31 PM9/21/10
to The Mirah Programming Language
Hi, all.

> The source code compiler doesn't support annotation values, but the
> bytecode backend should support string, class, and annotation values,
> as well as arrays of those types.

Does that mean that if Foo.mirah contains an annotation with a value,
that "mirahc Foo.mirah" should work, but "mirahc -j Foo.mirah" not so
much?

> We use square brackets instead of
> parens around the values:
>
> $Foo["xyz"]
> $Bar["a" => "A"]

I couldn't make this work with the bytecode backend at all. For
example, a JAX-RS annotation like $Path["/foo"] produces "undefined
method `[]' for nil:NilClass." What am I missing?

Thanks,

Ian

Rib Rdb

unread,
Sep 21, 2010, 1:17:12 PM9/21/10
to mi...@googlegroups.com
On Tue, Sep 21, 2010 at 10:08 AM, Ian Dees <und...@gmail.com> wrote:
Hi, all.

> The source code compiler doesn't support annotation values, but the
> bytecode backend should support string, class, and annotation values,
> as well as arrays of those types.

Does that mean that if Foo.mirah contains an annotation with a value,
that "mirahc Foo.mirah" should work, but "mirahc -j Foo.mirah" not so
much?

That was true, but I believe I fixed it this weekend so either should work.
 
> We use square brackets instead of
> parens around the values:
>
> $Foo["xyz"]
> $Bar["a" => "A"]

I couldn't make this work with the bytecode backend at all.  For
example, a JAX-RS annotation like $Path["/foo"] produces "undefined
method `[]' for nil:NilClass."  What am I missing?

I fixed a number of annotation bugs this weekend, so make sure you're using the latest version from git.  If you still have issues, can you compile with -V and send me the output? 

Ian Dees

unread,
Sep 21, 2010, 2:14:57 PM9/21/10
to The Mirah Programming Language
Hi.

> I fixed a number of annotation bugs this weekend, so make sure you're using
> the latest version from git.  If you still have issues, can you compile with
> -V and send me the output?

Ah, I see the commits in the git log now. It looks like it's working
fine with these latest additions. Thanks!

--Ian
Reply all
Reply to author
Forward
0 new messages