fairyhawk / protostuff

Automatically exported from code.google.com/p/protostuff
Apache License 2.0
0 stars 0 forks source link

Use FQCN everywhere in classes generated by java_v2protoc_schema #70

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Because proto messages can have any arbitrary names, there should be no 
implicit importing of the classes from outside the proto outer class. All 
references to String, Integer, Class etc. should be prepended with full 
"java.lang." package name. All references to com.dyuproject.protostuff.* 
classes and interfaces must be via FQCN. Same with java.io.IOException.

The following proto file results in a non-compilable code generated by 
java_v2protoc_schema compiler:

message Message {
    message String {
    }
    required String string = 1;
}
message Schema {}
message Class {}
message Integer {}
message Input {}
message Output {}

Original issue reported on code.google.com by sergei.s...@gmail.com on 30 Jun 2011 at 10:20

GoogleCodeExporter commented 8 years ago
If you can submit a patch, I'll gladly apply it.
Cheers

Original comment by david.yu...@gmail.com on 30 Jun 2011 at 10:28

GoogleCodeExporter commented 8 years ago
Attached is a patch that replaces all class name references with FQCNs (in a 
rather paranoid fashion).

It still does not fix the problem of using protoc keywords as variable names, 
as in:

message Message {
    message String {
    }
    required String string = 1;
    required bool required = 2;
}

protoc happily compiles the above, but it looks like protostuff parser can't 
handle it.

Original comment by sergei.s...@gmail.com on 3 Jul 2011 at 10:40

Attachments:

GoogleCodeExporter commented 8 years ago
Patch applied.  Thanks.
I've also added the fix that allows protobuf keywords to be used as variable 
names.
Let me know if you still have trouble compiling the example you posted above.

Cheers

Original comment by david.yu...@gmail.com on 4 Jul 2011 at 5:38