Re: Getting java constructor parameter names via scala reflection
Juha Heljoranta <[email protected]>
| Newsgroups | gmane.comp.lang.scala |
|---|---|
| Message-ID | <[email protected]> |
see javac option "-parameters'':
https://docs.oracle.com/javase/8/docs/technotes/tools/windows/javac.html
https://docs.oracle.com/javase/tutorial/reflect/member/methodparameterreflection.html
On Saturday, July 11, 2015 07:40:08 Aravindh S 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.