FIX: Recursive Import Statement Causes J0161 and J0049 Errors

Last reviewed: January 22, 1998
Article ID: Q156920
The information in this article applies to:
  • Microsoft Visual J++ 1.0

SYMPTOMS

Writing a Java program that recursively imports itself results in the following error message:

J0161: Cannot open source file: '.\filename'" and "J0049: Undefined name

'filename'

CAUSE

This error message occurs when the Java compiler recursively opens the Java file until there are too many files open.

WORKAROUND

You should not write programs that recursively import themselves. There is no conditional compilation in Java, and therefore no reason to write a Java file that recursively imports itself.

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. This problem has been fixed in Visual J++ 1.1.

MORE INFORMATION

Steps to Reproduce Behavior

The following code causes the compiler to recursively open the file "recursiveImport.java" until too many files are open and a J0161: Cannot open source file: '.\recursiveImport.java' error message is generated. This is followed with error J0049: Undefined name 'recursiveImport'.

   //recursiveImport.java
   import recursiveImport;

REFERENCES

For the latest Knowledge Base articles and other support information on Visual J++ and the SDK for Java, see the following page on the Microsoft Technical Support site:

   http://support.microsoft.com/support/visualj/
   http://support.microsoft.com/support/java/

Keywords          : CmdLnUtils
Technology        : kbInetDev
Version           : 1.0
Platform          : WINDOWS
Issue type        : kbbug
Solution Type     : kbfix


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: January 22, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.