Name: rmT116609 Date: 05/06/2004
FULL PRODUCT VERSION :
java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)
java version "1.5.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b32c)
Java HotSpot(TM) Client VM (build 1.5.0-beta-b32c, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
When i ty to create some file names with windows reserved words.It wont report any exception and program flow goes as if it created the file.
If i run the below code snippet it neither created the file LPT1.txt nor it thorwed exception to putput.
it prints the statement "created the file name LPT1" as if it created.
String windowreservedWords[] ={"LPT1.txt","CON.txt","COM1.txt")
try{
File file=new File(windowreservedWords[0]);
file.createNewFile();
if(file.exists()){
System.out.println("created File name"+windowreservedWords[0]);
}
}catch(IOException ioe){
e.printStackTrace();
}
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and run the test case provided.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
It must throw IOException
ACTUAL -
does nothing.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.io.*;
class Test {
public static void main(String args[]) {
String windowreservedWords[] ={"LPT1.txt","CON.txt","COM1.txt"};
try{
File file=new File(windowreservedWords[0]);
file.createNewFile();
if(file.exists()){
System.out.println("created File name"+windowreservedWords[0]);
}
}catch(IOException ioe){
ioe.printStackTrace();
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Provide method in the System class to get all reserved words in the OS and restrict it which will be helpful for other checks too.
(Incident Review ID: 261243)
======================================================================
###@###.### 10/8/04 19:21 GMT