JDK-4650921 : compilation error using classes in default package with classes in package struc
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 1.4.0
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86
  • Submitted: 2002-03-11
  • Updated: 2002-03-11
  • Resolved: 2002-03-11
Related Reports
Duplicate :  
Description

Name: rmT116609			Date: 03/11/2002


FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)


FULL OPERATING SYSTEM VERSION : Red Hat Linux 7.1 (kernel 2.4.3-12) (glibc - glibc-2.2.2-10)


A DESCRIPTION OF THE PROBLEM :
I've two classes. One class is without package structure and other one is with package structure. Now if I try to compile the class with package structure and this class has a reference to class without package structure, I'm not
able to compile the class with package structure. I am NOT able to use "import <classname>" as I was able to do with previous version. And the class without package structure is in differenct directory and I cannot use the above
import statement I'm getting compile time error saying that "cannot resolve symbol" (I've correct CLASSPATH settings and java/class files are in appropriate dir).

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1.copy the B.java file(without package) to a /tmp directory
2. javac B.java
3.copy the Test.java file(with package) to /tmp directory
4. javac -d . Test.java

EXPECTED VERSUS ACTUAL BEHAVIOR :
compiled Test.class file in /tmp/com/hamilsci/Test.class

ERROR MESSAGES/STACK TRACES THAT OCCUR :
Test.java:7: cannot resolve symbol
symbol  : class B
location: class com.hamilsci.Test
        B lb = new B();
        ^
Test.java:7: cannot resolve symbol
symbol  : class B
location: class com.hamilsci.Test
        B lb = new B();


This bug can be reproduced always.

The problem is reproducible on Windows 2000, Solaris 2.8, Linux Redhat 7.1(Seawolf) using JDK1.4.0.

---------- BEGIN SOURCE ----------
//The directory structure is /tmp/com/hamilsci. Also CLASSPATH setting is
//correct.

//Class B is in /tmp directory and without package structure
public class B {
    public B() {
    }
}


//Class Test uses B and the java file is in /tmp directory

package com.hamilsci;
//import B; //This was allowed in previous JDK version 1.3.1

public class Test {
    public Test() {
        B lb = new B();
    }
    public static void main(String arg[]) {
        new Test();
    }
}

---------- END SOURCE ----------
(Review ID: 144027) 
======================================================================