Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import java.util.jar.JarFile
import scala.collection.mutable
import scala.collection.JavaConversions._
import scala.reflect.runtime.universe.runtimeMirror
import scala.reflect.runtime.{universe => unv}

/**
* A tool for generating classes to be excluded during binary checking with MIMA. It is expected
Expand All @@ -42,7 +43,7 @@ object GenerateMIMAIgnore {
private def classesPrivateWithin(packageName: String): Set[String] = {

val classes = getClasses(packageName)
val privateClasses = mutable.HashSet[String]()
val ignoredClasses = mutable.HashSet[String]()

def isPackagePrivate(className: String) = {
try {
Expand Down Expand Up @@ -70,8 +71,21 @@ object GenerateMIMAIgnore {
}
}

def isDeveloperApi(className: String) = {
try {
val clazz = mirror.classSymbol(Class.forName(className, false, classLoader))
clazz.annotations.exists(_.tpe =:= unv.typeOf[org.apache.spark.annotation.DeveloperApi])
} catch {
case _: Throwable => {
println("Error determining Annotations: " + className)
false
}
}
}

for (className <- classes) {
val directlyPrivateSpark = isPackagePrivate(className)
val developerApi = isDeveloperApi(className)

/* Inner classes defined within a private[spark] class or object are effectively
invisible, so we account for them as package private. */
Expand All @@ -83,9 +97,11 @@ object GenerateMIMAIgnore {
false
}
}
if (directlyPrivateSpark || indirectlyPrivateSpark) privateClasses += className
if (directlyPrivateSpark || indirectlyPrivateSpark || developerApi) {
ignoredClasses += className
}
}
privateClasses.flatMap(c => Seq(c, c.replace("$", "#"))).toSet
ignoredClasses.flatMap(c => Seq(c, c.replace("$", "#"))).toSet
}

def main(args: Array[String]) {
Expand Down