You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What is the expected output?
Generated code compiles successfully.
What do you see instead?
Compile error.
Test.java:25: as of release 5, 'enum' is a keyword, and may not be used as an identifier
(use -source 1.4 or lower to use 'enum' as an identifier)
private List<String> enum = new ArrayList<String>();
What version of the product are you using?
0.3.1
On what Java version?
java version "1.6.0_30"
Adding this code before returning from (PropertyRule.getPropertyName(PropertyRule.java:158)) resolves the issue:
if( javax.lang.model.SourceVersion.isKeyword(nodeName) ){
nodeName = "__" + nodeName;
}
From [email protected] on July 26, 2012 21:26:55
I've gone with appending an underscore for a couple of reasons:
It doesn't look as strange as a $ when reading the source. $ is generally associated with inner classes and confusing Java inter-op code from other languages.
It's not as intrusive as pre-pending when reading the source, e.g.
It's possible to avoid changing the method names but not currently practical. Since this is very much an edge case I'm happy with appending the underscore.
Thanks again for raising this John, there are many small areas where the plugin isn't as robust as it should be and this was a good one to fix.
Original author: [email protected] (July 16, 2012 19:02:55)
What steps will reproduce the problem?
{
"id" : "test",
"type" : "object",
"additionalProperties" : false,
"properties" : {
"name" : {
"type": "string"
},
"enum" : {
"type" : "array",
"default" : [],
"items" : { "type" : "string" }
}
}
}
2.Compile Generated java code.
What is the expected output?
Generated code compiles successfully.
What do you see instead?
Compile error.
Test.java:25: as of release 5, 'enum' is a keyword, and may not be used as an identifier
(use -source 1.4 or lower to use 'enum' as an identifier)
private List<String> enum = new ArrayList<String>();
What version of the product are you using?
0.3.1
On what Java version?
java version "1.6.0_30"
Adding this code before returning from (PropertyRule.getPropertyName(PropertyRule.java:158)) resolves the issue:
if( javax.lang.model.SourceVersion.isKeyword(nodeName) ){
nodeName = "__" + nodeName;
}
Original issue: http://code.google.com/p/jsonschema2pojo/issues/detail?id=63
The text was updated successfully, but these errors were encountered: