lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Native Policeman (JIRA)" <>
Subject [jira] Commented: (LUCENE-2791) WindowsDirectory
Date Fri, 03 Dec 2010 11:55:11 GMT


Native Policeman commented on LUCENE-2791:

bq. So bottom line: I disagree with you on everything you said.

This was not against you, but I am hacking native Windows since Win32 was started :-)

bq. Yes I do use it, do you understand C ?

I kill you the next time we meet. I am hacking C longer than Java. This was not about C it
was about the MSDN docs telling something different. See my last comment above. Thats all.
Why are you so aggresive?

bq. Exception handling: in native read, you call throwIOException, when ReadFile() returns
false. But 2 lines later you still call the method to copy the local buffer to the java byte
array. JNI docs say, that after an Exception is in the thread's local exception, you should
not call any JNI methods anymore (expect some allowed ones). Also the copy operation is not
really needed.

I don't think you know what you are talking about!

Sorry we seem to have a misunderstanding. I was *not* talking about the internal copy the
JVM does. I was talking about the fact, that you should not call JNI functions anymore when
you set the thread's exception status and exit the function as soon as possible. You set this
status after the failed ReadFile with throwIOEx(). After that its no longer needed to copy
the buffer[] to the java byte array and its risky to do it because I am not sure if this env->SetByteArrayRegion()
is safe to be called after exception status is set - that all I wanted to say. I would change
tha code to:

if (ReadFile((HANDLE) fd, &buffer, length, &numRead, &io)) {
  env->SetByteArrayRegion(bytes, offset, numRead, (const jbyte *) buffer);
} else {
  throwIOException(env, GetLastError());
  numRead = -1;

Please note env->throwNew() always returns, it simply sets the thread's exception status,
so the JVM thorws the Java Exce├╝ption passed in after the native method returns to Java bytecode

Native Policeman

> WindowsDirectory
> ----------------
>                 Key: LUCENE-2791
>                 URL:
>             Project: Lucene - Java
>          Issue Type: New Feature
>          Components: Store
>            Reporter: Robert Muir
>         Attachments: LUCENE-2791.patch, LUCENE-2791.patch, WindowsDirectory.dll, WindowsDirectory_amd64.dll
> We can use Windows' overlapped IO to do pread() and avoid the performance problems of

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message