title: Java Spark Dataset autogen compile exception
body: <p>I'm running into issues with Java Spark Dataset's groupByKey method. The following code, when run locally in a test environment (Spark 2.1.0, spark-core_2.11, spark-sql_2.11), throws the following exception:</p>
  
  <p><code>java.lang.Exception: failed to compile: org.codehaus.commons.compiler.CompileException: File 'generated.java', Line 43, Column 21: No applicable constructor/method found for zero actual parameters; candidates are: "public int org.package.example.ExampleTest$1ExampleClass.getX()</code></p>
  
  <p>Code is:</p>
  
  <pre><code>    class ExampleClass implements Serializable {
          private int x;
          private int y;
          public ExampleClass() {}
          public ExampleClass(int x, int y) {this.x = x; this.y = y;}
  
          public int getX() {return x;}
  
          public void setX(int x) {
              this.x = x;
          }
  
          public int getY() {
              return y;
          }
  
          public void setY(int y) {
              this.y = y;
          }
  
          @Override
          public boolean equals(Object o) {
              if (this == o) return true;
              if (o == null || getClass() != o.getClass()) return false;
  
              ExampleClass that = (ExampleClass) o;
  
              if (x != that.x) return false;
              return y == that.y;
          }
  
          @Override
          public int hashCode() {
              int result = x;
              result = 31 * result + y;
              return result;
          }
      }
      ExampleClass exampleClass1 = new ExampleClass(1, 1);
      ExampleClass exampleClass2 = new ExampleClass(1, 2);
      ExampleClass exampleClass3 = new ExampleClass(1, 3);
  
      List&lt;ExampleClass&gt; exampleClasses = Lists.newArrayList(
              exampleClass1,
              exampleClass2,
              exampleClass3
      );
  
      Dataset&lt;ExampleClass&gt; dataset = spark.createDataset(exampleClasses, Encoders.bean(ExampleClass.class));
  
      KeyValueGroupedDataset&lt;Integer, ExampleClass&gt; grouped = dataset.groupByKey(
              (MapFunction&lt;ExampleClass, Integer&gt;) ExampleClass::getX,
              Encoders.INT()
      );
  }
  </code></pre>
  
  <p>It looks like it can't find the default parameter-less constructor, or I'm leaving something out. Also interesting, if I change the ints to boxed Integers, it says the candidate is getY() not getX().</p>
  
  <p>Any help is much appreciated!</p>
  
  <p>EDIT: After messing around with it some more, moving <code>ExampleClass</code> out of a nested class in my test and into its own file fixes the problem. I still don't know why though so any answers are still appreciated.</p>