This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

SWT fileviewer fixes (PR=java/9253, PR=java/9254)


Hi,

I have attached fixes for the File problem (PR=java/9253) and something that
might get around the threads problem (PR=java/9254)... these sit over the top
the MingW patch.

The File problem is actually quite simple and is to do with windows behavior
not being what you'd expect as every drive can have it's own current directory
(which is what was being incorrectly returned). I have tested this fix and it
seems to work fine.

The other problem is a bit harder as I haven't been able to find a convincing
fix in the Win32 API, but looking at the code for "object.wait()" it seems that
the stuff below should work and will at least be better than what is there
now... However "WaitForMultipleObjects" can only cope with 64 threads which may
be an issue for some people (or maybe just a windows limitation, I dunno).

I haven't had a chance to test the thread code with the SWT stuff yet.

I wasn't sure if I should send these to the patches mailing list or here, but
as the threads one isn't all that tested I thought I'd post it here.

Cheers
JohnM


--- libjava/java/io/natFileWin32.cc
+++ libjava/java/io/natFileWin32.cc
@@ -103,6 +103,14 @@
 java::io::File::getCanonicalPath (void)
 {
-  char *buf = (char *) __builtin_alloca (JvGetStringUTFLength (path) + 1);
+  char *buf = (char *) __builtin_alloca (JvGetStringUTFLength (path) + 3);
   jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
+
+  // On windows if the filename ends with ":" it is a drive, to retain the
+  // standard java behaviour we have to add "\." to the end.
+  if (total > 0 && buf[total-1] == ':')
+  {
+    buf[total++] = '\\';
+    buf[total++] = '.';
+  }
   buf[total] = '\0';
 
--- libjava/win32-threads.cc
+++ libjava/win32-threads.cc
@@ -112,6 +112,9 @@
   _Jv_MutexLock (mu);
 
-  if (rval == WAIT_FAILED) return GetLastError();
-  else if (rval == WAIT_TIMEOUT) return ETIMEDOUT;
+  // The only error that java.lang.Object.wait() seems to care about is
+  // interrupted, so if an error occurs the wait is "interrupted"
+  if (rval == WAIT_FAILED) return _JV_INTERRUPTED;
+  // A timeout is fine as long as it wasn't caused by an interrupt
+  // else if (rval == WAIT_TIMEOUT) return ETIMEDOUT;
   else return 0;
 }



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]