From 916c96c2b9b5cf5343c49d7d0f2e8eb38449001a Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Wed, 14 Sep 2011 13:27:17 -0600 Subject: [PATCH] fix access violation introduced in last commit --- classpath/java-io.cpp | 11 ++++++----- test/Zip.java | 3 +++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/classpath/java-io.cpp b/classpath/java-io.cpp index d0165019d6..9175c6e978 100644 --- a/classpath/java-io.cpp +++ b/classpath/java-io.cpp @@ -346,14 +346,15 @@ Java_java_io_File_length(JNIEnv* e, jclass, jstring path) #ifdef PLATFORM_WINDOWS LARGE_INTEGER fileSize; - HANDLE file = CreateFileW((wchar_t *)e->GetStringChars(path, 0), FILE_READ_DATA, FILE_SHARE_READ, 0, - OPEN_EXISTING, 0, 0); - e->ReleaseStringChars(path, 0); + string_t chars = getChars(e, path); + HANDLE file = CreateFileW + (chars, FILE_READ_DATA, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0); + releaseChars(e, path, chars); if (file != INVALID_HANDLE_VALUE) GetFileSizeEx(file, &fileSize); - else return -1; + else return 0; CloseHandle(file); - return (jlong)fileSize.QuadPart; + return static_cast(fileSize.QuadPart); #else diff --git a/test/Zip.java b/test/Zip.java index 9b34444023..36d08b6ca2 100644 --- a/test/Zip.java +++ b/test/Zip.java @@ -10,6 +10,9 @@ public class Zip { for (File file: directory.listFiles()) { if (file.isFile()) { if (file.getName().endsWith(".jar")) { + System.out.println + ("found " + file.getAbsolutePath() + " length " + file.length()); + return file.getAbsolutePath(); } } else if (file.isDirectory()) {