THRIFT-716. java: Field names can conflict with local variables in code for unions

This patch resolves the name clash issue by removing the unnecessary parameters from the generated method and using the protected variables directly instead.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@917130 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/cpp/src/generate/t_java_generator.cc b/compiler/cpp/src/generate/t_java_generator.cc
index 949d062..e28a214 100644
--- a/compiler/cpp/src/generate/t_java_generator.cc
+++ b/compiler/cpp/src/generate/t_java_generator.cc
@@ -915,11 +915,11 @@
 
 void t_java_generator::generate_write_value(ofstream& out, t_struct* tstruct) {
   indent(out) << "@Override" << endl;
-  indent(out) << "protected void writeValue(TProtocol oprot, _Fields setField, Object value) throws TException {" << endl;
+  indent(out) << "protected void writeValue(TProtocol oprot) throws TException {" << endl;
 
   indent_up();
 
-  indent(out) << "switch (setField) {" << endl;
+  indent(out) << "switch (setField_) {" << endl;
   indent_up();
 
   const vector<t_field*>& members = tstruct->get_members();
@@ -931,14 +931,14 @@
     indent(out) << "case " << constant_name(field->get_name()) << ":" << endl;
     indent_up();
     indent(out) << type_name(field->get_type(), true, false) << " " << field->get_name() 
-      << " = (" <<  type_name(field->get_type(), true, false) << ")getFieldValue();" << endl;
+      << " = (" <<  type_name(field->get_type(), true, false) << ")value_;" << endl;
     generate_serialize_field(out, field, "");
     indent(out) << "return;" << endl;
     indent_down();
   }
   
   indent(out) << "default:" << endl;
-  indent(out) << "  throw new IllegalStateException(\"Cannot write union with unknown field \" + setField);" << endl;
+  indent(out) << "  throw new IllegalStateException(\"Cannot write union with unknown field \" + setField_);" << endl;
 
   indent_down();
   indent(out) << "}" << endl;
diff --git a/lib/java/src/org/apache/thrift/TUnion.java b/lib/java/src/org/apache/thrift/TUnion.java
index 625b00d..cc3c069 100644
--- a/lib/java/src/org/apache/thrift/TUnion.java
+++ b/lib/java/src/org/apache/thrift/TUnion.java
@@ -163,7 +163,7 @@
     }
     oprot.writeStructBegin(getStructDesc());
     oprot.writeFieldBegin(getFieldDesc(setField_));
-    writeValue(oprot, setField_, value_);
+    writeValue(oprot);
     oprot.writeFieldEnd();
     oprot.writeFieldStop();
     oprot.writeStructEnd();
@@ -185,7 +185,7 @@
    */
   protected abstract Object readValue(TProtocol iprot, TField field) throws TException;
 
-  protected abstract void writeValue(TProtocol oprot, F setField, Object value) throws TException;
+  protected abstract void writeValue(TProtocol oprot) throws TException;
 
   protected abstract TStruct getStructDesc();