8057777: Cleanup of old and unused VM interfaces
Reviewed-by: coleenp, hseigel, alanb, sherman
This commit is contained in:
parent
8848e6168c
commit
fee63b862f
@ -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, \
|
||||
|
@ -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().
|
||||
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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 <a href="#name">binary name</a>,
|
||||
* loading it if necessary.
|
||||
|
@ -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<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 @@ 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() { }
|
||||
}
|
||||
|
@ -730,7 +730,7 @@ public class Runtime {
|
||||
* @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 @@ public class Runtime {
|
||||
* @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
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
*/
|
||||
|
@ -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]);
|
||||
}
|
@ -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)
|
||||
{
|
||||
|
@ -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:
|
||||
|
@ -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);
|
||||
|
@ -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 */
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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 @@ 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;
|
||||
}
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user