You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Jens Geyer (JIRA)" <ji...@apache.org> on 2016/02/26 20:54:18 UTC
[jira] [Commented] (THRIFT-3674) Java generated deep copy is
shallow
[ https://issues.apache.org/jira/browse/THRIFT-3674?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15169663#comment-15169663 ]
Jens Geyer commented on THRIFT-3674:
------------------------------------
Duplicates day! Could that be a duplicate of THRIFT-3377?
> Java generated deep copy is shallow
> -----------------------------------
>
> Key: THRIFT-3674
> URL: https://issues.apache.org/jira/browse/THRIFT-3674
> Project: Thrift
> Issue Type: Bug
> Components: Java - Compiler
> Affects Versions: 0.9.2
> Reporter: Mykhailo Kozik
>
> Minimum reproducible scenario
> I have an IDL called test.thrift
> {code}
> struct A {
> 1: required B b;
> }
> struct B {
> 1: required string id;
> }
> {code}
> Then I generate java file
> {code}
> thrift -gen java -out src/main/java/gen src/main/resources/test.thrift
> {code}
> Generated object for A contains method called deepCopy, which is calling copy constructor, which is actually just shallow copy (copy references)
> {code}
> class A {
> //...
> public A(A other) {
> if (other.isSetB()) {
> this.b = other.b;
> }
> }
> public A deepCopy() {
> return new A(this);
> }
> //...
> }
> {code}
> Instead of copying references we need copy deepCopy recursively.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)