You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to scala-debate
Real-world use case:
Extract all the values of a target type from instances at rutime. Instance class and val names are not know at compile time.
Java based solution allowes to cache Methods. Retrieving a field value is simple and efficient: cacheMethod.invoke(instance)
Scala based solution only allows to cache MethodSymbols
Aleksey Nikiforov
unread,
Jan 25, 2013, 7:08:02 PM1/25/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to scala-debate
...continued:
Scala based solution only allows to cache MethodSymbols. Retrieving a field is also simple: instanceMirror.reflectField(cachedMethodSymbol).get
However the Scala based solution is over 40 times slower than Java counterpart, and is not usable in production.
It
would greatly improve performance if a new FieldMirrors could be created with
another instance: fieldMirror.forInstance(instance).get. As long as it
is possible to cache method handles any other (possibly more elegant) solution
would make Scala reflection much faster.
Jason Zaugg
unread,
Jan 26, 2013, 2:33:15 AM1/26/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Aleksey Nikiforov, scala-debate
This facility was added in the master branch, which is targetting 2.11.x [1].
We can't add it to 2.10.1 because we are maintaining forward binary compatibility along the 2.10.x series, so we can't add public methods.