title: Unable to pass the spark developer code check, encountered binary compatibility error
body: <p>I'm a new spark contributor. I want to add class weight support for the random forest classifier, which is described here: <a href="https://issues.apache.org/jira/browse/SPARK-9478" rel="nofollow">https://issues.apache.org/jira/browse/SPARK-9478</a></p>
  
  <p>I've finished the function implementation and I'm following the code contributing instructions here : <a href="https://cwiki.apache.org/confluence/display/SPARK/Contributing+to+Spark#ContributingtoSpark-PreparingtoContributeCodeChanges" rel="nofollow">https://cwiki.apache.org/confluence/display/SPARK/Contributing+to+Spark#ContributingtoSpark-PreparingtoContributeCodeChanges</a></p>
  
  <p>In the instructions, it says 'Run all tests with ./dev/run-tests to verify that the code still compiles, passes tests, and passes style checks'. When I was running the test, my code cannot pass the binary compatibility check. </p>
  
  <p>The log says:</p>
  
  <pre><code>[error]  * method this(scala.Enumeration#Value,org.apache.spark.mllib.tree.impurity.Impurity,Int,Int,Int,scala.Enumeration#Value,scala.collection.immutable.Map,Int,Double,Int,Double,Boolean,Int)Unit 
  in class org.apache.spark.mllib.tree.configuration.Strategy does not have a correspondent in current version
  [error]    filter with: ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.spark.mllib.tree.configuration.Strategy.this")
  </code></pre>
  
  <p>I changed the file "org.apache.spark.mllib.tree.configuration.Strategy" because I need to change the interface of this class. What I did is adding a new input parameter like this:</p>
  
  <pre><code>    class Strategy @Since("1.3.0") (
      @Since("1.0.0") @BeanProperty var algo: Algo,
      @Since("1.0.0") @BeanProperty var impurity: Impurity,
      @Since("1.0.0") @BeanProperty var maxDepth: Int,
      @Since("1.2.0") @BeanProperty var numClasses: Int = 2,
      @Since("1.0.0") @BeanProperty var maxBins: Int = 32,
      @Since("1.0.0") @BeanProperty var quantileCalculationStrategy: QuantileStrategy = Sort,
      @Since("1.0.0") @BeanProperty var categoricalFeaturesInfo: Map[Int, Int] = Map[Int, Int](),
      @Since("1.2.0") @BeanProperty var minInstancesPerNode: Int = 1,
      @Since("1.2.0") @BeanProperty var minInfoGain: Double = 0.0,
      @Since("1.0.0") @BeanProperty var maxMemoryInMB: Int = 256,
      @Since("1.2.0") @BeanProperty var subsamplingRate: Double = 1,
      @Since("1.2.0") @BeanProperty var useNodeIdCache: Boolean = false,
  -    @Since("1.2.0") @BeanProperty var checkpointInterval: Int = 10) extends Serializable {
  +    @Since("1.2.0") @BeanProperty var checkpointInterval: Int = 10,
  +    @Since("2.0.0") @BeanProperty var classWeights: Array[Double] = Array(1, 1))
  </code></pre>
  
  <p>How can I fix this issue or what is the direction to debug?</p>
  
  <p>--------------------------------  An update  ------------------------------</p>
  
  <p>I'm not one of the authors who have made a pull request for this problem in the JIRA. I have a new implementation which needs less memory to achieve the same goal. My code can be found here: <a href="https://github.com/n-triple-a/spark" rel="nofollow">https://github.com/n-triple-a/spark</a> and the branch 'weightedRandomForest' has the problem mentioned above. </p>
  
  <p>I can currently solve this problem by adding a constructor in the <strong>Strategy</strong> class having the first 13 params(or without the <strong>classWeights</strong> in the argument list) like this:</p>
  
  <pre><code>    this(var algo: Algo,
        impurity: Impurity,
        maxDepth: Int,
        numClasses: Int,
        maxBins: Int,
        quantileCalculationStrategy: QuantileStrategy,
        categoricalFeaturesInfo: Map[Int, Int],
        minInstancesPerNode: Int,
        minInfoGain: Double,
        maxMemoryInMB: Int,
        subsamplingRate: Double,
        useNodeIdCache: Boolean,
        checkpointInterval: Int) {
      this(algo, impurity, maxDepth, numClasses, maxBins, 
           quantileCalculationStrategy, categoricalFeaturesInfo, minInstancesPerNode,
           minInfoGain, maxMemoryInMB, subsamplingRate, useNodeIdCache, 
           checkpointInterval, Array(1.0, 1.0))
      }
  </code></pre>
  
  <p>I also changed the scalastyle's definition on the maximum number of arguments allowed for a function, which is 10 by default. But it is weird to me because there is a default value binding to the <strong>classWeights</strong>. Why do I have to add a redundant constructor?</p>