Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Duplicate
    • Affects Version/s: Scala 2.10.0
    • Fix Version/s: Scala 2.10.0-M6
    • Component/s: Reflection
    • Labels:
      None

      Description

      scala> class A
      defined class A
      
      scala> class B {
           | def foo(x: A) = 1
           | }
      defined class B
      
      scala> val cm = reflect.runtime.currentMirror
      cm: reflect.runtime.universe.Mirror = JavaMirror with scala.tools.nsc.interpreter.IMain$TranslatingClassLoader@1f517997 of type class scala.tools.nsc.interpreter.IMain$TranslatingClassLoader with classpath <unknown>
      
      scala> val u = cm.universe
      u: reflect.runtime.universe.type = scala.reflect.runtime.JavaUniverse@44cdf872
      
      scala> val im = cm.reflect(new B)
      im: reflect.runtime.universe.InstanceMirror = scala.reflect.runtime.JavaMirrors$JavaMirror$JavaInstanceMirror@76ad962c
      
      scala> val method = im.symbol.asType.nonPrivateMember(u.newTermName("foo")).asMethodSymbol
      method: reflect.runtime.universe.MethodSymbol = method foo
      
      scala> im.reflectMethod(method)
      res0: reflect.runtime.universe.MethodMirror = scala.reflect.runtime.JavaMirrors$JavaMirror$JavaMethodMirror@40c84051
      
      scala> res0(new A)
      java.lang.ClassNotFoundException: no Java class corresponding to object $iw found
              at scala.reflect.runtime.JavaMirrors$JavaMirror$$anonfun$classToJava$1.scala$reflect$runtime$JavaMirrors$JavaMirror$$anonfun$$noClass$1(JavaMirrors.scala:905)
              at scala.reflect.runtime.JavaMirrors$JavaMirror$$anonfun$classToJava$1$$anonfun$apply$3.apply(JavaMirrors.scala:917)
              at scala.reflect.runtime.JavaMirrors$JavaMirror$$anonfun$classToJava$1$$anonfun$apply$3.apply(JavaMirrors.scala:917)
              at scala.Option.getOrElse(Option.scala:120)
              at scala.reflect.runtime.JavaMirrors$JavaMirror$$anonfun$classToJava$1.apply(JavaMirrors.scala:917)
              at scala.reflect.runtime.JavaMirrors$JavaMirror$$anonfun$classToJava$1.apply(JavaMirrors.scala:904)
              at scala.reflect.runtime.TwoWayCache.toJava(TwoWayCache.scala:36)
              at scala.reflect.runtime.JavaMirrors$JavaMirror.classToJava(JavaMirrors.scala:904)
              at scala.reflect.runtime.JavaMirrors$JavaMirror$$anonfun$classToJava$1.apply(JavaMirrors.scala:914)
              at scala.reflect.runtime.JavaMirrors$JavaMirror$$anonfun$classToJava$1.apply(JavaMirrors.scala:904)
              at scala.reflect.runtime.TwoWayCache.toJava(TwoWayCache.scala:36)
              at scala.reflect.runtime.JavaMirrors$JavaMirror.classToJava(JavaMirrors.scala:904)
              at scala.reflect.runtime.JavaMirrors$JavaMirror$$anonfun$classToJava$1.apply(JavaMirrors.scala:914)
              at scala.reflect.runtime.JavaMirrors$JavaMirror$$anonfun$classToJava$1.apply(JavaMirrors.scala:904)
              at scala.reflect.runtime.TwoWayCache.toJava(TwoWayCache.scala:36)
              at scala.reflect.runtime.JavaMirrors$JavaMirror.classToJava(JavaMirrors.scala:904)
              at scala.reflect.runtime.JavaMirrors$JavaMirror.typeToJavaClass(JavaMirrors.scala:974)
              at scala.reflect.runtime.JavaMirrors$JavaMirror$$anonfun$methodToJava$1$$anonfun$21.apply(JavaMirrors.scala:943)
              at scala.reflect.runtime.JavaMirrors$JavaMirror$$anonfun$methodToJava$1$$anonfun$21.apply(JavaMirrors.scala:943)
              at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:239)
              at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:239)
              at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
              at scala.collection.immutable.List.foreach(List.scala:77)
              at scala.collection.TraversableLike$class.map(TraversableLike.scala:239)
              at scala.collection.AbstractTraversable.map(Traversable.scala:105)
              at scala.reflect.runtime.JavaMirrors$JavaMirror$$anonfun$methodToJava$1.apply(JavaMirrors.scala:943)
              at scala.reflect.runtime.JavaMirrors$JavaMirror$$anonfun$methodToJava$1.apply(JavaMirrors.scala:941)
              at scala.reflect.runtime.TwoWayCache.toJava(TwoWayCache.scala:36)
              at scala.reflect.runtime.JavaMirrors$JavaMirror.methodToJava(JavaMirrors.scala:941)
              at scala.reflect.runtime.JavaMirrors$JavaMirror$JavaMethodMirror.jmeth$lzycompute(JavaMirrors.scala:179)
              at scala.reflect.runtime.JavaMirrors$JavaMirror$JavaMethodMirror.jmeth(JavaMirrors.scala:178)
              at scala.reflect.runtime.JavaMirrors$JavaMirror$JavaMethodMirror.apply(JavaMirrors.scala:192)
              at .<init>(<console>:15)
              at .<clinit>(<console>)
              at .<init>(<console>:7)
              at .<clinit>(<console>)
              at $print(<console>)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
              at java.lang.reflect.Method.invoke(Method.java:616)
              at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.call(IMain.scala:736)
              at scala.tools.nsc.interpreter.IMain$Request.loadAndRun(IMain.scala:991)
              at scala.tools.nsc.interpreter.IMain.loadAndRunReq$1(IMain.scala:579)
              at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:610)
              at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:574)
              at scala.tools.nsc.interpreter.ILoop.reallyInterpret$1(ILoop.scala:742)
              at scala.tools.nsc.interpreter.ILoop.interpretStartingWith(ILoop.scala:787)
              at scala.tools.nsc.interpreter.ILoop.command(ILoop.scala:699)
              at scala.tools.nsc.interpreter.ILoop.processLine$1(ILoop.scala:563)
              at scala.tools.nsc.interpreter.ILoop.innerLoop$1(ILoop.scala:570)
              at scala.tools.nsc.interpreter.ILoop.loop(ILoop.scala:573)
              at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply$mcZ$sp(ILoop.scala:864)
              at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:819)
              at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:819)
              at scala.tools.nsc.util.ScalaClassLoader$.savingContextLoader(ScalaClassLoader.scala:135)
              at scala.tools.nsc.interpreter.ILoop.process(ILoop.scala:819)
              at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:79)
              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)
      

        Issue Links

          Activity

          Hide
          Eugene Burmako added a comment -

          Duplicate of SI-4023

          Show
          Eugene Burmako added a comment - Duplicate of SI-4023
          Hide
          Daniel Sobral added a comment -

          Even though this issue has been closed, I'd like to point out something said on issue SI-4316, linked by SI-4023:

          Paul Phillips added a comment - 13/Aug/11 7:58 PM
          Don't hold me to too many details, but yes. It is the reverse which gets us elsewhere: reflection expects a class called foo$bar$baz$1 to be nested inside a class called foo$bar$baz, and with us that's not all that likely.

          Grzegorz Kossakowski added a comment - 13/Aug/11 8:05 PM
          I see. It's interesting, I thought InnerClasses attribute in a class servers exactly this purpose to provide information about nesting. If implementations decided to ignore their own invention and rely on strings then I'd be in favor of ignoring Java reflection entirely.
          It's quite likely that we'll be in luxury situation of having native Scala reflection that we can point folks at.

          Is Scala reflection making use of that InnerClasses attribute? Could it, to avoid this problem?

          Show
          Daniel Sobral added a comment - Even though this issue has been closed, I'd like to point out something said on issue SI-4316 , linked by SI-4023 : Paul Phillips added a comment - 13/Aug/11 7:58 PM Don't hold me to too many details, but yes. It is the reverse which gets us elsewhere: reflection expects a class called foo$bar$baz$1 to be nested inside a class called foo$bar$baz, and with us that's not all that likely. Grzegorz Kossakowski added a comment - 13/Aug/11 8:05 PM I see. It's interesting, I thought InnerClasses attribute in a class servers exactly this purpose to provide information about nesting. If implementations decided to ignore their own invention and rely on strings then I'd be in favor of ignoring Java reflection entirely. It's quite likely that we'll be in luxury situation of having native Scala reflection that we can point folks at. Is Scala reflection making use of that InnerClasses attribute? Could it, to avoid this problem?
          Hide
          Eugene Burmako added a comment -

          Let's proceed with the discussion at SI-4023, okay? Greg has also asked a similar question there.

          Show
          Eugene Burmako added a comment - Let's proceed with the discussion at SI-4023 , okay? Greg has also asked a similar question there.

            People

            • Assignee:
              Eugene Burmako
              Reporter:
              Eugene Burmako
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development