title: Kotlin data class copy function not working when called from java class
body: <p>Maybe I'm misinterpreting how the <code>copy</code> function of a <code>data</code> class works or maybe there's a bug, but the following is an example of the <code>copy</code> function not working as expected:</p>
  
  <p>Kotlin:</p>
  
  <pre><code>data class A {
      public var x: String? = null
      public var y: String? = null
      public var z: B = B.ONE
  }
  
  enum class B {
      ONE
      TWO
      THREE
  }
  </code></pre>
  
  <p>Java</p>
  
  <pre><code>A a1 = new A()
  a1.setX("Hello")
  a1.setY("World")
  a1.setZ(B.TWO)
  
  A a2 = a1.copy()
  // a2.x is null
  // a2.y is null
  // a2.z is B.ONE
  </code></pre>
  
  <p>It seems that <code>copy</code> is just making a new instance of <code>A</code> and not copying the values. If I put the variables in the constructor, the values are assigned, but then it's no different than constructing a new instance.</p>