Menu

#64 Redundant import, same as class name

v1.1
closed-fixed
ejbdoclet (127)
5
2002-03-07
2002-01-21
No

Sample build from Xdoclet-1.1 fails with compilation
error because a redundant import statement is
generated for the current class.

Environment:
JSDK 1.4.0 Beta 3
Ant 1.4.1

See resulting messages below. Sample generated code
attached.

compile-ejbs:
[javac] Compiling 74 source files to
C:\Java\xdoclet-1.1\samples\build\ejb\c
lasses
[javac] C:\Java\xdoclet-1.1\samples\gen-
src\java\test\interfaces\CustomerData.java:11:
test.interfaces.CustomerData is already defined in
this compilation unit
[javac] import test.interfaces.CustomerData;
[javac] ^
[javac] C:\Java\xdoclet-1.1\samples\gen-
src\java\test\interfaces\PersonData.java:11:
test.interfaces.PersonData is already defined in this
compilation unit
[javac] import test.interfaces.PersonData;
[javac] ^
[javac] C:\Java\xdoclet-1.1\samples\gen-
src\java\test\interfaces\CustomerPK.java:12:
test.interfaces.CustomerPK is already defined in this
compilation unit
[javac] import test.interfaces.CustomerPK;
[javac] ^
[javac] C:\Java\xdoclet-1.1\samples\gen-
src\java\test\interfaces\Customer.java:10:
test.interfaces.Customer is already defined in this
compilation unit
[javac] import test.interfaces.Customer;
[javac] ^
[javac] C:\Java\xdoclet-1.1\samples\gen-
src\java\test\interfaces\Person.java:10:
test.interfaces.Person is already defined in this
compilation unit
[javac] import test.interfaces.Person;
[javac] ^
[javac] C:\Java\xdoclet-1.1\samples\gen-
src\java\test\interfaces\AccountData.java:10:
test.interfaces.AccountData is already defined in this
compilation unit
[javac] import test.interfaces.AccountData;
[javac] ^
[javac] C:\Java\xdoclet-1.1\samples\gen-
src\java\test\interfaces\Account.java:9:
test.interfaces.Account is already defined in this
compilation unit
[javac] import test.interfaces.Account;
[javac] ^
[javac] 7 errors

BUILD FAILED

Discussion

  • Ismael Matos

    Ismael Matos - 2002-01-21

    generated file: Account.java

     
  • Vincent Harcq

    Vincent Harcq - 2002-01-21

    Logged In: YES
    user_id=125677

    Have you tried on JDK 1.3 ?

    I already come to this but can not remember how...

    As a quick solution you should add
    import test.interfaces.*;
    instead of
    import test.interfaces.CustomerData;

     
  • Vincent Harcq

    Vincent Harcq - 2002-01-21
    • assigned_to: nobody --> vharcq
     
  • Vincent Harcq

    Vincent Harcq - 2002-01-25

    Logged In: YES
    user_id=125677

    Did this work for you now ?
    Else please provide the ant task that you have too see if I
    can help further

     
  • Ismael Matos

    Ismael Matos - 2002-01-29

    Logged In: YES
    user_id=189690

    I haven't tried JDK1.3. - I don't think it would work
    anyway.

    It seems that the importedList() method in
    xdoclet.tags.ClassTagsHandler is the culprit... There is no
    filter to avoid generating the import for the "current"
    class in the second "for" block of the method.

    I'm including the code here from the source of xdoclet1.1.
    Not sure if this matches with your version.

    public String importedList() throws XDocletException
    {
    ...
    for( int i = 0; i < classes.length; i++ )
    st.append( "import " ).append(
    classes[i].toString() ).append( ";" ).append(
    PrettyPrintWriter.LINE_SEPARATOR );

    return st.toString();
    }

     
  • Vincent Harcq

    Vincent Harcq - 2002-01-30

    Logged In: YES
    user_id=125677

    Hehe,
    I did not have this problem one week ago
    I just updated to 1.4RC
    Now I have the problem
    I guess it is a JDK feature, I post to xdoclet-devel to see
    what we will do but I guess we will have to do sth

     
  • Vincent Harcq

    Vincent Harcq - 2002-02-03

    Logged In: YES
    user_id=125677

    Fixed :)

     
  • Vincent Harcq

    Vincent Harcq - 2002-02-03
    • status: open --> open-fixed
     
  • Andy Stevens

    Andy Stevens - 2002-03-07
    • status: open-fixed --> closed-fixed
     

Log in to post a comment.