javaee / jaxb-v2

Other
211 stars 100 forks source link

compilation problem with JAXB2 generated code - import statements #166

Closed glassfishrobot closed 18 years ago

glassfishrobot commented 18 years ago

When I compile the following Jaxb 2.0 generated class in IDE such as Eclipse, it compiles properly; but, when I compile using Ant or javac, it fails. (NOTE: all the tools are using same Jdk).

package pack.FFEL;

.......

import pack.FFEL.PersonResponseType.Birth; import pack.FFEL.PersonResponseType.FinancialData; import pack.FFEL.PersonResponseType.FinancialData.Response; import pack.core.BirthType; import pack.core.IndexType; import pack.core.PersonFinancialDataType; import pack.core.PersonIdentifiersType; import pack.core.ResponseType;

public class PersonResponseType {

protected Birth birth; protected FinancialData financialData;

public static class Birth extends BirthType { }

public static class FinancialData extends PersonFinancialDataType { protected Response response;

public static class Response extends ResponseType { } } }

Error: [javac] PersonResponseType.java:33: cannot find symbol [javac] symbol : class PersonFinancialDataType [javac] location: class pack.FFEL.PersonResponseType [javac] extends PersonFinancialDataType ^

Summary:

Generated class contains import statements in the following order 1) inner classes 2) super classes that these inner classes extend.

This class compiles if I do any of the following.

1) I moved "PersonFinancialDataType" import statement to the top i.e just above inner class imports.

2) Add full package name to "PersonFinancialDataType" at the 'extends' statement, it compiles.

3) Remove import statements for inner classes.

Questions:

1) Why compilation is failing on javac not in IDE.

2) Why can't compiler find 'PersonFinancialDataType' - it is already in import statement.

3) Are there any circular dependencies etc? If so, why doesn't it fail on "BirthType", which is similar to 'PersonFinancialDataType' - I tried changing import/class definition order to get error on "BirthType"; but never got an error on it.

Environment

Operating System: Windows NT Platform: PC URL: https://jaxb.dev.java.net/servlets/ReadMsg?listName=users&msgNo=5377

Affected Versions

[2.0 FCS]

glassfishrobot commented 18 years ago

Reported by anandvallam

glassfishrobot commented 18 years ago

anandvallam said: Created an attachment (id=101) Schemas, customization file and build file for source code generation and compilation

glassfishrobot commented 18 years ago

anandvallam said: Attached a test case

Steps to reproduce:

1) Unzip in to <>\jwsdp-2.0\jaxb-ri\samples OR <>\jwsdp- 2.0\jaxb\samples 2) Run ant 3) Should see compilation errors.

glassfishrobot commented 18 years ago

kohsuke said: I filed 6431987 (should be visible on BugParade) for this.

Meanwhile, I think a work around in the JAXB RI is to avoid importing inner classes. I don't want to always do that because that would make the output uglier, but I'll add an option like "-Xworkaround6431987" so that you can get going in the meantime.

glassfishrobot commented 18 years ago

kohsuke said: The javac team told me that this is indeed a bug in javac, and the current target for this bug fix is Mustang update release 1.

Meanwhile, I added a workaround in JAXB to avoid this problem (by not importing inner classes.) I initially mentioned about adding an option, but decided not to do it. This work around will take effect by default.

glassfishrobot commented 18 years ago

File: CRC.zip Attached By: anandvallam

glassfishrobot commented 18 years ago

Was assigned to jaxb-issues

glassfishrobot commented 7 years ago

This issue was imported from java.net JIRA JAXB-166

glassfishrobot commented 18 years ago

Marked as fixed on Wednesday, May 31st 2006, 2:35:54 am