Open jiangdequan opened 6 years ago
Can you please provide a pull request ? And possibly include a unit test as well that clearly shows the abnormal behavior ?
It occured when I add property 'org.exolab.castor.builder.automaticConflictResolution=true' to resolve class name conflict.The following is the error log:
Caused by: java.lang.IllegalArgumentException: 'WwwYourOrgTestSpace}NameSurname' is not a valid Java identifier.
at org.exolab.javasource.JStructure.<init>(JStructure.java:109)
at org.exolab.javasource.AbstractJClass.<init>(AbstractJClass.java:78)
at org.exolab.javasource.AbstractJClass.<init>(AbstractJClass.java:69)
at org.exolab.javasource.JClass.<init>(JClass.java:59)
at org.exolab.castor.builder.descriptors.DescriptorJClass.<init>(DescriptorJClass.java:92)
at org.exolab.castor.builder.descriptors.DescriptorSourceFactory.createSource(DescriptorSourceFactory.java:112)
at org.exolab.castor.builder.SingleClassGenerator.processClassDescriptor(SingleClassGenerator.java:390)
at org.exolab.castor.builder.SingleClassGenerator.process(SingleClassGenerator.java:370)
at org.exolab.castor.builder.SingleClassGenerator.process(SingleClassGenerator.java:310)
at org.exolab.castor.builder.SourceGenerator.createClasses(SourceGenerator.java:933)
at org.exolab.castor.builder.SourceGenerator.processContentModel(SourceGenerator.java:1078)
at org.exolab.castor.builder.SourceGenerator.processContentModel(SourceGenerator.java:1081)
at org.exolab.castor.builder.SourceGenerator.processComplexType(SourceGenerator.java:1019)
at org.exolab.castor.builder.SourceGenerator.createClasses(SourceGenerator.java:939)
at org.exolab.castor.builder.SourceGenerator.generateAllClassFiles(SourceGenerator.java:786)
at org.exolab.castor.builder.SourceGenerator.generateSource(SourceGenerator.java:744)
at org.exolab.castor.builder.SourceGenerator.generateSource(SourceGenerator.java:690)
at org.exolab.castor.builder.SourceGenerator.generateSource(SourceGenerator.java:587)
Due to the development environment, I commited several times, but the last one 'a57c621' is useful.
There is a problem about the classname! In the model castor-codegen of org.exolab.castor.builder.conflict.strategy.BaseClassNameConflictResolver.calculateXPathPrefix, in some cases, when the input is like '/Voucher{http://www.your.org/Test/Space}/Name/Surname', but the output is 'WwwYourOrgTestSpace}NameSurname'.This is not a valid java identifier.
the source code below split the input string words, but not remove the invalid identifier in model castor-xml(org.castor.xml.JavaNamingImpl)
fix: add some code to remove "}" in model castor-xml(org.castor.xml.JavaNamingImpl)