user2887053
user2887053

Reputation: 103

Convert protoc generated java files to .proto

I have a .java file created by protoc from a .proto file.

The .proto file no longer exists, is there an existing tool to recreate it from the generated .java file?

Upvotes: 0

Views: 845

Answers (1)

Carl Mastrangelo
Carl Mastrangelo

Reputation: 6628

In the bottom of the file, you should see a field called descriptorData which includes the original descriptor of the proto. You cannot directly turn this back into a proto file, but it does contain all the information about how to parse the proto.

If you were so inclined, the format of this data is itself a proto, representing a descriptor.proto. You can parse this data yourself and reconstruct it, though I don't think there are any tools to do so automatically.

Upvotes: 1

Related Questions