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

Win32 only: recursive function call causes crash

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      1.0beta2
    • CPU:
      x86
    • OS:
      windows_nt
    • Verification:
      Verified

      Description

      Win32 only: recursive function call with stream object causes crash in Win95, and
      runtime error R6018 - unexpected heap error in WinNT. Using 30-Nov-95 build.


      Steps to reproduce
      Compile the attached code
      run java FilesTest -home c:\\java (or any other directory on your system)

      // note: it will crash in the fourth or fifth directory

      import java.io.*;

      public class FilesTest
      {
          // class variables
          private String javaHome;
          private String logFile;

          public static void main(String args[])
          {
             // local variables
             FilesTest ft = new FilesTest();
             ft.init(args);

          }

          public void init(String args[])
          {
             // local variables
             int i;
             DataOutputStream oStream;

             // parse arguments
             for (i = 0; i < args.length ; ++i)
             {
                if ( args[i].equals("-home") )
                   javaHome = args[++i];
                else if ( args[i].equals("-log") )
                   logFile = args[++i];
                          
             }

             // check javaHome
             if (javaHome == null)
                javaHome = "/usr/local/java/latestJDK";

             // check logFile
             if (logFile == null)
                logFile = "files.list";

             try
             {
                oStream = new DataOutputStream( new FileOutputStream(logFile) );
                File dir = new File(javaHome);
                listFiles(dir, oStream);
             }
             catch(Exception e)
             {
                System.out.println(e.getMessage());
             }
          }

          public void listFiles(File dir, DataOutputStream oStream)
             throws IOException
          {

             // local variables
             String relativeName;
             String fileList[] = dir.list();
             int i;

             System.out.println("Working on dir: " + dir.getName());

             // loop through directory
             for (i = 0; i < fileList.length; ++i)
             {
                File fn = new File(dir, fileList[i]);
                if ( fn.isDirectory() )
                   listFiles(fn, oStream);
                else
                {
                   // need to get the substring of fn.getAbsolutePath()
                   relativeName = fn.getAbsolutePath().substring(javaHome.length());
                   oStream.writeBytes(relativeName +
                                      "\\t" +
                                      Long.toString( fn.length() )+
                                      "\\n");
                }
             }
                    
             
          }
          
      }

        Attachments

          Activity

            People

            Assignee:
            dconnellsunw David Connelly (Inactive)
            Reporter:
            kasmithsunw Kevin Smith (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: