0

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?

user2887053
  • 103
  • 1
  • 2
  • 8

1 Answers1

1

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.

Carl Mastrangelo
  • 5,970
  • 1
  • 28
  • 37