Bug 29194

Summary: fails to import package from project
Product: gcc Reporter: Debian GCC Maintainers <debian-gcc>
Component: javaAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal CC: gcc-bugs, java-prs
Priority: P3    
Version: 4.1.2   
Target Milestone: 4.3.0   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2006-09-23 22:33:23
Bug Depends on: 28067    
Bug Blocks:    
Attachments: example

Description Debian GCC Maintainers 2006-09-23 17:18:12 UTC
[forwarded from http://bugs.debian.org/369873]

GCJ fails with 

   Can't find default package 'core'. ... 

when a class source file specifies `import core.*'.   A full example is 
outlined below. 

If you try to compile this `project' like 

  gcj -d . src/Main.java src/core/Foo.java 

the above mentioned error is reported.  The same project works fine
with Sun's or Blackdown's Java compiler. 

Suppose we have the directory structure 

  > find . 
  ./src
  ./src/core
  ./src/core/Foo.java
  ./src/Main.java

with the following contents of `src/Main.java': 

  // commenting out this line makes the classes compile. 
  import core.*;

  public class Main 
  {
      public Main() 
      {
          core.Foo foo = new core.Foo();
          foo.print();
      }
      public static void main(String args[]) 
      {
          Main m = new Main();
      }
  }

and the following contents of `src/core/Foo.java': 

  package core;

  public class Foo 
  {
      public Foo()
      {}
      public void print() 
      {
        System.out.println("Hello, world");
      }
  }
Comment 1 Debian GCC Maintainers 2006-09-23 17:18:48 UTC
Created attachment 12314 [details]
example
Comment 2 Tom Tromey 2006-09-23 22:33:23 UTC
Note that -d doesn't do anything when compiling to object.
However, adding -C doesn't help either.

A simple workaround is to add -Isrc.

This is fixed on the gcj-eclipse branch, I marked this PR as
depending on PR 28067.

Perhaps gcj needs to handle -combine properly.
That would also help fix this, I think.
Comment 3 Tom Tromey 2007-01-09 20:48:51 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.