Bug 18175

Summary: Can't find default package with redundant package import
Product: gcc Reporter: Phil Shaw <phil>
Component: javaAssignee: Not yet assigned to anyone <unassigned>
Severity: normal CC: gcc-bugs, java-prs
Priority: P2 Keywords: rejects-valid
Version: 3.3.3   
Target Milestone: 4.3.0   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2005-07-23 05:59:24
Bug Depends on: 6818, 28067    
Bug Blocks:    

Description Phil Shaw 2004-10-27 12:06:13 UTC
The following class will not compile with GCJ version 3.3.3 (cygwin special), 
succeeds with Sun javac. The workaround is obvious, but not always easy with 
other people's code.

$ gcj -classpath . -C Test.java
Test.java:3: error: Can't find default package `com.example'. Check the CLASSPAT
H environment variable and the access to the archives
1 error

-- Test.java

package com.example;

import com.example.*;

class Test {


-- End Test.java
Comment 1 Andrew Pinski 2004-10-27 13:05:28 UTC
Confirmed.  Almost certain that is related to (or even the same bug as) PR 6818.
Comment 2 Ranjit Mathew 2004-10-27 13:37:47 UTC
Andrew, did you try it with the current mainline? I don't see this bug any more
at all. IMHO, this should be closed.
Comment 3 Andrew Pinski 2004-10-27 13:41:27 UTC
I used "gcc version 4.0.0 20041026 (experimental)"
Comment 4 Ranjit Mathew 2004-10-27 14:08:39 UTC
Weird! I don't see this error at all (i686-pc-linux-gnu) with
the current mainline:
-------------------------- 8< --------------------------
~/src/tmp/r1 > cat com/example/Test.java
package com.example;
import com.example.*;
class Test { }

~/src/tmp/r1 > $MYGCJ -classpath . -C com/example/Test.java

~/src/tmp/r1 > $MYGCJ --version
gcj (GCC) 4.0.0 20041027 (experimental)
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
-------------------------- 8< --------------------------

MYGCJ is a variable defined in such a way that I can use
the GCJ built from CVS without having to actually install

~/src/tmp/r1 > echo $MYGCJ
/home/ranmath/src/gcc/build/gcc/gcj -B/home/ranmath/src/gcc/build/gcc/ -B/home/r
anmath/src/gcc/build/i686-pc-linux-gnu/libjava/ -I/home/ranmath/src/gcc/build/i6
86-pc-linux-gnu/libjava/libgcj-4.0.0.jar -L/home/ranmath/src/gcc/build/i686-pc-l

But I don't think that should affect the outcome.
Comment 5 Andrew Pinski 2004-10-27 14:13:23 UTC
Note you compiling with the full path to the package/java source where the problem comes into play.
If you compile with just gcj -c Test.java, it fails.
Comment 6 Ranjit Mathew 2004-10-27 14:15:00 UTC
Oh! I see.

In that case, I do not see the error with JDK 1.4.2_03 
(Linux), but I do see it with GCJ (mainline, Linux). So
yeah, it is sort of a bug.

But note that it is still not quite the same as PR6818.

The workaround is to compile from the folder containing
"com/example" as is the norm in Java programming.
Comment 7 CVS Commits 2005-08-22 16:21:36 UTC
Subject: Bug 18175

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	pinskia@gcc.gnu.org	2005-08-22 16:21:19

Modified files:
	gcc            : ChangeLog c-common.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.dg: switch-warn-3.c 

Log message:
	2005-08-22  Andrew Pinski  <pinskia@physics.uc.edu>
	PR c/18715
	* c-common.c (c_do_switch_warnings): Look for a node where the enum's
	value is inbetween the range if we did not find an exact match.
	2005-08-22  Andrew Pinski  <pinskia@physics.uc.edu>
	PR c/18175
	* gcc.dg/switch-warn-3.c: New test.


Comment 8 Andrew Pinski 2005-08-22 16:23:59 UTC
Ignore that commit, I got 7 and 1 switched around.
Comment 9 Tom Tromey 2007-01-09 20:46:38 UTC
All gcj front end bugs have been fixed by the gcj-eclipse branch merge.
I'm mass-closing the affected PRs.
If you believe one of these was closed in error, please reopen it
with a note explaining why.