JDK-4190157 : using "Con" as a class name causes a problem (reserved filename in Win32)
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 1.1.6,5.0,6
  • Priority: P5
  • Status: Closed
  • Resolution: Won't Fix
  • OS: generic,windows_nt,windows_xp
  • CPU: generic,x86
  • Submitted: 1998-11-16
  • Updated: 2024-10-09
  • Resolved: 2020-06-12
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Description
Name: tb29552			Date: 11/16/98


/*

This might be known already. But I couldn't find in the
bug search.  If one use the word "Con" as a name for a
class, the JDK compiler produces the byte code, and
dumps to the screen, instead of creating a file
"Con.class".  Appearantly, it misinterprets the class
name as Console or something.

*/
class Con {
    public static void outputMessage() {
	System.out.println("java.version                  = " +
			   System.getProperty("java.version"));
	System.out.println("Operating System Name         = " +
			   System.getProperty("os.name"));
	System.out.println("Operating system architecture = " +
			   System.getProperty("os.arch"));
	System.out.println("Operating system version      = " +
			   System.getProperty("os.version") + "\n");
    }

    public static void main(String[] args) {
	outputMessage();
    }
}

(Review ID: 42799)
======================================================================

Comments
EVALUATION See 6241975 for a list of bad possible names.
24-09-2009

EVALUATION bug 6176051 has been fixed. Should check if the class file is a valid writable file before writing it, and fail gracefully if not.
08-12-2006

EVALUATION After bug 6176051 has been fixed in Mustang, the compiler should now be able to handle this situation gracefully.
03-02-2006

WORK AROUND Name: tb29552 Date: 11/16/98 Don't use the word "Con". ======================================================================
11-06-2004

EVALUATION I recall that there is special meaning for Con on win32 systems. For Con.class as well? I don't know. Passing this on... todd.turnidge@Eng 1998-12-01 CON, LPT, NUL, and several others are reserved pathnames in win32. Presumably, the compiler should know about these and escape them, though I am unhappy with the idea that the compiler should know anything about the platform it is running on -- it *should* be the canonical 100% pure Java program. Again, this shows the need for a platform-independent filesystem, or a means to query its capabilities in an abstract way. See also 4307912. Unlike the case with that bug, however, adopting a "lowest common denominator" approach, always escaping these names on all platforms, is not so unpalatable. william.maddox@Eng 2000-02-02
02-02-2000