Re: Getting java constructor parameter names via scala reflection

Jon Pretty <[email protected]>
Newsgroups gmane.comp.lang.scala
Message-ID <CAE45xch67AwouDzFF4Yvb7GqFUpfO4s6-d5B-NA3a380e4H4iw@mail.gmail.com>
I didn't know the answer myself, but this looks like it might be helpful:


http://stackoverflow.com/questions/18556400/some-function-parameters-named-arg0-arg1-etc-after-compiling-a-jar-library

Cheers,
Jon

On 11 July 2015 at 16:40, Aravindh S <[email protected]> wrote:

> Hi,
>  I am trying to get the names of constructor parameters of a java class
> using scala reflection. I have the following:
> Tender.java
>
> public class Tender {
>     public String name;
>     public int age;
>
>     public Tender(String name,int age){
>         this.name = name;
>
>         this.age = age;
>     }
> }
>
>
> Program.scala
>
> def classAccessors[T: TypeTag] = typeOf[T].members.head.asMethod.paramLists
>
> private val symbols = classAccessors[Tender]
>
>
> I am getting the value of symbols as List(List(value x$1, value x$2))
> I want the actual names viz `name` & `age` rather than x$1 & x$2. Is there
> any way to accomplish this?
>
>
> Thanks
> Aravindh.S
>
>  --
> You received this message because you are subscribed to the Google Groups
> "scala-language" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Jon Pretty | @propensive

-- 
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.