You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2011/04/19 10:33:57 UTC
svn commit: r1094924 - in /commons/sandbox/runtime/trunk/src/main:
java/org/apache/commons/runtime/NativeShutdownHook.java
java/org/apache/commons/runtime/Platform.java native/os/unix/platform.c
native/os/win32/platform.c
Author: mturk
Date: Tue Apr 19 08:33:56 2011
New Revision: 1094924
URL: http://svn.apache.org/viewvc?rev=1094924&view=rev
Log:
Add Platform.SIZE_T_MAX for checking overflows in java
Modified:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/NativeShutdownHook.java
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Platform.java
commons/sandbox/runtime/trunk/src/main/native/os/unix/platform.c
commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c
Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/NativeShutdownHook.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/NativeShutdownHook.java?rev=1094924&r1=1094923&r2=1094924&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/NativeShutdownHook.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/NativeShutdownHook.java Tue Apr 19 08:33:56 2011
@@ -27,6 +27,8 @@ final class NativeShutdownHook extends T
{
}
+
+ @Override
public void run()
{
Native.terminate();
Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Platform.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Platform.java?rev=1094924&r1=1094923&r2=1094924&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Platform.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Platform.java Tue Apr 19 08:33:56 2011
@@ -24,7 +24,7 @@ import java.nio.charset.Charset;
* @since Runtime 1.0
*
*/
-final class Platform
+public final class Platform
{
private Platform()
@@ -47,6 +47,7 @@ final class Platform
*/
private static native void init0(int cp);
private static native void init1(int[] p);
+ private static native long init2();
private static final int getDefaultCharset()
{
int cs;
@@ -86,7 +87,8 @@ final class Platform
MAX_PATH_ELEMENT = i[6];
MAX_PATH = i[7];
PAGESIZE = i[8];
- GRANULARITY = i[9];
+ ALLOCTION_GRANULARITY = i[9];
+ SIZE_T_MAX = init2();
}
/**
@@ -141,7 +143,12 @@ final class Platform
* The granualarity of the starting address at wich {@code memory} pages
* can be allocated.
*/
- public static final int GRANULARITY;
+ public static final int ALLOCTION_GRANULARITY;
+
+ /**
+ * Maximum value of native {@code size_t} type.
+ */
+ public static final long SIZE_T_MAX;
}
Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/platform.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/platform.c?rev=1094924&r1=1094923&r2=1094924&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/platform.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/platform.c Tue Apr 19 08:33:56 2011
@@ -56,6 +56,12 @@ ACR_JNI_EXPORT(void, Platform, init1)(JN
(*env)->SetIntArrayRegion(env, p, 0, 16, ia);
}
+ACR_JNI_EXPORT(jlong, Platform, init2)(JNI_STDARGS)
+{
+ jlong rv = ACR_I64_C(0);
+ return rv + SIZE_T_MAX;
+}
+
ACR_JNI_EXPORT(jboolean, Platform, supported0)(JNI_STDARGS)
{
UNREFERENCED_STDARGS;
Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c?rev=1094924&r1=1094923&r2=1094924&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c Tue Apr 19 08:33:56 2011
@@ -56,6 +56,12 @@ ACR_JNI_EXPORT(void, Platform, init1)(JN
(*env)->SetIntArrayRegion(env, p, 0, 16, ia);
}
+ACR_JNI_EXPORT(jlong, Platform, init2)(JNI_STDARGS)
+{
+ jlong rv = ACR_I64_C(0);
+ return rv + SIZE_T_MAX;
+}
+
ACR_JNI_EXPORT(jboolean, Platform, supported0)(JNI_STDARGS)
{
UNREFERENCED_STDARGS;