8057777: Cleanup of old and unused VM interfaces
Reviewed-by: coleenp, hseigel, alanb, sherman
--- a/jdk/make/lib/CoreLibraries.gmk Tue Oct 07 15:16:17 2014 +0200
+++ b/jdk/make/lib/CoreLibraries.gmk Thu Oct 09 04:48:12 2014 -0700
@@ -169,6 +169,7 @@
-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, \
--- a/jdk/make/mapfiles/libjava/mapfile-vers Tue Oct 07 15:16:17 2014 +0200
+++ b/jdk/make/mapfiles/libjava/mapfile-vers Thu Oct 09 04:48:12 2014 -0700
@@ -129,13 +129,11 @@
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 @@
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 @@
# ZipFile.c needs this one
throwFileNotFoundException;
+ # zip_util.c needs this one
+ getLastErrorString;
# Outcalls from libjvm done using dlsym().
--- a/jdk/src/java.base/macosx/native/include/jvm_md.h Tue Oct 07 15:16:17 2014 +0200
+++ b/jdk/src/java.base/macosx/native/include/jvm_md.h Thu Oct 09 04:48:12 2014 -0700
@@ -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 */
--- a/jdk/src/java.base/share/classes/java/lang/ClassLoader.java Tue Oct 07 15:16:17 2014 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/ClassLoader.java Thu Oct 09 04:48:12 2014 -0700
@@ -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 @@
* @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 <a href="#name">binary name</a>,
* loading it if necessary.
--- a/jdk/src/java.base/share/classes/java/lang/Compiler.java Tue Oct 07 15:16:17 2014 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/Compiler.java Thu Oct 09 04:48:12 2014 -0700
@@ -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 @@
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<Void>() {
- 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 @@
* @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 @@
* @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 @@
* @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() { }
}
--- a/jdk/src/java.base/share/classes/java/lang/Runtime.java Tue Oct 07 15:16:17 2014 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/Runtime.java Thu Oct 09 04:48:12 2014 -0700
@@ -730,7 +730,7 @@
* @param on <code>true</code> to enable instruction tracing;
* <code>false</code> 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 @@
* @param on <code>true</code> to enable instruction tracing;
* <code>false</code> 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
--- a/jdk/src/java.base/share/native/include/jvm.h Tue Oct 07 15:16:17 2014 +0200
+++ b/jdk/src/java.base/share/native/include/jvm.h Thu Oct 09 04:48:12 2014 -0700
@@ -111,19 +111,11 @@
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);
JNIEXPORT void JNICALL
@@ -146,12 +138,6 @@
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);
@@ -177,12 +163,6 @@
JVM_IsSupportedJNIVersion(jint version);
/*
- * java.lang.Float and java.lang.Double
- */
-JNIEXPORT jboolean JNICALL
-JVM_IsNaN(jdouble d);
-
-/*
* java.lang.Throwable
*/
JNIEXPORT void JNICALL
@@ -195,30 +175,6 @@
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
*/
JNIEXPORT void JNICALL
@@ -304,25 +260,9 @@
* 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
*/
JNIEXPORT jint JNICALL
@@ -373,11 +313,6 @@
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 @@
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
@@ -1134,150 +1032,6 @@
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 @@
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
--- a/jdk/src/java.base/share/native/libjava/ClassLoader.c Tue Oct 07 15:16:17 2014 +0200
+++ b/jdk/src/java.base/share/native/libjava/ClassLoader.c Thu Oct 09 04:48:12 2014 -0700
@@ -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 @@
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.
*/
--- a/jdk/src/java.base/share/native/libjava/Compiler.c Tue Oct 07 15:16:17 2014 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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]);
-}
--- a/jdk/src/java.base/share/native/libjava/Runtime.c Tue Oct 07 15:16:17 2014 +0200
+++ b/jdk/src/java.base/share/native/libjava/Runtime.c Thu Oct 09 04:48:12 2014 -0700
@@ -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
@@ -66,18 +66,6 @@
}
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)
{
jclass cl;
--- a/jdk/src/java.base/share/native/libjava/io_util.h Tue Oct 07 15:16:17 2014 +0200
+++ b/jdk/src/java.base/share/native/libjava/io_util.h Thu Oct 09 04:48:12 2014 -0700
@@ -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 @@
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:
--- a/jdk/src/java.base/share/native/libjava/jni_util.c Tue Oct 07 15:16:17 2014 +0200
+++ b/jdk/src/java.base/share/native/libjava/jni_util.c Thu Oct 09 04:48:12 2014 -0700
@@ -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 @@
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);
--- a/jdk/src/java.base/share/native/libjava/jni_util.h Tue Oct 07 15:16:17 2014 +0200
+++ b/jdk/src/java.base/share/native/libjava/jni_util.h Thu Oct 09 04:48:12 2014 -0700
@@ -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 buildJniFunctionName(const char *sym, const char *cname,
char *jniEntryName);
+extern size_t getLastErrorString(char *buf, size_t len);
#ifdef __cplusplus
} /* extern "C" */
#endif /* __cplusplus */
--- a/jdk/src/java.base/share/native/libzip/ZipFile.c Tue Oct 07 15:16:17 2014 +0200
+++ b/jdk/src/java.base/share/native/libzip/ZipFile.c Thu Oct 09 04:48:12 2014 -0700
@@ -93,24 +93,27 @@
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);
}
--- a/jdk/src/java.base/share/native/libzip/zip_util.c Tue Oct 07 15:16:17 2014 +0200
+++ b/jdk/src/java.base/share/native/libzip/zip_util.c Thu Oct 09 04:48:12 2014 -0700
@@ -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 @@
flagsAndAttributes, /* flags and attributes */
NULL);
#else
- return JVM_Open(fname, flags, 0);
+ return open(fname, flags, 0);
#endif
}
@@ -136,7 +136,7 @@
#ifdef WIN32
CloseHandle((HANDLE) zfd);
#else
- JVM_Close(zfd);
+ close(zfd);
#endif
}
@@ -145,14 +145,6 @@
#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 @@
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->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 @@
*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);
--- a/jdk/src/java.base/unix/native/include/jvm_md.h Tue Oct 07 15:16:17 2014 +0200
+++ b/jdk/src/java.base/unix/native/include/jvm_md.h Thu Oct 09 04:48:12 2014 -0700
@@ -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 */
--- a/jdk/src/java.base/unix/native/libjava/io_util_md.c Tue Oct 07 15:16:17 2014 +0200
+++ b/jdk/src/java.base/unix/native/libjava/io_util_md.c Thu Oct 09 04:48:12 2014 -0700
@@ -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 @@
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;
-}
--- a/jdk/src/java.base/unix/native/libjava/jni_util_md.c Tue Oct 07 15:16:17 2014 +0200
+++ b/jdk/src/java.base/unix/native/libjava/jni_util_md.c Thu Oct 09 04:48:12 2014 -0700
@@ -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 <errno.h>
#include <string.h>
#include "jni.h"
@@ -51,3 +52,17 @@
}
}
+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;
+}
--- a/jdk/src/java.base/windows/native/include/jvm_md.h Tue Oct 07 15:16:17 2014 +0200
+++ b/jdk/src/java.base/windows/native/include/jvm_md.h Thu Oct 09 04:48:12 2014 -0700
@@ -97,7 +97,6 @@
#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 */
--- a/jdk/src/java.base/windows/native/libjava/io_util_md.c Tue Oct 07 15:16:17 2014 +0200
+++ b/jdk/src/java.base/windows/native/libjava/io_util_md.c Thu Oct 09 04:48:12 2014 -0700
@@ -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 @@
}
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;
-}
--- a/jdk/src/java.base/windows/native/libjava/jni_util_md.c Tue Oct 07 15:16:17 2014 +0200
+++ b/jdk/src/java.base/windows/native/libjava/jni_util_md.c Thu Oct 09 04:48:12 2014 -0700
@@ -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 @@
}
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;
+}