This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Scala proxy (first try of Scala's reflection API)

3 replies
gkossakowski
Joined: 2010-03-11,
User offline. Last seen 33 weeks 5 days ago.
Hi,
I decided to give a try idea of implementing Scala counterpart of java.lang.reflect.Proxy functionality. Here's the result of quick hacking: http://goo.gl/5AmJd
Basically, the idea is to provide similar functionality to Proxy but using Scala reflection API types intead of Java ones. There are lots of benefits including proper handling of fancy method names like bar_!.
I think use of Proxies in Java is popular usecase for reflection and we provide our API for it too. Thoughts?
--
Grzegorz Kossakowski

Jordi Salvat i ...
Joined: 2011-09-29,
User offline. Last seen 42 years 45 weeks ago.
Re: Scala proxy (first try of Scala's reflection API)
Wouldn't it be preferable to use Any in the signature of invoke, rather than Object?

2011/10/2 Grzegorz Kossakowski <grzegorz.kossakowski@gmail.com>
Hi,
I decided to give a try idea of implementing Scala counterpart of java.lang.reflect.Proxy functionality. Here's the result of quick hacking: http://goo.gl/5AmJd
Basically, the idea is to provide similar functionality to Proxy but using Scala reflection API types intead of Java ones. There are lots of benefits including proper handling of fancy method names like bar_!.
I think use of Proxies in Java is popular usecase for reflection and we provide our API for it too. Thoughts?
--
Grzegorz Kossakowski


gkossakowski
Joined: 2010-03-11,
User offline. Last seen 33 weeks 5 days ago.
Re: Scala proxy (first try of Scala's reflection API)
On 2 October 2011 23:05, Jordi Salvat i Alabart <jordi.salvat.i.alabart@gmail.com> wrote:
Wouldn't it be preferable to use Any in the signature of invoke, rather than Object?

I'd need to put AnyRef because Array (for args) is invariant. In principle, you are right. It's better to stick to Scala types.
Corrected.
--
Grzegorz Kossakowski
extempore
Joined: 2008-12-17,
User offline. Last seen 35 weeks 3 days ago.
Re: Scala proxy (first try of Scala's reflection API)

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland