JDK-4807099 : File.exists() fails with relative paths after user.dir is modified
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 1.4.1
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2003-01-23
  • Updated: 2003-01-25
  • Resolved: 2003-01-25
Related Reports
Duplicate :  
Description

Name: rmT116609			Date: 01/23/2003


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


FULL OPERATING SYSTEM VERSION : Windows 2000 Server


A DESCRIPTION OF THE PROBLEM :
File.exists() fails with relative paths if user.dir is set
to a directory other than the current directory of the JVM
process.

Win32FileSystem.getBooleanAttributes(File f) is called
without previously resolving the file within the user.dir.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
see example

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.io.File;

public class Show
{
 public static void main(String[] p_args)
 {
  File   l_file;
  String l_strAbsolutePath;
  // ? a directory containing subdirectory subdir with file ping.txt
  // that is not the current directory of the process
  System.setProperty("user.dir", "?");
  l_file = new File("subdir", "ping.txt");
  l_strAbsolutePath = l_file.getAbsolutePath();
  System.out.println("This should be true but is " + l_file.exists());
  System.out.println("This should be true and is " + (new File
(l_strAbsolutePath)).exists());
 }
}

---------- END SOURCE ----------


(Review ID: 180301) 
======================================================================