Bug 123003 - The import ... conflicts with a type defined in the same file
Summary: The import ... conflicts with a type defined in the same file
Status: RESOLVED WORKSFORME
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.5.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-01-07 09:41 EST by Wang Bin CLA
Modified: 2006-02-15 03:50 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Wang Bin CLA 2006-01-07 09:41:49 EST
I defined aspect named MyAspect in package debug
If I import a java class named a.b.c.MyAspect, then the compiler tells me that "The import a.b.cMyAspect conflicts with a type defined in the same file"
Comment 1 Adrian Colyer CLA 2006-01-09 04:33:17 EST
this definitely needs investigating for the 1.5.1 point release.
Comment 2 Andrew Clement CLA 2006-01-09 06:45:23 EST
this is working as designed.  See the JVM language spec 7.5.1:

"If another top level type with the same simple name is otherwise declared in the current compilation unit except by a 'type-import-on-demand' declaration then a compile-time error occurs.

So the sample program:
  import java.util.Vector;
  class Vector { Object[] vec; }
causes a compile time error."

so I have recreated this error using some aspects, then I recreated it using some standard classes and ajc then I recreated it with javac too:

===
package debug;

import a.b.c.MyAspect;

public class MyAspect {
}

===
package a.b.c;

public class  MyAspect {
}
===

C:\>ajc  debug\MyAspect.java a\b\c\MyAspect.java
debug\MyAspect.java:3 [error] The import a.b.c.MyAspect conflicts with a type defined in the same file
import a.b.c.MyAspect;
       ^^^^^^^^^^^^^

1 error


C:\>javac  debug\MyAspect.java a\b\c\MyAspect.java
debug\MyAspect.java:3: debug.MyAspect is already defined in this compilation unit
import a.b.c.MyAspect;
^
1 error


Comment 3 Andrew Clement CLA 2006-02-15 03:50:43 EST
nothing to fix.