You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by hi...@apache.org on 2010/09/24 00:21:52 UTC
svn commit: r1000648 - in /harmony/enhanced/java/branches/java6: ./
classlib/ classlib/depends/libs/ classlib/modules/luni/src/main/java/java/io/
classlib/modules/luni/src/main/native/luni/shared/
classlib/modules/luni/src/main/native/luni/unix/ classl...
Author: hindessm
Date: Thu Sep 23 22:21:51 2010
New Revision: 1000648
URL: http://svn.apache.org/viewvc?rev=1000648&view=rev
Log:
Merge change from /harmony/enhanced/java/trunk@1000005:
r1000005 | tellison | 2010-09-22 15:49:04 +0100 (Wed, 22 Sep 2010) | 2 lines
Apply patch for HARMONY-6642 ([classlib][luni] FileInputStream doesn't close FD in native code)
Modified:
harmony/enhanced/java/branches/java6/ (props changed)
harmony/enhanced/java/branches/java6/classlib/ (props changed)
harmony/enhanced/java/branches/java6/classlib/depends/libs/ (props changed)
harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/io/FileDescriptor.java
harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/io/FileInputStream.java
harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/io/FileOutputStream.java
harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/native/luni/shared/filedesc.c
harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/native/luni/unix/exports.txt
harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/native/luni/unix/helpers.c
harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/native/luni/unix/helpers.h
harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/native/luni/windows/helpers.c
harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/native/luni/windows/helpers.h
harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileInputStreamTest.java
harmony/enhanced/java/branches/java6/drlvm/ (props changed)
harmony/enhanced/java/branches/java6/jdktools/ (props changed)
Propchange: harmony/enhanced/java/branches/java6/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Sep 23 22:21:51 2010
@@ -1,4 +1,4 @@
/harmony/enhanced/java/branches/mrh:935751-941490
-/harmony/enhanced/java/trunk:929253-997624,997759,997980,997986,998010,998030,998619,998628,998759,998804,998822,999260,999286,999306,999591,999601,999623,999715-999716,999724,999793
+/harmony/enhanced/java/trunk:929253-997624,997759,997980,997986,998010,998030,998619,998628,998759,998804,998822,999260,999286,999306,999591,999601,999623,999715-999716,999724,999793,1000005
/harmony/enhanced/trunk:476395-929252
/incubator/harmony/enhanced/trunk:292550-476394
Propchange: harmony/enhanced/java/branches/java6/classlib/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Sep 23 22:21:51 2010
@@ -1,7 +1,7 @@
/harmony/enhanced/classlib/trunk:713674-735919,765923-926091,926318-926838
/harmony/enhanced/classlib/trunk/working_classlib:884014-884286
/harmony/enhanced/java/branches/mrh/classlib:935751-941490
-/harmony/enhanced/java/trunk/classlib:929253-997624,997759,997980,997986,998010,998030,998619,998628,998759,998804,998822,999260,999286,999306,999591,999601,999623,999715-999716,999724,999793
+/harmony/enhanced/java/trunk/classlib:929253-997624,997759,997980,997986,998010,998030,998619,998628,998759,998804,998822,999260,999286,999306,999591,999601,999623,999715-999716,999724,999793,1000005
/harmony/enhanced/trunk/classlib:476395-929252
/harmony/enhanced/trunk/working_classlib:476396-920147
/incubator/harmony/enhanced/trunk/classlib:292550-476394
Propchange: harmony/enhanced/java/branches/java6/classlib/depends/libs/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Sep 23 22:21:51 2010
@@ -1,4 +1,4 @@
/harmony/enhanced/classlib/trunk/depends/libs:544451-926091
-/harmony/enhanced/java/trunk/classlib/depends/libs:929253-997624,997759,997980,997986,998010,998030,998619,998628,998759,998804,998822,999260,999286,999306,999591,999601,999623,999715-999716,999724,999793
+/harmony/enhanced/java/trunk/classlib/depends/libs:929253-997624,997759,997980,997986,998010,998030,998619,998628,998759,998804,998822,999260,999286,999306,999591,999601,999623,999715-999716,999724,999793,1000005
/harmony/enhanced/trunk/classlib/depends/libs:476395-929252
/incubator/harmony/enhanced/trunk/classlib/depends/libs:292550-476394
Modified: harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/io/FileDescriptor.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/io/FileDescriptor.java?rev=1000648&r1=1000647&r2=1000648&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/io/FileDescriptor.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/io/FileDescriptor.java Thu Sep 23 22:21:51 2010
@@ -62,10 +62,16 @@ public final class FileDescriptor {
private static native void oneTimeInitialization();
+ private static native long getStdInDescriptor();
+
+ private static native long getStdOutDescriptor();
+
+ private static native long getStdErrDescriptor();
+
static {
- in.descriptor = 0;
- out.descriptor = 1;
- err.descriptor = 2;
+ in.descriptor = getStdInDescriptor();
+ out.descriptor = getStdOutDescriptor();
+ err.descriptor = getStdErrDescriptor();
oneTimeInitialization();
}
Modified: harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/io/FileInputStream.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/io/FileInputStream.java?rev=1000648&r1=1000647&r2=1000648&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/io/FileInputStream.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/io/FileInputStream.java Thu Sep 23 22:21:51 2010
@@ -45,8 +45,6 @@ public class FileInputStream extends Inp
// initialized).
private FileChannel channel;
- boolean innerFD;
-
private IFileSystem fileSystem = Platform.getFileSystem();
private static class RepositioningLock {
@@ -81,7 +79,6 @@ public class FileInputStream extends Inp
fd.readOnly = true;
fd.descriptor = fileSystem.open(file.properPath(true),
IFileSystem.O_RDONLY);
- innerFD = true;
channel = FileChannelFactory.getFileChannel(this, fd.descriptor,
IFileSystem.O_RDONLY);
}
@@ -109,7 +106,6 @@ public class FileInputStream extends Inp
security.checkRead(fd);
}
this.fd = fd;
- innerFD = false;
channel = FileChannelFactory.getFileChannel(this, fd.descriptor,
IFileSystem.O_RDONLY);
}
@@ -173,7 +169,7 @@ public class FileInputStream extends Inp
}
}
synchronized (this) {
- if (fd.descriptor >= 0 && innerFD) {
+ if (fd.descriptor >= 0) {
fileSystem.close(fd.descriptor);
fd.descriptor = -1;
}
Modified: harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/io/FileOutputStream.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/io/FileOutputStream.java?rev=1000648&r1=1000647&r2=1000648&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/io/FileOutputStream.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/io/FileOutputStream.java Thu Sep 23 22:21:51 2010
@@ -42,8 +42,6 @@ public class FileOutputStream extends Ou
*/
FileDescriptor fd;
- boolean innerFD;
-
// The unique file channel associated with this FileInputStream (lazily
// initialized).
private FileChannel channel;
@@ -94,7 +92,6 @@ public class FileOutputStream extends Ou
fd = new FileDescriptor();
fd.descriptor = fileSystem.open(file.properPath(true),
append ? IFileSystem.O_APPEND : IFileSystem.O_WRONLY);
- innerFD = true;
channel = FileChannelFactory.getFileChannel(this, fd.descriptor,
append ? IFileSystem.O_APPEND : IFileSystem.O_WRONLY);
}
@@ -123,7 +120,6 @@ public class FileOutputStream extends Ou
security.checkWrite(fd);
}
this.fd = fd;
- innerFD = false;
channel = FileChannelFactory.getFileChannel(this, fd.descriptor,
IFileSystem.O_WRONLY);
}
@@ -190,7 +186,7 @@ public class FileOutputStream extends Ou
}
synchronized (this) {
- if (fd.descriptor >= 0 && innerFD) {
+ if (fd.descriptor >= 0) {
fileSystem.close(fd.descriptor);
fd.descriptor = -1;
}
Modified: harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/native/luni/shared/filedesc.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/native/luni/shared/filedesc.c?rev=1000648&r1=1000647&r2=1000648&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/native/luni/shared/filedesc.c (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/native/luni/shared/filedesc.c Thu Sep 23 22:21:51 2010
@@ -19,6 +19,7 @@
#include "nethelp.h"
#include "exceptions.h"
#include "harmonyglob.h"
+#include "helpers.h"
JNIEXPORT void JNICALL
Java_java_io_FileDescriptor_syncImpl (JNIEnv * env, jobject recv)
@@ -57,3 +58,21 @@ Java_java_io_FileDescriptor_oneTimeIniti
return;
HARMONY_CACHE_SET (env, FID_java_io_FileDescriptor_descriptor, descriptorFID);
}
+
+JNIEXPORT jlong JNICALL
+Java_java_io_FileDescriptor_getStdInDescriptor (JNIEnv * env, jclass fdClazz)
+{
+ return getPlatformStdInFD();
+}
+
+JNIEXPORT jlong JNICALL
+Java_java_io_FileDescriptor_getStdOutDescriptor (JNIEnv * env, jclass fdClazz)
+{
+ return getPlatformStdOutFD();
+}
+
+JNIEXPORT jlong JNICALL
+Java_java_io_FileDescriptor_getStdErrDescriptor (JNIEnv * env, jclass fdClazz)
+{
+ return getPlatformStdErrFD();
+}
Modified: harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/native/luni/unix/exports.txt
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/native/luni/unix/exports.txt?rev=1000648&r1=1000647&r2=1000648&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/native/luni/unix/exports.txt (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/native/luni/unix/exports.txt Thu Sep 23 22:21:51 2010
@@ -51,6 +51,9 @@ Java_java_io_File_setLastModifiedImpl
Java_java_io_File_setReadableImpl
Java_java_io_File_setReadOnlyImpl
Java_java_io_File_setWritableImpl
+Java_java_io_FileDescriptor_getStdErrDescriptor
+Java_java_io_FileDescriptor_getStdInDescriptor
+Java_java_io_FileDescriptor_getStdOutDescriptor
Java_java_io_FileDescriptor_oneTimeInitialization
Java_java_io_FileDescriptor_syncImpl
Java_java_io_ObjectStreamClass_getConstructorSignature
Modified: harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/native/luni/unix/helpers.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/native/luni/unix/helpers.c?rev=1000648&r1=1000647&r2=1000648&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/native/luni/unix/helpers.c (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/native/luni/unix/helpers.c Thu Sep 23 22:21:51 2010
@@ -1025,3 +1025,13 @@ void getOSCharset(char *locale, const si
}
return;
}
+
+jlong getPlatformStdInFD() {
+ return (jlong)0;
+}
+jlong getPlatformStdOutFD() {
+ return (jlong)1;
+}
+jlong getPlatformStdErrFD() {
+ return (jlong)2;
+}
Modified: harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/native/luni/unix/helpers.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/native/luni/unix/helpers.h?rev=1000648&r1=1000647&r2=1000648&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/native/luni/unix/helpers.h (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/native/luni/unix/helpers.h Thu Sep 23 22:21:51 2010
@@ -70,5 +70,8 @@ I_32 getPlatformIsExecutable (JNIEnv * e
I_32 setPlatformExecutable (JNIEnv * env, char *path, jboolean executable, jboolean ownerOnly);
I_32 hasPrivilegeInOtherGroups(JNIEnv * env, struct stat * buffer, mode_t attr);
void getOSCharset(char *locale, const size_t size);
+jlong getPlatformStdInFD();
+jlong getPlatformStdOutFD();
+jlong getPlatformStdErrFD();
#endif /* helpers_h */
Modified: harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/native/luni/windows/helpers.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/native/luni/windows/helpers.c?rev=1000648&r1=1000647&r2=1000648&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/native/luni/windows/helpers.c (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/native/luni/windows/helpers.c Thu Sep 23 22:21:51 2010
@@ -15,6 +15,11 @@
* limitations under the License.
*/
+/* windows.h defined UDATA. Ignore its definition */
+#define UDATA UDATA_win32_
+#include <windows.h>
+#undef UDATA /* this is safe because our UDATA is a typedef, not a macro */
+
/* Undefine the winsockapi because winsock2 defines it. Removes warnings. */
#if defined(_WINSOCKAPI_) && !defined(_WINSOCK2API_)
#undef _WINSOCKAPI_
@@ -1075,3 +1080,13 @@ void getOSCharset(char *locale, const si
getCharset(cp, locale, size);
return;
}
+
+jlong getPlatformStdInFD() {
+ return (jlong)GetStdHandle(STD_INPUT_HANDLE);
+}
+jlong getPlatformStdOutFD() {
+ return (jlong)GetStdHandle(STD_OUTPUT_HANDLE);
+}
+jlong getPlatformStdErrFD() {
+ return (jlong)GetStdHandle(STD_ERROR_HANDLE);
+}
Modified: harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/native/luni/windows/helpers.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/native/luni/windows/helpers.h?rev=1000648&r1=1000647&r2=1000648&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/native/luni/windows/helpers.h (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/native/luni/windows/helpers.h Thu Sep 23 22:21:51 2010
@@ -64,4 +64,7 @@ jbyteArray getPlatformHardwareAddress(JN
I_32 getPlatformInterfaceAddresses(JNIEnv * env, jstring ifname, jint index, interfaceAddressArray_struct* interfaceAddressArray);
I_32 freeInterfaceAddressArray(JNIEnv * env, struct interfaceAddressArray_struct * array);
void getOSCharset(char *locale, const size_t size);
+jlong getPlatformStdInFD();
+jlong getPlatformStdOutFD();
+jlong getPlatformStdErrFD();
#endif /* helpers_h */
Modified: harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileInputStreamTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileInputStreamTest.java?rev=1000648&r1=1000647&r2=1000648&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileInputStreamTest.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileInputStreamTest.java Thu Sep 23 22:21:51 2010
@@ -18,6 +18,7 @@
package org.apache.harmony.luni.tests.java.io;
import java.io.File;
+import java.io.FileDescriptor;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
@@ -121,6 +122,31 @@ public class FileInputStreamTest extends
} catch (IOException e) {
// Expected
}
+
+ // Regression test for HARMONY-6642
+ FileInputStream fis = new FileInputStream(fileName);
+ FileInputStream fis2 = new FileInputStream(fis.getFD());
+ try {
+ fis2.close();
+ fis.read();
+ fail("Able to read from closed fd");
+ } catch (IOException e) {
+ // Expected
+ } finally {
+ try {
+ fis.close();
+ } catch (IOException e) {}
+ }
+
+ FileInputStream stdin = new FileInputStream(FileDescriptor.in);
+ stdin.close();
+ stdin = new FileInputStream(FileDescriptor.in);
+ try {
+ stdin.read();
+ fail("Able to read from stdin after close");
+ } catch (IOException e) {
+ // Expected
+ }
}
/**
Propchange: harmony/enhanced/java/branches/java6/drlvm/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Sep 23 22:21:51 2010
@@ -1,5 +1,5 @@
/harmony/enhanced/java/branches/mrh/drlvm:935751-941490
-/harmony/enhanced/java/trunk/drlvm:929253-997624,997759,997980,997986,998010,998030,998619,998628,998759,998804,998822,999260,999286,999306,999591,999601,999623,999715-999716,999724,999793
+/harmony/enhanced/java/trunk/drlvm:929253-997624,997759,997980,997986,998010,998030,998619,998628,998759,998804,998822,999260,999286,999306,999591,999601,999623,999715-999716,999724,999793,1000005
/harmony/enhanced/trunk/drlvm:476395-929252
/harmony/enhanced/trunk/working_vm:476396-920147
/incubator/harmony/enhanced/trunk/drlvm:292550-476394
Propchange: harmony/enhanced/java/branches/java6/jdktools/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Sep 23 22:21:51 2010
@@ -1,4 +1,4 @@
-/harmony/enhanced/java/trunk/jdktools:929253-997624,997759,997980,997986,998010,998030,998619,998628,998759,998804,998822,999260,999286,999306,999591,999601,999623,999715-999716,999724,999793
+/harmony/enhanced/java/trunk/jdktools:929253-997624,997759,997980,997986,998010,998030,998619,998628,998759,998804,998822,999260,999286,999306,999591,999601,999623,999715-999716,999724,999793,1000005
/harmony/enhanced/jdktools/trunk:630107-925933
/harmony/enhanced/trunk/jdktools:476395-929252
/harmony/enhanced/trunk/working_jdktools:476396-920147