Scala Programming Language
  1. Scala Programming Language
  2. SI-7071

runtime reflection java interop: non-public constructors aren't present in declarations

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: Scala 2.10.0
    • Fix Version/s: None
    • Component/s: Reflection
    • Labels:
      None

      Description

      package foo;
      
      class PackagePrivateJavaClass {
        private PackagePrivateJavaClass() {}
        protected PackagePrivateJavaClass(int x) {}
        public PackagePrivateJavaClass(int x, int y) {}
      }
      
      ====
      
      
      import scala.reflect.runtime.universe._
      
      package object foo {
        def testAll(): Unit = {
          test(typeOf[foo.PackagePrivateJavaClass].typeSymbol)
        }
      
        def test(sym: Symbol): Unit = {
          printSymbolDetails(sym)
          if (sym.isClass || sym.isModule) {
            sym.typeSignature.declarations.toList.sortBy(_.name.toString) foreach test
          }
        }
      
        def printSymbolDetails(sym: Symbol): Unit = {
          def stableSignature(sym: Symbol) = sym.typeSignature match {
            case ClassInfoType(_, _, _) => "ClassInfoType(...)"
            case tpe => tpe.toString
          }
          println("============")
          println(s"sym = $sym, signature = ${stableSignature(sym)}, owner = ${sym.owner}")
          println(s"isPrivate = ${sym.isPrivate}")
          println(s"isProtected = ${sym.isProtected}")
          println(s"isPublic = ${sym.isPublic}")
          println(s"privateWithin = ${sym.privateWithin}")
        }
      }
      
      object Test extends App {
        foo.testAll()
      }
      
      ============
      sym = class PackagePrivateJavaClass, signature = ClassInfoType(...), owner = package foo
      isPrivate = false
      isProtected = false
      isPublic = false
      privateWithin = package foo
      ============
      sym = constructor PackagePrivateJavaClass, signature = (x$1: Int, x$2: Int)foo.PackagePrivateJavaClass, owner = class PackagePrivateJavaClass
      isPrivate = false
      isProtected = false
      isPublic = true
      privateWithin = <none>
      

        Activity

        There are no comments yet on this issue.

          People

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

            Dates

            • Created:
              Updated:

              Development