You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fury.apache.org by "LouisLou2 (via GitHub)" <gi...@apache.org> on 2025/01/20 09:40:54 UTC

[I] Are furygo and furyJava not compatible? [fury]

LouisLou2 opened a new issue, #2014:
URL: https://github.com/apache/fury/issues/2014

   ### Search before asking
   
   - [x] I had searched in the [issues](https://github.com/apache/fury/issues) and found no similar issues.
   
   
   ### Version
   
   I'm using XLANG mode on both ends, but go still doesn't deserialize java serialized objects correctly!
   
   
   ### Component(s)
   
   Go
   
   ### Minimal reproduce step
   
   here is my trail. and please Let me know if I'm making some kind of cheap mistake.
   
   ## My First Trial
   
   **java**
   ```java
   public class Main {
     public static void main(String[] args) {
       Fury fury = Fury.builder()
         .withLanguage(Language.XLANG)
         .withRefTracking(true)
         .build();
   
       Map<String, Double> map = new HashMap<>();
       map.put("key", 1.0);
       map.put("key2", 2.0);
       byte [] bytes = fury.serialize(map);
   
       // save to file
       try (FileOutputStream fos = new FileOutputStream("sample_map.fury")) {
         fos.write(bytes);
       } catch (IOException e) {
         e.printStackTrace();
       }
     }
   }
   ```
   
   **go**
   ```go
   func deserialize() {
   	bytes, err := os.ReadFile("./res/sample_map.fury")
   	if err != nil {
   		fmt.Println("Error reading file:", err)
   		return
   	}
   	fury := fury2.NewFury(true)
   	var newValue interface{}
   	if err := fury.Unmarshal(bytes, &newValue); err != nil {
   		panic(err)
   	}
   	fmt.Println(newValue)
   }
   ```
   
   The result is that bytes can be successfully deserialized in java but gives a strange error in go.
   
   **go console**
   ```
   GOROOT=/usr/lib/go-1.22 #gosetup
   GOPATH=/home/leo/go #gosetup
   /usr/lib/go-1.22/bin/go build -o /home/leo/.cache/JetBrains/GoLand2024.3/tmp/GoLand/___go_build_github_com_apache_fury_go_fury_main github.com/apache/fury/go/fury/main #gosetup
   /home/leo/.cache/JetBrains/GoLand2024.3/tmp/GoLand/___go_build_github_com_apache_fury_go_fury_main #gosetup
   panic: type of id 50 not supported, supported types: map[1:bool 2:uint8 3:int8 5:int16 7:int32 9:int64 11:float32 12:float64 13:string 14:[]uint8 16:fury.Date 18:time.Time 25:[]interface {} 30:map[interface {}]interface {} 257:fury.GenericSet 258:[]bool 259:[]int16 260:[]int32 261:[]int64 262:[]float32 263:[]float64 264:[]string]
   
   goroutine 1 [running]:
   main.deserialize()
   	/home/leo/projects/furygo/main/main.go:54 +0x185
   main.main()
   	/home/leo/projects/furygo/main/main.go:37 +0xf
   
   Process finished with the exit code 2
   ```
   
   ## Second Trial
   
   Next I went to discover the difference in the logic of the deserialization code between the two.
   
   And then realized that in the go code there is one more part than in the java
   
   **go**
   ```go
   buf.ReadInt32() // nativeObjectsStartOffset
   nativeObjectsSize := buf.ReadInt32()
   if f.peerLanguage == GO {
   	if nativeObjectsSize > 0 {
   		return fmt.Errorf("native serialization for golang is not supported currently")
   	}
   }
   return f.ReadReferencable(buf, reflect.ValueOf(v).Elem())
   ```
   
   **java**
   ```java
   obj = xreadRef(buffer);
   ```
   
   I tried commenting out the code that reads an additional 4+4=8 bytes and then re-running the go code, however, a new error occurs
   
   ```bash
   GOROOT=/usr/lib/go-1.22 #gosetup
   GOPATH=/home/leo/go #gosetup
   /usr/lib/go-1.22/bin/go build -o /home/leo/.cache/JetBrains/GoLand2024.3/tmp/GoLand/___go_build_github_com_apache_fury_go_fury_main github.com/apache/fury/go/fury/main #gosetup
   /home/leo/.cache/JetBrains/GoLand2024.3/tmp/GoLand/___go_build_github_com_apache_fury_go_fury_main #gosetup
   panic: type of id 29 not supported, supported types: map[1:bool 2:uint8 3:int8 5:int16 7:int32 9:int64 11:float32 12:float64 13:string 14:[]uint8 16:fury.Date 18:time.Time 25:[]interface {} 30:map[interface {}]interface {} 257:fury.GenericSet 258:[]bool 259:[]int16 260:[]int32 261:[]int64 262:[]float32 263:[]float64 264:[]string]
   
   goroutine 1 [running]:
   main.deserialize()
   	/home/leo/projects/furygo/main/main.go:54 +0x185
   main.main()
   	/home/leo/projects/furygo/main/main.go:37 +0xf
   
   Process finished with the exit code 2
   ```
   
   I can roughly see that it's a type mismatch error, and then I went and compared the type id declared in furygo's `type.go` with the definition in the guide([xlang_type_mapping](https://fury.apache.org/docs/guide/xlang_type_mapping)), and there seems to be some discrepancies, and I'm a little confused about these conflicts, or am I using it incorrectly?
   
   ### What did you expect to see?
   
   furygo deserialized object successfully
   
   ### What did you see instead?
   
   unsupported type error
   
   ### Anything Else?
   
   _No response_
   
   ### Are you willing to submit a PR?
   
   - [ ] I'm willing to submit a PR!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fury.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fury.apache.org
For additional commands, e-mail: commits-help@fury.apache.org


Re: [I] Are furygo and furyJava not compatible? [fury]

Posted by "pandalee99 (via GitHub)" <gi...@apache.org>.
pandalee99 closed issue #2014: Are furygo and furyJava not compatible?
URL: https://github.com/apache/fury/issues/2014


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fury.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fury.apache.org
For additional commands, e-mail: commits-help@fury.apache.org


Re: [I] Are furygo and furyJava not compatible? [fury]

Posted by "pandalee99 (via GitHub)" <gi...@apache.org>.
pandalee99 closed issue #2014: Are furygo and furyJava not compatible?
URL: https://github.com/apache/fury/issues/2014


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fury.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fury.apache.org
For additional commands, e-mail: commits-help@fury.apache.org


Re: [I] Are furygo and furyJava not compatible? [fury]

Posted by "chaokunyang (via GitHub)" <gi...@apache.org>.
chaokunyang commented on issue #2014:
URL: https://github.com/apache/fury/issues/2014#issuecomment-2602712375

   Hi @LouisLou2 , which fury java version are you using? We are refactoring the xlang serialization spec. The first part of Fury java has been finished in #1690 , but the golang implementation has not be finished. Is this related to your issue?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fury.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fury.apache.org
For additional commands, e-mail: commits-help@fury.apache.org