Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot reflectively invoke String.+ #6178

Closed
scabug opened this issue Aug 4, 2012 · 4 comments
Closed

Cannot reflectively invoke String.+ #6178

scabug opened this issue Aug 4, 2012 · 4 comments
Assignees
Labels
Milestone

Comments

@scabug
Copy link

@scabug scabug commented Aug 4, 2012

import scala.reflect.runtime.universe._
import scala.reflect.runtime.{currentMirror => cm}

object Test extends App {
  val plus = typeOf[java.lang.String].member(newTermName("$plus")).asMethod
  println(cm.reflect("").reflectMethod(plus).apply("2"))
}
java.lang.NoSuchMethodException: java.lang.String.$plus(java.lang.Object)
        at java.lang.Class.getDeclaredMethod(Class.java:1937)
        at scala.reflect.runtime.JavaMirrors$JavaMirror$$anonfun$methodToJava$1.apply(JavaMirrors.scala:1023)
        at scala.reflect.runtime.JavaMirrors$JavaMirror$$anonfun$methodToJava$1.apply(JavaMirrors.scala:1016)
        at scala.reflect.runtime.TwoWayCache.toJava(TwoWayCache.scala:49)
        at scala.reflect.runtime.JavaMirrors$JavaMirror.methodToJava(JavaMirrors.scala:1016)
        at scala.reflect.runtime.JavaMirrors$JavaMirror$JavaMethodMirror.jmeth$lzycompute(JavaMirrors.scala:236)
        at scala.reflect.runtime.JavaMirrors$JavaMirror$JavaMethodMirror.jmeth(JavaMirrors.scala:235)
        at scala.reflect.runtime.JavaMirrors$JavaMirror$JavaMethodMirror.apply(JavaMirrors.scala:249)
        at Test$delayedInit$body.apply(Test.scala:6)
        at scala.Function0$class.apply$mcV$sp(Function0.scala:40)
        at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
        at scala.App$$anonfun$main$1.apply(App.scala:61)
        at scala.App$$anonfun$main$1.apply(App.scala:61)
        at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
        at scala.collection.immutable.List.foreach(List.scala:78)
        at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:32)
        at scala.collection.mutable.ListBuffer.foreach(ListBuffer.scala:45)
        at scala.App$class.main(App.scala:61)
        at Test$.main(Test.scala:4)
        at Test.main(Test.scala)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at scala.tools.nsc.util.ScalaClassLoader$$anonfun$run$1.apply(ScalaClassLoader.scala:71)
        at scala.tools.nsc.util.ScalaClassLoader$class.asContext(ScalaClassLoader.scala:31)
        at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.asContext(ScalaClassLoader.scala:139)
        at scala.tools.nsc.util.ScalaClassLoader$class.run(ScalaClassLoader.scala:71)
        at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.run(ScalaClassLoader.scala:139)
        at scala.tools.nsc.CommonRunner$class.run(ObjectRunner.scala:28)
        at scala.tools.nsc.ObjectRunner$.run(ObjectRunner.scala:45)
        at scala.tools.nsc.CommonRunner$class.runAndCatch(ObjectRunner.scala:35)
        at scala.tools.nsc.ObjectRunner$.runAndCatch(ObjectRunner.scala:45)
        at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:70)
        at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:92)
        at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:101)
        at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Aug 4, 2012

Imported From: https://issues.scala-lang.org/browse/SI-6178?orig=1
Reporter: @xeno-by
Other Milestones: 2.10.0

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Aug 4, 2012

Sagie Davidovich (sagie.d) said:
Shouldn't it be asMethodSymbol?

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Aug 4, 2012

@xeno-by said:
asXXXSymbol methods have been renamed to asXXX in scala/scala@013acf6

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Aug 7, 2012

@scabug scabug closed this Aug 7, 2012
@scabug scabug added this to the 2.10.0-M6 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.