Thilo Goetz wrote:
Philip Ogren wrote:
If you create a type with the name 'Feature' you get compile errors
because of a namespace conflict with the Feature interface. I think
this could be easily fixed by simply removing the import statement in
the generated code and explicitly providing the fully qualified name for
the Feature interface when referenced (e.g. 'org.apache.uima.cas.Feature').
Please advise me if I am submitting this to the wrong list.
Thanks,
Philip
I think your suggestion is a good one. We'll get similar errors when
somebody creates types with names like "FeatureStructure" or "Type".
Marshall, what do you think?
The JCasGen code already has a test to check for "reserved" Feature
names. These are typically names that are part of the FeatureStructure
interface, starting with get or set. For instance, there is a getType()
- so if you had a feature named "Type", this would conflict.
The easy fix for this case would be as you suggested: to replace all
refs to Feature in the generated code with the fully qualified name, and
remove the import. The downside is that this would make the generated
code more un-readable (not that anyone reads it :-).
If we did this for other imported things: JCas, JCasRegistry, CASImpl,
FSGenerator, FeatureStructure, TypeImpl,
Type, FeatureImpl, Annotation_Type, it might make the code look quite
hard to read.
A more complex fix could be to only do this if the defined type was a
conflicting name, and then only for that type.
Perhaps you can take a look at the JCasGen code and propose a patch?
-Marshall