Bug 12262 - Compiler Bug with import Statement
Summary: Compiler Bug with import Statement
Status: RESOLVED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC All
: P2 normal (vote)
Target Milestone: 2.0 M5   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-03-26 01:23 EST by Ulrich Schreiner CLA
Modified: 2002-04-23 08:48 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ulrich Schreiner CLA 2002-03-26 01:23:18 EST
we have packages like

de.innuendo.util
de.innuendo.auth

but not "de.innuendo" (there is no class in it; the directory exists). when 
writing in eclipse

import de.innuendo.*

everythin compiles. but the jdk1.4 compiler from sun complains 

Test.java:6: package de.innuendo does not exist
 import de.innuendo.*;
 ^
1 error

this problem happens if you delete classes out of a package until the package 
is empty. all of our development is done with eclipse but the daily build uses 
the JDK 1.4 compiler of sun.

so it is a little annoying that eclipse don't notices it as a bug.
Comment 1 Philipe Mulet CLA 2002-03-26 17:48:59 EST
Kent - please double check other vendors behavior.
Comment 2 Kent Johnson CLA 2002-03-27 10:45:25 EST
Take the following example with 2 files a\b\A.java & x\X.java:

A.java

package a.b;
import a.*;
public class A {}

X.java

package x;
import a.*;
public class X {}

a\b\A.java never complains. x\X.java only complains if it is compiled by itself.

How are you compiling your files with javac? All together or one at a time?
Comment 3 Ulrich Schreiner CLA 2002-03-28 06:12:11 EST
its an ant script. try the following:

A.java

package a.b;
import a.*;
public class A {}
====

X.java

package a.c;
public class X {}
====

so X.java is ok, but A.java contains the buggy import. suppose you have both 
package trees in different projects

-client
 +--a
    +--b
       +--A.java

-server
 +--a
    +--c
       +--X.java

now i check out both projects to directory "c:/temp". change to 
directory "c:/temp" and enter

set classpath=
javac client/a/b/*.java server/a/c/*.java

please unset the classpath so that the compiler cannot check any imports 
against the filesystem.

now you get an error from the jdk1.4 compiler. 

i'm not sure that this is a bug in eclipse; it is only a difference to sun's 
compiler. i don't know which is the correct. to be honest: i would prefer the 
javac from jdk1.4 to work like eclipse :^)

if you set the classpath to

set classpath=c:/temp/client;c:/temp/server

everything compiles. so i think the sun compiler is also not consistent. but in 
my script i unset the classpath to be sure not to load old classes.

Comment 4 Kent Johnson CLA 2002-03-28 14:31:02 EST
The Eclipse compiler is always consistent (the example results I gave 
previously were with javac)... only javac reports errors sometimes depending on 
what it can find with:

javac client/a/b/*.java server/a/c/*.java

We believe the package 'a' exists because we're compiling a type defined in 
package a.b or a.c. Javac only seems to think it exists when it can find it on 
its classpath. Try this from inside the client directory:

javac a/b/*.java ../server/a/c/*.java

javac did not complain.

To ensure you don't pick up other classes, why not tell javac to put the class 
files somewhere else using the -d option? Then you could set a normal class 
path.

Or use the batch version of the Eclipse compiler instead of javac all 
together. ;)
Comment 5 Ulrich Schreiner CLA 2002-03-29 07:03:43 EST
nice idea to use the eclipse compiler. but our sources are part of a product 
which is bundled as sourcecode. the customer can and will compile it. so it 
should compile with jdk1.4.

the easiest workaround is to remove the buggy import statement. it would be 
nice to get a notify from the eclipse compiler. but we realize this behaviour 
with our daily build which is made with jdk1.4.

btw: i use the "-d" option of javac in our ant script. 
Comment 6 Kent Johnson CLA 2002-04-01 11:00:56 EST
Yes the easiest workaround is to remove the import but I'm missing why you 
cannot set the classpath in your ant script.
Comment 7 Ulrich Schreiner CLA 2002-04-02 01:01:30 EST
- i set the CP only to libraries which i need for my product but not to my own 
classes (compile time). this does not make sense at compile time.

- i cannot optimize the build process for our company if our customers have 
another process which uses jdk1.4 and they have problems. 

- our customers use different IDE's for java development and our sources have 
to compile in every IDE especially when this ide uses the standard javac.

but for me its ok now: now i know that i have to do a daily build with the 
jdk1.4 to minimize such compatibility problems.
Comment 8 Kent Johnson CLA 2002-04-10 16:12:57 EDT
We're not going to change our behaviour to match javac for this case.

Until they clarify the spec or add a JCK test that covers this case, we going 
to leave our behaviour as is.