From c5ef39f2bd6d5911ca41b0c1887277ecdfbde9b9 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Thu, 16 Feb 2012 18:19:01 -0700 Subject: [PATCH 1/3] implement File.getAbsoluteFile for Windows --- classpath/java-io.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/classpath/java-io.cpp b/classpath/java-io.cpp index c851a0d75a..ff728b5365 100644 --- a/classpath/java-io.cpp +++ b/classpath/java-io.cpp @@ -323,7 +323,19 @@ extern "C" JNIEXPORT jstring JNICALL Java_java_io_File_toAbsolutePath(JNIEnv* e UNUSED, jclass, jstring path) { #ifdef PLATFORM_WINDOWS - // todo + string_t chars = getChars(e, path); + if (chars) { + const unsigned BufferSize = MAX_PATH; + char_t buffer[BufferSize]; + DWORD success = GetFullPathNameW(chars, BufferSize, buffer, 0); + releaseChars(e, path, chars); + + if (success) { + return e->NewString + (reinterpret_cast(buffer), wcslen(buffer)); + } + } + return path; #else jstring result = path; From 999e90c3321529fe3a034f28e87eb4fa2d6207ef Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Thu, 16 Feb 2012 18:22:11 -0700 Subject: [PATCH 2/3] fix MSVC build --- makefile | 3 ++- src/common.h | 2 ++ src/finder.h | 2 +- src/machine.h | 4 ++-- src/system.h | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/makefile b/makefile index 218216f537..0cab252162 100755 --- a/makefile +++ b/makefile @@ -478,7 +478,8 @@ ifdef msvc -DUSE_ATOMIC_OPERATIONS -DAVIAN_JAVA_HOME=\"$(javahome)\" \ -DAVIAN_EMBED_PREFIX=\"$(embed-prefix)\" \ -Fd$(build)/$(name).pdb -I"$(zlib)/include" -I$(src) -I"$(build)" \ - -I"$(windows-java-home)/include" -I"$(windows-java-home)/include/win32" + -I"$(windows-java-home)/include" -I"$(windows-java-home)/include/win32" \ + -DTARGET_BYTES_PER_WORD=$(pointer-size) -DTARGET_PLATFORM_WINDOWS shared = -dll lflags = -nologo -LIBPATH:"$(zlib)/lib" -DEFAULTLIB:ws2_32 \ -DEFAULTLIB:zlib -MANIFEST -debug diff --git a/src/common.h b/src/common.h index 7c60041449..8c762f6c70 100644 --- a/src/common.h +++ b/src/common.h @@ -56,10 +56,12 @@ typedef unsigned __int64 uint64_t; # ifdef _M_IX86 typedef int32_t intptr_t; typedef uint32_t uintptr_t; +# define UINT64_C(x) x##LL # define ARCH_x86_32 # elif defined _M_X64 typedef int64_t intptr_t; typedef uint64_t uintptr_t; +# define UINT64_C(x) x##L # define ARCH_x86_64 # else # error "unsupported architecture" diff --git a/src/finder.h b/src/finder.h index 55aa9e85ee..e784fe6e9a 100644 --- a/src/finder.h +++ b/src/finder.h @@ -173,7 +173,7 @@ class Finder { virtual void dispose() = 0; }; -Finder* +JNIEXPORT Finder* makeFinder(System* s, Allocator* a, const char* path, const char* bootLibrary); Finder* diff --git a/src/machine.h b/src/machine.h index 12aca3bc45..96c853624f 100644 --- a/src/machine.h +++ b/src/machine.h @@ -3884,10 +3884,10 @@ errorLog(Thread* t) } // namespace vm -void +JNIEXPORT void vmPrintTrace(vm::Thread* t); -void* +JNIEXPORT void* vmAddressFromLine(vm::Thread* t, vm::object m, unsigned line); #endif//MACHINE_H diff --git a/src/system.h b/src/system.h index 0ec1b29eb5..897193d042 100644 --- a/src/system.h +++ b/src/system.h @@ -199,7 +199,7 @@ assert(System* s, bool v) #endif // not NDEBUG -System* +JNIEXPORT System* makeSystem(const char* crashDumpDirectory); } // namespace vm From 750e5f903c40072c5eff86a6c66376e1f33f0e9e Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Sat, 18 Feb 2012 15:14:16 -0700 Subject: [PATCH 3/3] include leading slash in path when parsing URLs in URLStreamHandler This matches the behavior of OpenJDK's version. --- classpath/java/net/URLStreamHandler.java | 2 +- test/UrlTest.java | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/classpath/java/net/URLStreamHandler.java b/classpath/java/net/URLStreamHandler.java index 5c72deada1..e1312437b9 100644 --- a/classpath/java/net/URLStreamHandler.java +++ b/classpath/java/net/URLStreamHandler.java @@ -40,7 +40,7 @@ public abstract class URLStreamHandler { host = s.substring(0, colon); port = Integer.parseInt(s.substring(colon + 1), slash); } - s = s.substring(slash + 1); + s = s.substring(slash); } } diff --git a/test/UrlTest.java b/test/UrlTest.java index 35281b367a..244d1ec45a 100644 --- a/test/UrlTest.java +++ b/test/UrlTest.java @@ -3,7 +3,7 @@ import java.net.URL; public class UrlTest { private static String query="var1=val1&var2=val2"; - private static String path="testpath"; + private static String path="/testpath"; private static String domain="file://www.readytalk.com"; private static String file=path + "?" + query; private static URL url; @@ -15,7 +15,6 @@ public class UrlTest { private static void setupURL() throws MalformedURLException { StringBuilder builder = new StringBuilder(); builder.append(domain); - builder.append("/"); builder.append(file); url = new URL(builder.toString()); }