Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4042208

Single-type import statement not working for separately compiled program units.

    XMLWordPrintable

Details

    • generic
    • solaris_2.5.1

    Description


      allan.jacobs@Eng 1997-03-31

      Compile a program unit containing a public class. Then compile another
      program unit that imports that class. The second compilation will fail,
      complaining that "Only public classes and interfaces in other packages
      can be accessed."
       
      For instance try compiling JCK test lang/BINC/binc006/binc00601/binc00601.html.
      This test requires separate compilation of two program units, binc00601a.java
      and binc00601.java (in that order). The test fails unexpectedly because
      of compilation errors. Below is a recreation of the steps taken by the
      JCK harness in attempting to compile and execute this test.

      algol% pwd
      /home/ajacobs/jit/binc00601
      algol% rm -rf classes
      algol% mkdir classes
      algol% setenv CLASSPATH /set/sqe/java/JCK-11a/classes:/home/ajacobs/jit/binc00601/classes
      algol% ls
      classes/
      algol% cat /set/sqe/java/JCK-11a/tests/lang/BINC/binc006/binc00601/binc00601a.java
      // Ident: @(#)binc00601a.java 1.1 96/10/30
      // Copyright 10/30/96 Sun Microsystems, Inc. All Rights Reserved

      package javasoft.sqe.tests.lang.binc006.binc00601.binc00601b;

      public class binc00601a {
        int a = 5;
      }
          
      algol% grep import /set/sqe/java/JCK-11a/tests/lang/BINC/binc006/binc00601/binc00601.java
      import java.io.PrintStream;
      import javasoft.sqe.tests.lang.binc006.binc00601.binc00601b.binc00601a;
      algol% /usr/java/bin/javac -J-Djava.compiler=none -d /home/ajacobs/jit/binc00601/classes -nowarn /set/sqe/java/JCK-11a/tests/lang/BINC/binc006/binc00601/binc00601a.java
      algol% /usr/java/bin/javac -J-Djava.compiler=none -d /home/ajacobs/jit/binc00601/classes -nowarn /set/sqe/java/JCK-11a/tests/lang/BINC/binc006/binc00601/binc00601.java
      /set/sqe/java/JCK-11a/tests/lang/BINC/binc006/binc00601/binc00601.java:6:
      Can't access class javasoft.sqe.tests.lang.binc006.binc00601.binc00601b.binc00601a.
      Only public classes and interfaces in other packages can be accessed.
      import javasoft.sqe.tests.lang.binc006.binc00601.binc00601b.binc00601a;
             ^
      1 error



      If the program units are compiled together there is no problem.

      algol% /usr/java/bin/javac -J-Djava.compiler=none -d /home/ajacobs/jit/binc00601/classes -nowarn /set/sqe/java/JCK-11a/tests/lang/BINC/binc006/binc00601/binc00601a.java /set/sqe/java/JCK-11a/tests/lang/BINC/binc006/binc00601/binc00601.java
      algol%

      Attachments

        Issue Links

          Activity

            People

              tturnidgsunw Todd Turnidge (Inactive)
              ajacobssunw Allan Jacobs (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: