2
Copyright (C) 2010 Jeroen Frijters
4
This software is provided 'as-is', without any express or implied
5
warranty. In no event will the authors be held liable for any damages
6
arising from the use of this software.
8
Permission is granted to anyone to use this software for any purpose,
9
including commercial applications, and to alter it and redistribute it
10
freely, subject to the following restrictions:
12
1. The origin of this software must not be misrepresented; you must not
13
claim that you wrote the original software. If you use this software
14
in a product, an acknowledgment in the product documentation would be
15
appreciated but is not required.
16
2. Altered source versions must be plainly marked as such, and must not be
17
misrepresented as being the original software.
18
3. This notice may not be removed or altered from any source distribution.
25
package ikvm.internal;
28
public final class JNI
30
public static final Object NULL = null;
31
public static final boolean TRUE = true;
32
public static final boolean FALSE = false;
33
public static final boolean JNI_TRUE = true;
34
public static final boolean JNI_FALSE = false;
36
public static final String JNU_JAVAIOPKG = "java.io.";
37
public static final String JNU_JAVANETPKG = "java.net.";
39
public static long JVM_CurrentTimeMillis(JNIEnv env, int ignored)
41
return System.currentTimeMillis();
44
public static void JNU_ThrowNullPointerException(JNIEnv env, String message)
46
env.Throw(new NullPointerException(message));
49
public static void JNU_ThrowByName(JNIEnv env, String exceptionClass, String message)
51
if (exceptionClass.equals("java.net.SocketException"))
53
env.Throw(new java.net.SocketException(message));
55
else if (exceptionClass.equals("java.net.SocketTimeoutException"))
57
env.Throw(new java.net.SocketTimeoutException(message));
59
else if (exceptionClass.equals("java.net.PortUnreachableException"))
61
env.Throw(new java.net.PortUnreachableException(message));
63
else if (exceptionClass.equals("java.io.InterruptedIOException"))
65
env.Throw(new java.io.InterruptedIOException(message));
71
env.ThrowNew(Class.forName(exceptionClass), message);
73
catch (ClassNotFoundException x)
80
public static final class JNIEnv
82
private Throwable pendingException;
84
public void Throw(Throwable t)
89
public void ThrowNew(Class c, String msg)
93
pendingException = (Throwable)c.getConstructor(String.class).newInstance(msg);
101
public Throwable ExceptionOccurred()
103
return pendingException;
106
public void ThrowPendingException()
108
if (pendingException != null)
110
sun.misc.Unsafe.getUnsafe().throwException(pendingException);