Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proto 工程疑问 #139

Open
zhanghuaizheng opened this issue Dec 11, 2024 · 4 comments
Open

proto 工程疑问 #139

zhanghuaizheng opened this issue Dec 11, 2024 · 4 comments

Comments

@zhanghuaizheng
Copy link

请问一下就是我看在网络 接入netty 序列化反序列 读取的时候 都是用的反射字段的 自定义处理来处理的 ,那生成 协议java文件时 对应read() 和 write()是什么时候用的呢?
网络读取反序列化如图:
image

@jaysunxiao
Copy link
Contributor

image

image

生成协议走得是 CodeGenerateJava.

另外反序列化和序列号最终会使用字节码增强,运行时不会用到反射。

@jaysunxiao
Copy link
Contributor

com/zfoo/protocol/generate/GenerateTesting.java

所有的协议文件生成都可以在test测试用例找到,可以断点看看

@zhanghuaizheng
Copy link
Author

image
image

image
你的意思是 最终 tcpServer 调用的是你增强后的 自动生成的protocol 文件里的read 方法吗?并不是下图的 read方法
image

@jaysunxiao
Copy link
Contributor

是这样的,可以断点看看。也可以在xml协议中指定要不字节码增强,enhance = false就可以使用反射序列化的方式。

使用注解也可以 @protocol(id = 1118, enhance = false)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants