Bug 10894 - Wildcard import statements not resolved
Summary: Wildcard import statements not resolved
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: java (show other bugs)
Version: 3.3
: P3 normal
Target Milestone: 4.3.0
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
: 27280 (view as bug list)
Depends on: 28067
Blocks:
  Show dependency treegraph
 
Reported: 2003-05-21 03:46 UTC by jbrandmeyer
Modified: 2007-01-09 20:45 UTC (History)
6 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-06-22 00:20:23


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Pinski 2003-05-20 23:50:23 UTC
From: Andrew Pinski <pinskia@physics.uc.edu>
To: jbrandmeyer@users.sourceforge.net
Cc: Andrew Pinski <pinskia@physics.uc.edu>, gcc-gnats@gcc.gnu.org,
   "Gcc-Bugs@Gcc. Gnu. Org" <gcc-bugs@gcc.gnu.org>
Subject: Re: java/10894: Valid import statements are rejected.
Date: Tue, 20 May 2003 23:50:23 -0400

 Looks like your CLASSPATH environment is set to something that does not 
 include the gcj's classes.
 
 Thanks,
 Andrew Pinski
 
 On Tuesday, May 20, 2003, at 23:37 US/Eastern, 
 jbrandmeyer@users.sourceforge.net wrote:
 
 >
 > Test.java:1: error: Can't find default package `java.lang.Math'. Check
 > the CLASSPATH environment variable and the access to the archives
 

Comment 1 jbrandmeyer 2003-05-21 00:29:28 UTC
From: Jonathan Brandmeyer <jbrandmeyer@earthlink.net>
To: Andrew Pinski <pinskia@physics.uc.edu>
Cc: gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org
Subject: Re: java/10894: Valid import statements are rejected.
Date: 21 May 2003 00:29:28 -0400

 Not true.  As posted in the gcj -v output, those classes are on the
 CLASSPATH.  In fact, commenting out the offending line 'solves' the
 problem.  Here it is again:
 
 jonathan@illuvatar:~/workspace/HelloWorld/116csc/2Lab$ gcj -v -C
 Test.java
 Reading specs from /usr/lib/gcc-lib/i386-linux/3.3/specs
 Configured with: ../src/configure -v
 --enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr
 --mandir=/usr/share/man --infodir=/usr/share/info
 --with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared
 --with-system-zlib --enable-nls --without-included-gettext
 --enable-__cxa_atexit --enable-clocale=gnu --enable-debug
 --enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gc
 i386-linux
 Thread model: posix
 gcc version 3.3 (Debian)
  /usr/lib/gcc-lib/i386-linux/3.3/jc1 Test.java -quiet -dumpbase
 Test.java -auxbase-strip NONE -g1 -version -fsyntax-only
 -femit-class-files -o /dev/null
 GNU Java version 3.3 (Debian) (i386-linux)
         compiled by GNU C version 3.3 (Debian).
 GGC heuristics: --param ggc-min-expand=55 --param ggc-min-heapsize=48342
 Class path starts here:
     ./
     /usr/share/java/repository/
     /usr/share/java/libgcj-3.3.jar/ (system) (zip)
 Test.java:1: error: Can't find default package `java.lang.Math'. Check
 the CLASSPATH environment variable and the access to the archives
 1 error
 
 -Jonathan
 
 On Tue, 2003-05-20 at 23:50, Andrew Pinski wrote:
 > Looks like your CLASSPATH environment is set to something that does not 
 > include the gcj's classes.
 > 
 > Thanks,
 > Andrew Pinski
 > 
 > On Tuesday, May 20, 2003, at 23:37 US/Eastern, 
 > jbrandmeyer@users.sourceforge.net wrote:
 > 
 > >
 > > Test.java:1: error: Can't find default package `java.lang.Math'. Check
 > > the CLASSPATH environment variable and the access to the archives
 > 
 

Comment 2 Andrew Pinski 2003-05-21 00:40:47 UTC
From: Andrew Pinski <pinskia@physics.uc.edu>
To: jbrandmeyer@users.sourceforge.net
Cc: Andrew Pinski <pinskia@physics.uc.edu>, gcc-gnats@gcc.gnu.org,
   gcc-bugs@gcc.gnu.org
Subject: Re: java/10894: Valid import statements are rejected.
Date: Wed, 21 May 2003 00:40:47 -0400

 You are right I should have read that link, I have not kept up with 
 Java (at least the language) since 1.0.2 and since class inside classes 
 is new for 1.1 I did not know that import was extended also.
 
 Thanks,
 Andrew Pinski
 
 On Wednesday, May 21, 2003, at 00:29 US/Eastern, Jonathan Brandmeyer 
 wrote:
 
 > Not true.  As posted in the gcj -v output, those classes are on the
 > CLASSPATH.  In fact, commenting out the offending line 'solves' the
 > problem.  Here it is again:
 >
 > jonathan@illuvatar:~/workspace/HelloWorld/116csc/2Lab$ gcj -v -C
 > Test.java
 > Reading specs from /usr/lib/gcc-lib/i386-linux/3.3/specs
 > Configured with: ../src/configure -v
 > --enable-languages=c,c++,java,f77,pascal,objc,ada,treelang 
 > --prefix=/usr
 > --mandir=/usr/share/man --infodir=/usr/share/info
 > --with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared
 > --with-system-zlib --enable-nls --without-included-gettext
 > --enable-__cxa_atexit --enable-clocale=gnu --enable-debug
 > --enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gc
 > i386-linux
 > Thread model: posix
 > gcc version 3.3 (Debian)
 >  /usr/lib/gcc-lib/i386-linux/3.3/jc1 Test.java -quiet -dumpbase
 > Test.java -auxbase-strip NONE -g1 -version -fsyntax-only
 > -femit-class-files -o /dev/null
 > GNU Java version 3.3 (Debian) (i386-linux)
 >         compiled by GNU C version 3.3 (Debian).
 > GGC heuristics: --param ggc-min-expand=55 --param 
 > ggc-min-heapsize=48342
 > Class path starts here:
 >     ./
 >     /usr/share/java/repository/
 >     /usr/share/java/libgcj-3.3.jar/ (system) (zip)
 > Test.java:1: error: Can't find default package `java.lang.Math'. Check
 > the CLASSPATH environment variable and the access to the archives
 > 1 error
 >
 > -Jonathan
 >
 > On Tue, 2003-05-20 at 23:50, Andrew Pinski wrote:
 >> Looks like your CLASSPATH environment is set to something that does 
 >> not
 >> include the gcj's classes.
 >>
 >> Thanks,
 >> Andrew Pinski
 >>
 >> On Tuesday, May 20, 2003, at 23:37 US/Eastern,
 >> jbrandmeyer@users.sourceforge.net wrote:
 >>
 >>>
 >>> Test.java:1: error: Can't find default package `java.lang.Math'. 
 >>> Check
 >>> the CLASSPATH environment variable and the access to the archives
 >>
 >
 >
 >
Comment 3 jbrandmeyer 2003-05-21 03:46:01 UTC
The following code fails to compile, but is valid according to the public Sun Java specs, section 7.5.2 as found at http://java.sun.com/docs/books/jls/second_edition/html/packages.doc.html

"import java.lang.Math.*" in any compilation unit fails with this output:
/usr/lib/gcc-lib/i386-linux/3.3/jc1 Test.java -quiet -dumpbase
Test.java -auxbase-strip NONE -g1 -version -fsyntax-only
-femit-class-files -o /dev/null
GNU Java version 3.3 (Debian) (i386-linux)
        compiled by GNU C version 3.3 (Debian).
GGC heuristics: --param ggc-min-expand=55 --param ggc-min-heapsize=48342
Class path starts here:
    ./
    /usr/share/java/repository/
    /usr/share/java/libgcj-3.3.jar/ (system) (zip)
Test.java:1: error: Can't find default package `java.lang.Math'. Check
the CLASSPATH environment variable and the access to the archives
1 error

Release:
3.3

Environment:
Debian Sid, x86:
Reading specs from /usr/lib/gcc-lib/i386-linux/3.3/specs
Reading specs from /usr/lib/gcc-lib/i386-linux/3.3/../../../libgcj.spec
rename spec lib to liborig
Configured with: ../src/configure -v --enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --enable-__cxa_atexit --enable-clocale=gnu --enable-debug --enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gc i386-linux
Thread model: posix
gcc version 3.3 (Debian)

How-To-Repeat:
import java.lang.Math.*;

public class Test {
	public static void main( String[] args) {
		System.out.println( "this is a test");
	}
}

Compile with "gcj -v -C Test.java"
Comment 4 jbrandmeyer 2003-05-21 03:46:01 UTC
Fix:
Don't use statements of the form "import java.lang".anything.  They are superfluous.
Comment 5 Andrew Pinski 2003-05-27 23:07:43 UTC
I had confirmed this before getting bug access.
Comment 6 Daniel Naab 2004-03-26 02:51:51 UTC
Was there any resolution to this or possible workarounds?  I'm encountering a 
very similar problem except it's happening with my own packages.  Oddly, it 
only happens with imports using a wildcard, such as:

import mypackage.*;

The code is valid and I'm building using the Ant GCJ support.  No issues 
building with javac.

Thanks,
Dan
Comment 7 Phil Shaw 2004-12-22 18:06:00 UTC
Also affects GCJ 3.3.3 (cygwin special). Can I suggest the summary is changed to 
"Wildcard import statements not resolved", which seems more specific to me and 
may avoid duplicate submissions.

This test case implements an interface, but the same applies extending an 
abstract or concrete class, it's the import statement that is the problem:

-- WildcardImport.java

package com.example.bug;

import com.example.other.*;

public class WildcardImport implements Interfacer {

    // Empty
}

-- Interfacer.java

package com.example.other;

public interface Interfacer {

    // Empty
}

This is with commands like:

gcj -C -d /build @gcj-src.txt
Comment 8 jbrandmeyer 2004-12-22 23:40:39 UTC
Yes, that is much more specific.
Comment 9 Andrew Pinski 2006-04-26 02:44:24 UTC
*** Bug 27280 has been marked as a duplicate of this bug. ***
Comment 10 Tom Tromey 2007-01-09 20:45:28 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.
Thanks.