-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-1820][tools] Make GenerateMimaIgnore @DeveloperApi annotation aware. #845
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
Closed
Closed
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f495620
(SPARK-1820) Make GenerateMimaIgnore @DeveloperApi annotation aware
6a7201b
[SPARK-1820] Make GenerateMimaIgnore @DeveloperApi annotation aware
8fa02d2
[SPARK-1820] Make GenerateMimaIgnore @DeveloperApi annotation aware
4810471
[SPARK-1820] Make GenerateMimaIgnore @DeveloperApi annotation aware.
b735a78
[SPARK-1820] Make GenerateMimaIgnore @DeveloperApi annotation aware.
0516ee2
[SPARK-1820] Make GenerateMimaIgnore @DeveloperApi annotation aware.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,8 @@ 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} | ||
| import scala.reflect._ | ||
|
|
||
| /** | ||
| * A tool for generating classes to be excluded during binary checking with MIMA. It is expected | ||
|
|
@@ -69,9 +71,25 @@ object GenerateMIMAIgnore { | |
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
| def classesAnnotationCheck(className: String) = { | ||
| try { | ||
| val annotList=mirror | ||
| .classSymbol(Class.forName(className, false, classLoader)) | ||
| .annotations | ||
|
|
||
| isAnnotationExistClassLevel(annotList) | ||
| } catch { | ||
| case _: Throwable => { | ||
| println("Error determining Annotations: " + className) | ||
| false | ||
| } | ||
| } | ||
| } | ||
|
|
||
| for (className <- classes) { | ||
| val directlyPrivateSpark = isPackagePrivate(className) | ||
| val annotationCheck = classesAnnotationCheck(className) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be better to call this something like |
||
|
|
||
| /* Inner classes defined within a private[spark] class or object are effectively | ||
| invisible, so we account for them as package private. */ | ||
|
|
@@ -83,7 +101,8 @@ object GenerateMIMAIgnore { | |
| false | ||
| } | ||
| } | ||
| if (directlyPrivateSpark || indirectlyPrivateSpark) privateClasses += className | ||
|
|
||
| if (directlyPrivateSpark || indirectlyPrivateSpark || annotationCheck) privateClasses += className | ||
| } | ||
| privateClasses.flatMap(c => Seq(c, c.replace("$", "#"))).toSet | ||
| } | ||
|
|
@@ -93,7 +112,10 @@ object GenerateMIMAIgnore { | |
| writeAll(classesPrivateWithin("org.apache.spark").mkString("\n")) | ||
| println("Created : .mima-excludes in current directory.") | ||
| } | ||
|
|
||
|
|
||
| private def isAnnotationExistClassLevel(annotList: List[unv.Annotation]): Boolean = { | ||
| annotList.exists(_.tpe =:= unv.typeOf[org.apache.spark.annotation.DeveloperApi]) | ||
| } | ||
|
|
||
| private def shouldExclude(name: String) = { | ||
| // Heuristic to remove JVM classes that do not correspond to user-facing classes in Scala | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could use some formatting and naming cleanup - the indentation is weird. Also, it might be better to inline
isAnnotationExistClassLevelrather than having its own function.What about this?