History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: CASTOR-1917
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Werner Guttmann
Reporter: Simon Lord
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
castor

Source generator does not fail on unresolved element types instead it sets them as java.lang.Object

Created: 22/Mar/07 09:44 AM   Updated: 14/Mar/08 06:40 AM
Component/s: XML code generator
Affects Version/s: 1.1
Fix Version/s: 1.2

Time Tracking:
Original Estimate: Not Specified
Remaining Estimate: 0 minutes
Time Spent - 30 minutes
Time Spent: 30 minutes
Time Spent - 30 minutes

File Attachments: 1. Text File patch.c1917.20070323.txt (3 kb)
2. Text File patch.c1917.20070330.txt (5 kb)
3. Text File patch.c1917.20080110.txt (6 kb)
4. Zip Archive srcgen-bug.zip (32 kb)


Testcase included: yes


 Description  « Hide
In the previous version of castor i was using (0.9.5) if you had an element with a type that did not exist in the schema then the source generation would fail but with 1.1 it simply makes the type a java.lang.Object and procedes happily.

using the following schema (note that there is no declaration of type 'blahblahblah'):

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:simpleType name="HOST">
<xs:restriction base="xs:string"/>
</xs:simpleType>
<xs:simpleType name="ID">
<xs:restriction base="xs:string"/>
</xs:simpleType>
<xs:simpleType name="PASSWORD">
<xs:restriction base="xs:string"/>
</xs:simpleType>
<xs:complexType name="FLOWER">
<xs:sequence>
<xs:element name="HOST" type="HOST"/>
<xs:element name="ID" type="blahblahblah" />
<xs:element name="PASSWORD" type="PASSWORD"/>
</xs:sequence>
</xs:complexType>
</xs:schema>

with castor 0.9.x you get the following error:

[javac] FLOWER.java:47: cannot find symbol
[javac] symbol : class ID
[javac] location: package mypackage.common
[javac] private mypacakge.common.ID _ID;
[javac] ^

but with castor 1.1 it happily builds the source setting the property 'ID' to a java.lang.Object in the source file.

attached is the bug template where i've only touched files in srcgen-bug.zip\bugs\xml\srcgen\template\ (i replaced the schema, and added some settings to the SourceGenerator object.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Werner Guttmann - 23/Mar/07 04:13 AM
It looks like this is related to an oldish (BugZilla) bug with the number of 1471, where the following code is executed within MemberFactory.createFieldInfo() is the xsType is null.

if (xsType == null) {
//-- patch for bug 1471 (No XMLType specified)
//-- treat unspecified type as anyType
switch (component.getAnnotated().getStructureType()) { case Structure.ATTRIBUTE: case Structure.ELEMENT: xsType = new XSClass(SGTypes.OBJECT); break; default: // probably a model-group break; }
}

Which makes me wonder why we get that far at all .. .


Werner Guttmann - 23/Mar/07 05:27 AM
I think that it should be easy to provide a patch that restores old (pre-1.0) behaviour, but somehow I think that an exception should be thrown instead to indicate that there's a type reference that cannot be resolved.

Simon Lord - 23/Mar/07 06:39 AM
I agree - and it would make debugging easier if an exception was thrown that indicated that there's a type reference that cannot be resolved.

Werner Guttmann - 23/Mar/07 08:32 AM
Initial patch for reviw, working around the 'java.lang.Object' problem, returning to uncompilable code for such unresolvable type references.

Werner Guttmann - 29/Mar/07 10:45 AM
Before I can commit this patch, there's a few issues related to two or three broken CTF tests that need to sorted. In addition, I need a way to make a generation-only test as failing.

Werner Guttmann - 30/Mar/07 04:33 AM
Final patch for review.

Werner Guttmann - 10/Jan/08 07:57 AM
Simon, can I ask you to create a follow-up issue for the change with regards to exception handling. I'd like to make this patch available to restore things to pre-1.0 mode for the upcoming 1.2 release.

Werner Guttmann - 10/Jan/08 08:01 AM
Updated patch, replacing all other patches attached.