Circular package import problem

3,269 views
Skip to first unread message

Ken

unread,
Feb 7, 2011, 4:42:23 AM2/7/11
to Protocol Buffers
Hi,

I have two proto files: A.proto and B.proto. If I import package B in
A and import A in B, I got StackOverFlow exception during compiling.
Does anyone know any sulotion for it?

Thanks,

Ken

Pherl Liu

unread,
Feb 7, 2011, 1:26:50 PM2/7/11
to Ken, Protocol Buffers
You probably need to break up your proto files to eliminate the circular dependency.. (i.e. have multiple .proto files for a package, and only import necessary .proto files).


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


Kenton Varda

unread,
Feb 7, 2011, 5:36:44 PM2/7/11
to Pherl Liu, Ken, Protocol Buffers
With protoc (the standard compiler), this should produce a simple error.  Since Ken said he "got StackOverFlow exception", it sounds like he's using some other compiler (not written in C++).

Ken

unread,
Feb 8, 2011, 7:04:49 AM2/8/11
to Protocol Buffers
I am using protostuff-maven-plugin 1.0.0.M7. Currently I have to put
all classes into one big proto file. multiple .proto files can't avoid
cross referencing

On Feb 7, 10:36 pm, Kenton Varda <ken...@google.com> wrote:
> With protoc (the standard compiler), this should produce a simple error.
>  Since Ken said he "got StackOverFlow exception", it sounds like he's using
> some other compiler (not written in C++).
>
> On Mon, Feb 7, 2011 at 10:26 AM, Pherl Liu <liuj...@google.com> wrote:
> > You probably need to break up your proto files to eliminate the circular
> > dependency.. (i.e. have multiple .proto files for a package, and only import
> > necessary .proto files).
>

David Yu

unread,
Feb 8, 2011, 7:09:49 AM2/8/11
to Ken, Protocol Buffers
On Tue, Feb 8, 2011 at 8:04 PM, Ken <ke.la...@gmail.com> wrote:
I am using protostuff-maven-plugin 1.0.0.M7. Currently I have to put
all classes into one big proto file. multiple .proto files can't avoid
cross referencing
You're posting in the wrong googlegroups :-) 
Might wanna file a bug report on the googlecode issue tracker of protostuff.



--
When the cat is away, the mouse is alone.
- David Yu

David Yu

unread,
Feb 8, 2011, 7:14:56 AM2/8/11
to Kenton Varda, Pherl Liu, Ken, Protocol Buffers
On Tue, Feb 8, 2011 at 6:36 AM, Kenton Varda <ken...@google.com> wrote:
With protoc (the standard compiler), this should produce a simple error.  Since Ken said he "got StackOverFlow exception", it sounds like he's using some other compiler (not written in C++).
Hmm, so protoc doesn't handle cyclic imports as well. 
Are there plans to support it in the near future? 



--

Kenton Varda

unread,
Feb 22, 2011, 1:29:33 PM2/22/11
to David Yu, Pherl Liu, Ken, Protocol Buffers
On Tue, Feb 8, 2011 at 4:14 AM, David Yu <david....@gmail.com> wrote:
Hmm, so protoc doesn't handle cyclic imports as well. 
Are there plans to support it in the near future? 

No, cyclic imports are not likely to be supported.  Many programming languages do not support them, so supporting them in .proto would make it hard to support those languages.  Not to mention, handling cyclic dependencies just between declarations in a single .proto file is already ridiculously complicated.

David Yu

unread,
Feb 22, 2011, 5:06:08 PM2/22/11
to Kenton Varda, Pherl Liu, Ken, Protocol Buffers
On Wed, Feb 23, 2011 at 2:29 AM, Kenton Varda <ken...@google.com> wrote:
On Tue, Feb 8, 2011 at 4:14 AM, David Yu <david....@gmail.com> wrote:
Hmm, so protoc doesn't handle cyclic imports as well. 
Are there plans to support it in the near future? 

No, cyclic imports are not likely to be supported.  Many programming languages do not support them, so supporting them in .proto would make it hard to support those languages.  
Makes sense.  Thanks! 
Not to mention, handling cyclic dependencies just between declarations in a single .proto file is already ridiculously complicated.
Reply all
Reply to author
Forward
0 new messages