Re: Generating.proto files from java source file

2009-10-09 Thread grasshopper
I'll try to implement a simple tool to decompile messages, if I succeed, I
post the solution here.
Thank you

On Thu, Oct 8, 2009 at 4:02 PM, Henner Zeller  wrote:

> Hi,
> On Thu, Oct 8, 2009 at 11:51, Kenton Varda  wrote:
> > Hmm, that's true.  Although I'm not sure if there's actual code for
> writing
> > the .proto file in Java.  In C++, descriptors have a DebugString() method
> > which returns a compilable .proto file.
>
> So it would be a matter of either re-implementing the DebugString in
> Java or dumping out the descriptor from the Java code (after all, it
> is just a proto buffer), re-read that and DebugString it.
> (maybe protoc could have a
> 'read-binary-descriptor-and-dump-it-as-protofile' option ;) ).
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@googlegroups.com
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en
-~--~~~~--~~--~--~---



Re: Generating.proto files from java source file

2009-10-08 Thread Henner Zeller

Hi,
On Thu, Oct 8, 2009 at 11:51, Kenton Varda  wrote:
> Hmm, that's true.  Although I'm not sure if there's actual code for writing
> the .proto file in Java.  In C++, descriptors have a DebugString() method
> which returns a compilable .proto file.

So it would be a matter of either re-implementing the DebugString in
Java or dumping out the descriptor from the Java code (after all, it
is just a proto buffer), re-read that and DebugString it.
(maybe protoc could have a
'read-binary-descriptor-and-dump-it-as-protofile' option ;) ).

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@googlegroups.com
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en
-~--~~~~--~~--~--~---



Re: Generating.proto files from java source file

2009-10-08 Thread Kenton Varda
Hmm, that's true.  Although I'm not sure if there's actual code for writing
the .proto file in Java.  In C++, descriptors have a DebugString() method
which returns a compilable .proto file.

On Thu, Oct 8, 2009 at 11:41 AM, Henner Zeller  wrote:

> On Thu, Oct 8, 2009 at 11:32, Kenton Varda  wrote:
> > Yikes.  That's kind of like someone left you with just .class files
> without
> > the .java files.
> > If you look at the code, though, you will notice that there are comments
> in
> > it defining each field, like:
> >   // optional int32 i = 1;
> > These should be the exact field definitions as they might appear in the
> > .proto file.  So if you extract those -- keeping track of which inner
> class
> > each comment appeared in -- you should be able to reproduce the original
> > .proto file.
>
> Shouldn't it be possible to extract the descriptor from the java class
> and then use reflection to emit a proto-file ?
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@googlegroups.com
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en
-~--~~~~--~~--~--~---



Re: Generating.proto files from java source file

2009-10-08 Thread Henner Zeller

On Thu, Oct 8, 2009 at 11:32, Kenton Varda  wrote:
> Yikes.  That's kind of like someone left you with just .class files without
> the .java files.
> If you look at the code, though, you will notice that there are comments in
> it defining each field, like:
>   // optional int32 i = 1;
> These should be the exact field definitions as they might appear in the
> .proto file.  So if you extract those -- keeping track of which inner class
> each comment appeared in -- you should be able to reproduce the original
> .proto file.

Shouldn't it be possible to extract the descriptor from the java class
and then use reflection to emit a proto-file ?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@googlegroups.com
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en
-~--~~~~--~~--~--~---



Re: Generating.proto files from java source file

2009-10-08 Thread Kenton Varda
Yikes.  That's kind of like someone left you with just .class files without
the .java files.
If you look at the code, though, you will notice that there are comments in
it defining each field, like:
  // optional int32 i = 1;

These should be the exact field definitions as they might appear in the
.proto file.  So if you extract those -- keeping track of which inner class
each comment appeared in -- you should be able to reproduce the original
.proto file.

On Thu, Oct 8, 2009 at 6:34 AM, grasshopper  wrote:

> Hi all, a guy that isn't working in my company anymore has defined some
> protocol buffer messages that we still use. We need to extend these messages
> now, but we don't have the .proto file. Is there a straight way to generate
> the proto files from the java classes? How could I do this?
> Thanks
>
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@googlegroups.com
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en
-~--~~~~--~~--~--~---