diff --git a/jdk/make/lib/CoreLibraries.gmk b/jdk/make/lib/CoreLibraries.gmk index 852879f09ee..c62c71aa811 100644 --- a/jdk/make/lib/CoreLibraries.gmk +++ b/jdk/make/lib/CoreLibraries.gmk @@ -169,6 +169,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJAVA, \ -framework Foundation \ -framework Security -framework SystemConfiguration, \ LDFLAGS_SUFFIX_windows := -export:winFileHandleOpen -export:handleLseek \ + -export:getLastErrorString \ jvm.lib $(BUILD_LIBFDLIBM) $(WIN_VERIFY_LIB) \ shell32.lib delayimp.lib -DELAYLOAD:shell32.dll \ advapi32.lib, \ diff --git a/jdk/make/mapfiles/libjava/mapfile-vers b/jdk/make/mapfiles/libjava/mapfile-vers index 3b1d894ff71..b14ae84c1a9 100644 --- a/jdk/make/mapfiles/libjava/mapfile-vers +++ b/jdk/make/mapfiles/libjava/mapfile-vers @@ -129,13 +129,11 @@ SUNWprivate_1.1 { Java_java_lang_ClassLoader_defineClass1; Java_java_lang_ClassLoader_defineClass2; Java_java_lang_ClassLoader_findLoadedClass0; - Java_java_lang_ClassLoader_resolveClass0; Java_java_lang_ClassLoader_00024NativeLibrary_find; Java_java_lang_ClassLoader_00024NativeLibrary_load; Java_java_lang_ClassLoader_00024NativeLibrary_unload; Java_java_lang_ClassLoader_00024NativeLibrary_findBuiltinLib; Java_java_lang_ClassLoader_registerNatives; - Java_java_lang_Compiler_registerNatives; Java_java_lang_Double_longBitsToDouble; Java_java_lang_Double_doubleToRawLongBits; Java_java_lang_reflect_Proxy_defineClass0; @@ -196,8 +194,6 @@ SUNWprivate_1.1 { Java_java_lang_Runtime_gc; Java_java_lang_Runtime_runFinalization0; Java_java_lang_Runtime_totalMemory; - Java_java_lang_Runtime_traceInstructions; - Java_java_lang_Runtime_traceMethodCalls; Java_java_lang_Runtime_availableProcessors; Java_java_lang_SecurityManager_classDepth; Java_java_lang_SecurityManager_classLoaderDepth0; @@ -280,6 +276,8 @@ SUNWprivate_1.1 { # ZipFile.c needs this one throwFileNotFoundException; + # zip_util.c needs this one + getLastErrorString; # Outcalls from libjvm done using dlsym(). diff --git a/jdk/src/java.base/macosx/native/include/jvm_md.h b/jdk/src/java.base/macosx/native/include/jvm_md.h index 012bb1babe2..e369b6c066e 100644 --- a/jdk/src/java.base/macosx/native/include/jvm_md.h +++ b/jdk/src/java.base/macosx/native/include/jvm_md.h @@ -70,7 +70,6 @@ #define JVM_O_O_APPEND O_APPEND #define JVM_O_EXCL O_EXCL #define JVM_O_CREAT O_CREAT -#define JVM_O_DELETE 0x10000 /* Signals */ diff --git a/jdk/src/java.base/share/classes/java/lang/ClassLoader.java b/jdk/src/java.base/share/classes/java/lang/ClassLoader.java index 1def66a146b..44c8952ee14 100644 --- a/jdk/src/java.base/share/classes/java/lang/ClassLoader.java +++ b/jdk/src/java.base/share/classes/java/lang/ClassLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014 Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -956,11 +956,11 @@ public abstract class ClassLoader { * @see #defineClass(String, byte[], int, int) */ protected final void resolveClass(Class c) { - resolveClass0(c); + if (c == null) { + throw new NullPointerException(); + } } - private native void resolveClass0(Class c); - /** * Finds a class with the specified binary name, * loading it if necessary. diff --git a/jdk/src/java.base/share/classes/java/lang/Compiler.java b/jdk/src/java.base/share/classes/java/lang/Compiler.java index e934f5eb97c..fd4f3045d48 100644 --- a/jdk/src/java.base/share/classes/java/lang/Compiler.java +++ b/jdk/src/java.base/share/classes/java/lang/Compiler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,40 +47,6 @@ package java.lang; public final class Compiler { private Compiler() {} // don't make instances - private static native void initialize(); - - private static native void registerNatives(); - - static { - registerNatives(); - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Void run() { - boolean loaded = false; - String jit = System.getProperty("java.compiler"); - if ((jit != null) && (!jit.equals("NONE")) && - (!jit.equals(""))) - { - try { - System.loadLibrary(jit); - initialize(); - loaded = true; - } catch (UnsatisfiedLinkError e) { - System.err.println("Warning: JIT compiler \"" + - jit + "\" not found. Will use interpreter."); - } - } - String info = System.getProperty("java.vm.info"); - if (loaded) { - System.setProperty("java.vm.info", info + ", " + jit); - } else { - System.setProperty("java.vm.info", info + ", nojit"); - } - return null; - } - }); - } - /** * Compiles the specified class. * @@ -93,7 +59,9 @@ public final class Compiler { * @throws NullPointerException * If {@code clazz} is {@code null} */ - public static native boolean compileClass(Class clazz); + public static boolean compileClass(Class clazz) { + return false; + } /** * Compiles all classes whose name matches the specified string. @@ -107,7 +75,9 @@ public final class Compiler { * @throws NullPointerException * If {@code string} is {@code null} */ - public static native boolean compileClasses(String string); + public static boolean compileClasses(String string) { + return false; + } /** * Examines the argument type and its fields and perform some documented @@ -122,15 +92,17 @@ public final class Compiler { * @throws NullPointerException * If {@code any} is {@code null} */ - public static native Object command(Object any); + public static Object command(Object any) { + return null; + } /** * Cause the Compiler to resume operation. */ - public static native void enable(); + public static void enable() { } /** * Cause the Compiler to cease operation. */ - public static native void disable(); + public static void disable() { } } diff --git a/jdk/src/java.base/share/classes/java/lang/Runtime.java b/jdk/src/java.base/share/classes/java/lang/Runtime.java index f28528d20b2..66c78537d39 100644 --- a/jdk/src/java.base/share/classes/java/lang/Runtime.java +++ b/jdk/src/java.base/share/classes/java/lang/Runtime.java @@ -730,7 +730,7 @@ public class Runtime { * @param on true to enable instruction tracing; * false to disable this feature. */ - public native void traceInstructions(boolean on); + public void traceInstructions(boolean on) { } /** * Enables/Disables tracing of method calls. @@ -748,7 +748,7 @@ public class Runtime { * @param on true to enable instruction tracing; * false to disable this feature. */ - public native void traceMethodCalls(boolean on); + public void traceMethodCalls(boolean on) { } /** * Loads the native library specified by the filename argument. The filename diff --git a/jdk/src/java.base/share/native/include/jvm.h b/jdk/src/java.base/share/native/include/jvm.h index f3ac9286cdc..416a54f7771 100644 --- a/jdk/src/java.base/share/native/include/jvm.h +++ b/jdk/src/java.base/share/native/include/jvm.h @@ -111,18 +111,10 @@ JVM_ArrayCopy(JNIEnv *env, jclass ignored, jobject src, jint src_pos, JNIEXPORT jobject JNICALL JVM_InitProperties(JNIEnv *env, jobject p); -/* - * java.io.File - */ -JNIEXPORT void JNICALL -JVM_OnExit(void (*func)(void)); /* * java.lang.Runtime */ -JNIEXPORT void JNICALL -JVM_Exit(jint code); - JNIEXPORT void JNICALL JVM_Halt(jint code); @@ -146,12 +138,6 @@ JVM_GC(void); JNIEXPORT jlong JNICALL JVM_MaxObjectInspectionAge(void); -JNIEXPORT void JNICALL -JVM_TraceInstructions(jboolean on); - -JNIEXPORT void JNICALL -JVM_TraceMethodCalls(jboolean on); - JNIEXPORT jlong JNICALL JVM_TotalMemory(void); @@ -176,12 +162,6 @@ JVM_FindLibraryEntry(void *handle, const char *name); JNIEXPORT jboolean JNICALL JVM_IsSupportedJNIVersion(jint version); -/* - * java.lang.Float and java.lang.Double - */ -JNIEXPORT jboolean JNICALL -JVM_IsNaN(jdouble d); - /* * java.lang.Throwable */ @@ -194,30 +174,6 @@ JVM_GetStackTraceDepth(JNIEnv *env, jobject throwable); JNIEXPORT jobject JNICALL JVM_GetStackTraceElement(JNIEnv *env, jobject throwable, jint index); -/* - * java.lang.Compiler - */ -JNIEXPORT void JNICALL -JVM_InitializeCompiler (JNIEnv *env, jclass compCls); - -JNIEXPORT jboolean JNICALL -JVM_IsSilentCompiler(JNIEnv *env, jclass compCls); - -JNIEXPORT jboolean JNICALL -JVM_CompileClass(JNIEnv *env, jclass compCls, jclass cls); - -JNIEXPORT jboolean JNICALL -JVM_CompileClasses(JNIEnv *env, jclass cls, jstring jname); - -JNIEXPORT jobject JNICALL -JVM_CompilerCommand(JNIEnv *env, jclass compCls, jobject arg); - -JNIEXPORT void JNICALL -JVM_EnableCompiler(JNIEnv *env, jclass compCls); - -JNIEXPORT void JNICALL -JVM_DisableCompiler(JNIEnv *env, jclass compCls); - /* * java.lang.Thread */ @@ -304,24 +260,8 @@ JVM_GetSystemPackages(JNIEnv *env); * java.io.ObjectInputStream */ JNIEXPORT jobject JNICALL -JVM_AllocateNewObject(JNIEnv *env, jobject obj, jclass currClass, - jclass initClass); - -JNIEXPORT jobject JNICALL -JVM_AllocateNewArray(JNIEnv *env, jobject obj, jclass currClass, - jint length); - -JNIEXPORT jobject JNICALL JVM_LatestUserDefinedLoader(JNIEnv *env); -/* - * This function has been deprecated and should not be considered - * part of the specified JVM interface. - */ -JNIEXPORT jclass JNICALL -JVM_LoadClass0(JNIEnv *env, jobject obj, jclass currClass, - jstring currClassName); - /* * java.lang.reflect.Array */ @@ -373,11 +313,6 @@ JVM_GetCallerClass(JNIEnv *env, int depth); JNIEXPORT jclass JNICALL JVM_FindPrimitiveClass(JNIEnv *env, const char *utf); -/* - * Link the class - */ -JNIEXPORT void JNICALL -JVM_ResolveClass(JNIEnv *env, jclass cls); /* * Find a class from a boot class loader. Returns NULL if class not found. @@ -1088,43 +1023,6 @@ typedef int (*canonicalize_fn_t)(JNIEnv *env, char *orig, char *out, int len); PART 3: I/O and Network Support ************************************************************************/ -/* Note that the JVM IO functions are expected to return JVM_IO_ERR - * when there is any kind of error. The caller can then use the - * platform specific support (e.g., errno) to get the detailed - * error info. The JVM_GetLastErrorString procedure may also be used - * to obtain a descriptive error string. - */ -#define JVM_IO_ERR (-1) - -/* For interruptible IO. Returning JVM_IO_INTR indicates that an IO - * operation has been disrupted by Thread.interrupt. There are a - * number of technical difficulties related to interruptible IO that - * need to be solved. For example, most existing programs do not handle - * InterruptedIOExceptions specially, they simply treat those as any - * IOExceptions, which typically indicate fatal errors. - * - * There are also two modes of operation for interruptible IO. In the - * resumption mode, an interrupted IO operation is guaranteed not to - * have any side-effects, and can be restarted. In the termination mode, - * an interrupted IO operation corrupts the underlying IO stream, so - * that the only reasonable operation on an interrupted stream is to - * close that stream. The resumption mode seems to be impossible to - * implement on Win32 and Solaris. Implementing the termination mode is - * easier, but it's not clear that's the right semantics. - * - * Interruptible IO is not supported on Win32.It can be enabled/disabled - * using a compile-time flag on Solaris. Third-party JVM ports do not - * need to implement interruptible IO. - */ -#define JVM_IO_INTR (-2) - -/* Write a string into the given buffer, in the platform's local encoding, - * that describes the most recent system-level error to occur in this thread. - * Return the length of the string or zero if no error occurred. - */ -JNIEXPORT jint JNICALL -JVM_GetLastErrorString(char *buf, int len); - /* * Convert a pathname into native format. This function does syntactic * cleanup, such as removing redundant separator characters. It modifies @@ -1133,150 +1031,6 @@ JVM_GetLastErrorString(char *buf, int len); JNIEXPORT char * JNICALL JVM_NativePath(char *); -/* - * JVM I/O error codes - */ -#define JVM_EEXIST -100 - -/* - * Open a file descriptor. This function returns a negative error code - * on error, and a non-negative integer that is the file descriptor on - * success. - */ -JNIEXPORT jint JNICALL -JVM_Open(const char *fname, jint flags, jint mode); - -/* - * Close a file descriptor. This function returns -1 on error, and 0 - * on success. - * - * fd the file descriptor to close. - */ -JNIEXPORT jint JNICALL -JVM_Close(jint fd); - -/* - * Read data from a file decriptor into a char array. - * - * fd the file descriptor to read from. - * buf the buffer where to put the read data. - * nbytes the number of bytes to read. - * - * This function returns -1 on error, and 0 on success. - */ -JNIEXPORT jint JNICALL -JVM_Read(jint fd, char *buf, jint nbytes); - -/* - * Write data from a char array to a file decriptor. - * - * fd the file descriptor to read from. - * buf the buffer from which to fetch the data. - * nbytes the number of bytes to write. - * - * This function returns -1 on error, and 0 on success. - */ -JNIEXPORT jint JNICALL -JVM_Write(jint fd, char *buf, jint nbytes); - -/* - * Returns the number of bytes available for reading from a given file - * descriptor - */ -JNIEXPORT jint JNICALL -JVM_Available(jint fd, jlong *pbytes); - -/* - * Move the file descriptor pointer from whence by offset. - * - * fd the file descriptor to move. - * offset the number of bytes to move it by. - * whence the start from where to move it. - * - * This function returns the resulting pointer location. - */ -JNIEXPORT jlong JNICALL -JVM_Lseek(jint fd, jlong offset, jint whence); - -/* - * Set the length of the file associated with the given descriptor to the given - * length. If the new length is longer than the current length then the file - * is extended; the contents of the extended portion are not defined. The - * value of the file pointer is undefined after this procedure returns. - */ -JNIEXPORT jint JNICALL -JVM_SetLength(jint fd, jlong length); - -/* - * Synchronize the file descriptor's in memory state with that of the - * physical device. Return of -1 is an error, 0 is OK. - */ -JNIEXPORT jint JNICALL -JVM_Sync(jint fd); - -/* - * Networking library support - */ - -JNIEXPORT jint JNICALL -JVM_InitializeSocketLibrary(void); - -struct sockaddr; - -JNIEXPORT jint JNICALL -JVM_Socket(jint domain, jint type, jint protocol); - -JNIEXPORT jint JNICALL -JVM_SocketClose(jint fd); - -JNIEXPORT jint JNICALL -JVM_SocketShutdown(jint fd, jint howto); - -JNIEXPORT jint JNICALL -JVM_Recv(jint fd, char *buf, jint nBytes, jint flags); - -JNIEXPORT jint JNICALL -JVM_Send(jint fd, char *buf, jint nBytes, jint flags); - -JNIEXPORT jint JNICALL -JVM_Timeout(int fd, long timeout); - -JNIEXPORT jint JNICALL -JVM_Listen(jint fd, jint count); - -JNIEXPORT jint JNICALL -JVM_Connect(jint fd, struct sockaddr *him, jint len); - -JNIEXPORT jint JNICALL -JVM_Bind(jint fd, struct sockaddr *him, jint len); - -JNIEXPORT jint JNICALL -JVM_Accept(jint fd, struct sockaddr *him, jint *len); - -JNIEXPORT jint JNICALL -JVM_RecvFrom(jint fd, char *buf, int nBytes, - int flags, struct sockaddr *from, int *fromlen); - -JNIEXPORT jint JNICALL -JVM_SendTo(jint fd, char *buf, int len, - int flags, struct sockaddr *to, int tolen); - -JNIEXPORT jint JNICALL -JVM_SocketAvailable(jint fd, jint *result); - - -JNIEXPORT jint JNICALL -JVM_GetSockName(jint fd, struct sockaddr *him, int *len); - -JNIEXPORT jint JNICALL -JVM_GetSockOpt(jint fd, int level, int optname, char *optval, int *optlen); - -JNIEXPORT jint JNICALL -JVM_SetSockOpt(jint fd, int level, int optname, const char *optval, int optlen); - -JNIEXPORT int JNICALL -JVM_GetHostName(char* name, int namelen); - /* * The standard printing functions supported by the Java VM. (Should they * be renamed to JVM_* in the future? @@ -1342,39 +1096,6 @@ JVM_GetTemporaryDirectory(JNIEnv *env); JNIEXPORT jobjectArray JNICALL JVM_GetEnclosingMethodInfo(JNIEnv* env, jclass ofClass); -/* - * Java thread state support - */ -enum { - JAVA_THREAD_STATE_NEW = 0, - JAVA_THREAD_STATE_RUNNABLE = 1, - JAVA_THREAD_STATE_BLOCKED = 2, - JAVA_THREAD_STATE_WAITING = 3, - JAVA_THREAD_STATE_TIMED_WAITING = 4, - JAVA_THREAD_STATE_TERMINATED = 5, - JAVA_THREAD_STATE_COUNT = 6 -}; - -/* - * Returns an array of the threadStatus values representing the - * given Java thread state. Returns NULL if the VM version is - * incompatible with the JDK or doesn't support the given - * Java thread state. - */ -JNIEXPORT jintArray JNICALL -JVM_GetThreadStateValues(JNIEnv* env, jint javaThreadState); - -/* - * Returns an array of the substate names representing the - * given Java thread state. Returns NULL if the VM version is - * incompatible with the JDK or the VM doesn't support - * the given Java thread state. - * values must be the jintArray returned from JVM_GetThreadStateValues - * and javaThreadState. - */ -JNIEXPORT jobjectArray JNICALL -JVM_GetThreadStateNames(JNIEnv* env, jint javaThreadState, jintArray values); - /* ========================================================================= * The following defines a private JVM interface that the JDK can query * for the JVM version and capabilities. sun.misc.Version defines diff --git a/jdk/src/java.base/share/native/libjava/ClassLoader.c b/jdk/src/java.base/share/native/libjava/ClassLoader.c index 7701cce4bea..ae69096bd50 100644 --- a/jdk/src/java.base/share/native/libjava/ClassLoader.c +++ b/jdk/src/java.base/share/native/libjava/ClassLoader.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -224,18 +224,6 @@ Java_java_lang_ClassLoader_defineClass2(JNIEnv *env, return result; } -JNIEXPORT void JNICALL -Java_java_lang_ClassLoader_resolveClass0(JNIEnv *env, jobject this, - jclass cls) -{ - if (cls == NULL) { - JNU_ThrowNullPointerException(env, 0); - return; - } - - JVM_ResolveClass(env, cls); -} - /* * Returns NULL if class not found. */ diff --git a/jdk/src/java.base/share/native/libjava/Compiler.c b/jdk/src/java.base/share/native/libjava/Compiler.c deleted file mode 100644 index eac1304081a..00000000000 --- a/jdk/src/java.base/share/native/libjava/Compiler.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 1995, 1999, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "jvm.h" -#include "jni.h" -#include "java_lang_Compiler.h" - -static JNINativeMethod methods[] = { - {"compileClass", - "(Ljava/lang/Class;)Z", - (void *)&JVM_CompileClass}, - {"compileClasses", - "(Ljava/lang/String;)Z", - (void *)&JVM_CompileClasses}, - {"command", - "(Ljava/lang/Object;)Ljava/lang/Object;", - (void *)&JVM_CompilerCommand}, - {"enable", - "()V", - (void *)&JVM_EnableCompiler}, - {"disable", - "()V", - (void *)&JVM_DisableCompiler} -}; - -JNIEXPORT void JNICALL -Java_java_lang_Compiler_registerNatives(JNIEnv *env, jclass compCls) -{ - (*env)->RegisterNatives(env, compCls, methods, - sizeof methods / sizeof methods[0]); -} diff --git a/jdk/src/java.base/share/native/libjava/Runtime.c b/jdk/src/java.base/share/native/libjava/Runtime.c index dece2232f8a..2d40d310177 100644 --- a/jdk/src/java.base/share/native/libjava/Runtime.c +++ b/jdk/src/java.base/share/native/libjava/Runtime.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2000, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -65,18 +65,6 @@ Java_java_lang_Runtime_gc(JNIEnv *env, jobject this) JVM_GC(); } -JNIEXPORT void JNICALL -Java_java_lang_Runtime_traceInstructions(JNIEnv *env, jobject this, jboolean on) -{ - JVM_TraceInstructions(on); -} - -JNIEXPORT void JNICALL -Java_java_lang_Runtime_traceMethodCalls(JNIEnv *env, jobject this, jboolean on) -{ - JVM_TraceMethodCalls(on); -} - JNIEXPORT void JNICALL Java_java_lang_Runtime_runFinalization0(JNIEnv *env, jobject this) { diff --git a/jdk/src/java.base/share/native/libjava/io_util.h b/jdk/src/java.base/share/native/libjava/io_util.h index 6f058ccc4b5..120594fe804 100644 --- a/jdk/src/java.base/share/native/libjava/io_util.h +++ b/jdk/src/java.base/share/native/libjava/io_util.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -54,7 +54,6 @@ void writeBytes(JNIEnv *env, jobject this, jbyteArray bytes, jint off, jint len, jboolean append, jfieldID fid); void fileOpen(JNIEnv *env, jobject this, jstring path, jfieldID fid, int flags); void throwFileNotFoundException(JNIEnv *env, jstring path); -size_t getLastErrorString(char *buf, size_t len); /* * Macros for managing platform strings. The typical usage pattern is: diff --git a/jdk/src/java.base/share/native/libjava/jni_util.c b/jdk/src/java.base/share/native/libjava/jni_util.c index 2955e0f1aa7..2f8f4e48b1a 100644 --- a/jdk/src/java.base/share/native/libjava/jni_util.c +++ b/jdk/src/java.base/share/native/libjava/jni_util.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -157,7 +157,7 @@ JNU_ThrowByNameWithLastError(JNIEnv *env, const char *name, const char *defaultDetail) { char buf[256]; - int n = JVM_GetLastErrorString(buf, sizeof(buf)); + int n = getLastErrorString(buf, sizeof(buf)); if (n > 0) { jstring s = JNU_NewStringPlatform(env, buf); diff --git a/jdk/src/java.base/share/native/libjava/jni_util.h b/jdk/src/java.base/share/native/libjava/jni_util.h index b66ea62fe5b..5278ebe0f45 100644 --- a/jdk/src/java.base/share/native/libjava/jni_util.h +++ b/jdk/src/java.base/share/native/libjava/jni_util.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -387,6 +387,7 @@ void* getProcessHandle(); void buildJniFunctionName(const char *sym, const char *cname, char *jniEntryName); +extern size_t getLastErrorString(char *buf, size_t len); #ifdef __cplusplus } /* extern "C" */ #endif /* __cplusplus */ diff --git a/jdk/src/java.base/share/native/libzip/ZipFile.c b/jdk/src/java.base/share/native/libzip/ZipFile.c index 4604d8ff229..6329908fa81 100644 --- a/jdk/src/java.base/share/native/libzip/ZipFile.c +++ b/jdk/src/java.base/share/native/libzip/ZipFile.c @@ -93,24 +93,27 @@ Java_java_util_zip_ZipFile_open(JNIEnv *env, jclass cls, jstring name, jzfile *zip = 0; if (mode & OPEN_READ) flag |= O_RDONLY; - if (mode & OPEN_DELETE) flag |= JVM_O_DELETE; if (path != 0) { zip = ZIP_Get_From_Cache(path, &msg, lastModified); if (zip == 0 && msg == 0) { ZFILE zfd = 0; #ifdef WIN32 + if (mode & OPEN_DELETE) flag |= O_TEMPORARY; zfd = winFileHandleOpen(env, name, flag); if (zfd == -1) { /* Exception already pending. */ goto finally; } #else - zfd = JVM_Open(path, flag, 0); + zfd = open(path, flag, 0); if (zfd < 0) { throwFileNotFoundException(env, name); goto finally; } + if (mode & OPEN_DELETE) { + unlink(path); + } #endif zip = ZIP_Put_In_Cache0(path, zfd, &msg, lastModified, usemmap); } diff --git a/jdk/src/java.base/share/native/libzip/zip_util.c b/jdk/src/java.base/share/native/libzip/zip_util.c index a072e6624c4..dd5e8a31dd9 100644 --- a/jdk/src/java.base/share/native/libzip/zip_util.c +++ b/jdk/src/java.base/share/native/libzip/zip_util.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -123,7 +123,7 @@ ZFILE_Open(const char *fname, int flags) { flagsAndAttributes, /* flags and attributes */ NULL); #else - return JVM_Open(fname, flags, 0); + return open(fname, flags, 0); #endif } @@ -136,7 +136,7 @@ ZFILE_Close(ZFILE zfd) { #ifdef WIN32 CloseHandle((HANDLE) zfd); #else - JVM_Close(zfd); + close(zfd); #endif } @@ -145,14 +145,6 @@ ZFILE_read(ZFILE zfd, char *buf, jint nbytes) { #ifdef WIN32 return (int) IO_Read(zfd, buf, nbytes); #else - /* - * Calling JVM_Read will return JVM_IO_INTR when Thread.interrupt is called - * only on Solaris. Continue reading jar file in this case is the best - * thing to do since zip file reading is relatively fast and it is very onerous - * for a interrupted thread to deal with this kind of hidden I/O. However, handling - * JVM_IO_INTR is tricky and could cause undesired side effect. So we decided - * to simply call "read" on Solaris/Linux. See details in bug 6304463. - */ return read(zfd, buf, nbytes); #endif } @@ -198,9 +190,8 @@ readFully(ZFILE zfd, void *buf, jlong len) { if (n > 0) { bp += n; len -= n; - } else if (n == JVM_IO_ERR && errno == EINTR) { - /* Retry after EINTR (interrupted by signal). - We depend on the fact that JVM_IO_ERR == -1. */ + } else if (n == -1 && errno == EINTR) { + /* Retry after EINTR (interrupted by signal). */ continue; } else { /* EOF or IO error */ return -1; @@ -828,7 +819,7 @@ ZIP_Put_In_Cache0(const char *name, ZFILE zfd, char **pmsg, jlong lastModified, zip->lastModified = lastModified; if (zfd == -1) { - if (pmsg && JVM_GetLastErrorString(errbuf, sizeof(errbuf)) > 0) + if (pmsg && getLastErrorString(errbuf, sizeof(errbuf)) > 0) *pmsg = strdup(errbuf); freeZip(zip); return NULL; @@ -849,7 +840,7 @@ ZIP_Put_In_Cache0(const char *name, ZFILE zfd, char **pmsg, jlong lastModified, *pmsg = strdup("zip file is empty"); } } else { /* error */ - if (pmsg && JVM_GetLastErrorString(errbuf, sizeof(errbuf)) > 0) + if (pmsg && getLastErrorString(errbuf, sizeof(errbuf)) > 0) *pmsg = strdup(errbuf); } ZFILE_Close(zfd); diff --git a/jdk/src/java.base/unix/native/include/jvm_md.h b/jdk/src/java.base/unix/native/include/jvm_md.h index 5c681914bba..818ab732a40 100644 --- a/jdk/src/java.base/unix/native/include/jvm_md.h +++ b/jdk/src/java.base/unix/native/include/jvm_md.h @@ -75,7 +75,6 @@ #define JVM_O_O_APPEND O_APPEND #define JVM_O_EXCL O_EXCL #define JVM_O_CREAT O_CREAT -#define JVM_O_DELETE 0x10000 /* Signals */ diff --git a/jdk/src/java.base/unix/native/libjava/io_util_md.c b/jdk/src/java.base/unix/native/libjava/io_util_md.c index 5899a410347..4c539ecdafb 100644 --- a/jdk/src/java.base/unix/native/libjava/io_util_md.c +++ b/jdk/src/java.base/unix/native/libjava/io_util_md.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -211,18 +211,3 @@ handleSetLength(FD fd, jlong length) RESTARTABLE(ftruncate64(fd, length), result); return result; } - -size_t -getLastErrorString(char *buf, size_t len) -{ - if (errno == 0 || len < 1) return 0; - - const char *err = strerror(errno); - size_t n = strlen(err); - if (n >= len) - n = len - 1; - - strncpy(buf, err, n); - buf[n] = '\0'; - return n; -} diff --git a/jdk/src/java.base/unix/native/libjava/jni_util_md.c b/jdk/src/java.base/unix/native/libjava/jni_util_md.c index 90b89676caa..36d3565c401 100644 --- a/jdk/src/java.base/unix/native/libjava/jni_util_md.c +++ b/jdk/src/java.base/unix/native/libjava/jni_util_md.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ * questions. */ +#include #include #include "jni.h" @@ -51,3 +52,17 @@ void buildJniFunctionName(const char *sym, const char *cname, } } +size_t +getLastErrorString(char *buf, size_t len) +{ + if (errno == 0 || len < 1) return 0; + + const char *err = strerror(errno); + size_t n = strlen(err); + if (n >= len) + n = len - 1; + + strncpy(buf, err, n); + buf[n] = '\0'; + return n; +} diff --git a/jdk/src/java.base/windows/native/include/jvm_md.h b/jdk/src/java.base/windows/native/include/jvm_md.h index 23b2a74f546..e9feba32415 100644 --- a/jdk/src/java.base/windows/native/include/jvm_md.h +++ b/jdk/src/java.base/windows/native/include/jvm_md.h @@ -97,7 +97,6 @@ JVM_GetHostByName(char* name); #define JVM_O_O_APPEND O_APPEND #define JVM_O_EXCL O_EXCL #define JVM_O_CREAT O_CREAT -#define JVM_O_DELETE O_TEMPORARY /* Signals */ diff --git a/jdk/src/java.base/windows/native/libjava/io_util_md.c b/jdk/src/java.base/windows/native/libjava/io_util_md.c index 123995433eb..ba2db4de401 100644 --- a/jdk/src/java.base/windows/native/libjava/io_util_md.c +++ b/jdk/src/java.base/windows/native/libjava/io_util_md.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -576,77 +576,3 @@ handleLseek(FD fd, jlong offset, jint whence) } return long_to_jlong(pos.QuadPart); } - -size_t -getLastErrorString(char *utf8_jvmErrorMsg, size_t cbErrorMsg) -{ - size_t n = 0; - if (cbErrorMsg > 0) { - BOOLEAN noError = FALSE; - WCHAR *utf16_osErrorMsg = (WCHAR *)malloc(cbErrorMsg*sizeof(WCHAR)); - if (utf16_osErrorMsg == NULL) { - // OOM accident - strncpy(utf8_jvmErrorMsg, "Out of memory", cbErrorMsg); - // truncate if too long - utf8_jvmErrorMsg[cbErrorMsg - 1] = '\0'; - n = strlen(utf8_jvmErrorMsg); - } else { - DWORD errval = GetLastError(); - if (errval != 0) { - // WIN32 error - n = (size_t)FormatMessageW( - FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - errval, - 0, - utf16_osErrorMsg, - (DWORD)cbErrorMsg, - NULL); - if (n > 3) { - // Drop final '.', CR, LF - if (utf16_osErrorMsg[n - 1] == L'\n') --n; - if (utf16_osErrorMsg[n - 1] == L'\r') --n; - if (utf16_osErrorMsg[n - 1] == L'.') --n; - utf16_osErrorMsg[n] = L'\0'; - } - } else if (errno != 0) { - // C runtime error that has no corresponding WIN32 error code - const WCHAR *rtError = _wcserror(errno); - if (rtError != NULL) { - wcsncpy(utf16_osErrorMsg, rtError, cbErrorMsg); - // truncate if too long - utf16_osErrorMsg[cbErrorMsg - 1] = L'\0'; - n = wcslen(utf16_osErrorMsg); - } - } else - noError = TRUE; //OS has no error to report - - if (!noError) { - if (n > 0) { - n = WideCharToMultiByte( - CP_UTF8, - 0, - utf16_osErrorMsg, - n, - utf8_jvmErrorMsg, - cbErrorMsg, - NULL, - NULL); - - // no way to die - if (n > 0) - utf8_jvmErrorMsg[min(cbErrorMsg - 1, n)] = '\0'; - } - - if (n <= 0) { - strncpy(utf8_jvmErrorMsg, "Secondary error while OS message extraction", cbErrorMsg); - // truncate if too long - utf8_jvmErrorMsg[cbErrorMsg - 1] = '\0'; - n = strlen(utf8_jvmErrorMsg); - } - } - free(utf16_osErrorMsg); - } - } - return n; -} diff --git a/jdk/src/java.base/windows/native/libjava/jni_util_md.c b/jdk/src/java.base/windows/native/libjava/jni_util_md.c index 80f1b355fe5..b2bb70aa758 100644 --- a/jdk/src/java.base/windows/native/libjava/jni_util_md.c +++ b/jdk/src/java.base/windows/native/libjava/jni_util_md.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2014 Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -73,3 +73,77 @@ void buildJniFunctionName(const char *sym, const char *cname, } return; } + +size_t +getLastErrorString(char *utf8_jvmErrorMsg, size_t cbErrorMsg) +{ + size_t n = 0; + if (cbErrorMsg > 0) { + BOOLEAN noError = FALSE; + WCHAR *utf16_osErrorMsg = (WCHAR *)malloc(cbErrorMsg*sizeof(WCHAR)); + if (utf16_osErrorMsg == NULL) { + // OOM accident + strncpy(utf8_jvmErrorMsg, "Out of memory", cbErrorMsg); + // truncate if too long + utf8_jvmErrorMsg[cbErrorMsg - 1] = '\0'; + n = strlen(utf8_jvmErrorMsg); + } else { + DWORD errval = GetLastError(); + if (errval != 0) { + // WIN32 error + n = (size_t)FormatMessageW( + FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + errval, + 0, + utf16_osErrorMsg, + (DWORD)cbErrorMsg, + NULL); + if (n > 3) { + // Drop final '.', CR, LF + if (utf16_osErrorMsg[n - 1] == L'\n') --n; + if (utf16_osErrorMsg[n - 1] == L'\r') --n; + if (utf16_osErrorMsg[n - 1] == L'.') --n; + utf16_osErrorMsg[n] = L'\0'; + } + } else if (errno != 0) { + // C runtime error that has no corresponding WIN32 error code + const WCHAR *rtError = _wcserror(errno); + if (rtError != NULL) { + wcsncpy(utf16_osErrorMsg, rtError, cbErrorMsg); + // truncate if too long + utf16_osErrorMsg[cbErrorMsg - 1] = L'\0'; + n = wcslen(utf16_osErrorMsg); + } + } else + noError = TRUE; //OS has no error to report + + if (!noError) { + if (n > 0) { + n = WideCharToMultiByte( + CP_UTF8, + 0, + utf16_osErrorMsg, + n, + utf8_jvmErrorMsg, + cbErrorMsg, + NULL, + NULL); + + // no way to die + if (n > 0) + utf8_jvmErrorMsg[min(cbErrorMsg - 1, n)] = '\0'; + } + + if (n <= 0) { + strncpy(utf8_jvmErrorMsg, "Secondary error while OS message extraction", cbErrorMsg); + // truncate if too long + utf8_jvmErrorMsg[cbErrorMsg - 1] = '\0'; + n = strlen(utf8_jvmErrorMsg); + } + } + free(utf16_osErrorMsg); + } + } + return n; +}