Github user tdas commented on a diff in the pull request:
https://github.com/apache/spark/pull/7471#discussion_r35051130
--- Diff:
streaming/src/main/scala/org/apache/spark/streaming/receiver/Receiver.scala ---
@@ -271,7 +271,7 @@ abstract class Receiver[T](val storageLevel:
StorageLevel) extends Serializable
}
/** Get the attached executor. */
- private def executor = {
+ private[streaming] def executor = {
--- End diff --
Aah, I see. The reason I wanted to use PrivateTest is because marking
private[streaming] make it invisible through Scala compilation, but its visibly
publicly in the bytecode, and therefore through Java. And since Receivers can
be written in Java, I dont want to expose that. PrivateTester wont work, but
the underlying mechanism will working using reflection.
```
scala> abstract class A { private val i = 1 }
defined class A
scala> class B extends A
defined class B
scala> B.getClass().getSuperclass()
<console>:8: error: not found: value B
B.getClass().getSuperclass()
^
scala> classOf[B].getSuperclass()
res1: Class[_ >: B] = class A
scala> classOf[B].getSuperclass().getDeclaredFields()
res2: Array[java.lang.reflect.Field] = Array(private final int A.i)
scala> val f = classOf[B].getSuperclass().getDeclaredFields().head
f: java.lang.reflect.Field = private final int A.i
scala> f.setAccessible(true)
scala> f.get(new B)
res4: Object = 1
```
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]