Java Code Examples for sun.misc.Unsafe#setMemory()
The following examples show how to use
sun.misc.Unsafe#setMemory() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CopyMemory.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static void testSetByteArray(Unsafe unsafe) throws Exception { System.out.println("Testing setMemory() for byte[]..."); byte[] b = new byte[BUFFER_SIZE]; for (int i = 0; i < N; i++) { set(b, 0, BUFFER_SIZE, FILLER); int ofs = random.nextInt(BUFFER_SIZE / 2); int len = random.nextInt(BUFFER_SIZE / 2); int val = random.nextInt(256); unsafe.setMemory(b, Unsafe.ARRAY_BYTE_BASE_OFFSET + ofs, len, (byte)val); check(b, 0, ofs - 1, FILLER); check(b, ofs, len, val); check(b, ofs + len, BUFFER_SIZE - (ofs + len), FILLER); } }
Example 2
Source File: CopyMemory.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private static void testSetByteArray(Unsafe unsafe) throws Exception { System.out.println("Testing setMemory() for byte[]..."); byte[] b = new byte[BUFFER_SIZE]; for (int i = 0; i < N; i++) { set(b, 0, BUFFER_SIZE, FILLER); int ofs = random.nextInt(BUFFER_SIZE / 2); int len = random.nextInt(BUFFER_SIZE / 2); int val = random.nextInt(256); unsafe.setMemory(b, Unsafe.ARRAY_BYTE_BASE_OFFSET + ofs, len, (byte)val); check(b, 0, ofs - 1, FILLER); check(b, ofs, len, val); check(b, ofs + len, BUFFER_SIZE - (ofs + len), FILLER); } }
Example 3
Source File: CopyMemory.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static void testSetRawMemory(Unsafe unsafe) throws Exception { System.out.println("Testing setMemory() for raw memory..."); long b = getMemory(BUFFER_SIZE); for (int i = 0; i < N; i++) { set(unsafe, b, 0, BUFFER_SIZE, FILLER); int ofs = random.nextInt(BUFFER_SIZE / 2); int len = random.nextInt(BUFFER_SIZE / 2); int val = random.nextInt(256); unsafe.setMemory(null, b + ofs, len, (byte)val); check(unsafe, b, 0, ofs - 1, FILLER); check(unsafe, b, ofs, len, val); check(unsafe, b, ofs + len, BUFFER_SIZE - (ofs + len), FILLER); } }
Example 4
Source File: CopyMemory.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
private static void testSetByteArray(Unsafe unsafe) throws Exception { System.out.println("Testing setMemory() for byte[]..."); byte[] b = new byte[BUFFER_SIZE]; for (int i = 0; i < N; i++) { set(b, 0, BUFFER_SIZE, FILLER); int ofs = random.nextInt(BUFFER_SIZE / 2); int len = random.nextInt(BUFFER_SIZE / 2); int val = random.nextInt(256); unsafe.setMemory(b, Unsafe.ARRAY_BYTE_BASE_OFFSET + ofs, len, (byte)val); check(b, 0, ofs - 1, FILLER); check(b, ofs, len, val); check(b, ofs + len, BUFFER_SIZE - (ofs + len), FILLER); } }
Example 5
Source File: CopyMemory.java From hottub with GNU General Public License v2.0 | 5 votes |
private static void testSetRawMemory(Unsafe unsafe) throws Exception { System.out.println("Testing setMemory() for raw memory..."); long b = getMemory(BUFFER_SIZE); for (int i = 0; i < N; i++) { set(unsafe, b, 0, BUFFER_SIZE, FILLER); int ofs = random.nextInt(BUFFER_SIZE / 2); int len = random.nextInt(BUFFER_SIZE / 2); int val = random.nextInt(256); unsafe.setMemory(null, b + ofs, len, (byte)val); check(unsafe, b, 0, ofs - 1, FILLER); check(unsafe, b, ofs, len, val); check(unsafe, b, ofs + len, BUFFER_SIZE - (ofs + len), FILLER); } }
Example 6
Source File: CopyMemory.java From hottub with GNU General Public License v2.0 | 5 votes |
private static void testSetByteArray(Unsafe unsafe) throws Exception { System.out.println("Testing setMemory() for byte[]..."); byte[] b = new byte[BUFFER_SIZE]; for (int i = 0; i < N; i++) { set(b, 0, BUFFER_SIZE, FILLER); int ofs = random.nextInt(BUFFER_SIZE / 2); int len = random.nextInt(BUFFER_SIZE / 2); int val = random.nextInt(256); unsafe.setMemory(b, Unsafe.ARRAY_BYTE_BASE_OFFSET + ofs, len, (byte)val); check(b, 0, ofs - 1, FILLER); check(b, ofs, len, val); check(b, ofs + len, BUFFER_SIZE - (ofs + len), FILLER); } }
Example 7
Source File: CopyMemory.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static void testSetRawMemory(Unsafe unsafe) throws Exception { System.out.println("Testing setMemory() for raw memory..."); long b = getMemory(BUFFER_SIZE); for (int i = 0; i < N; i++) { set(unsafe, b, 0, BUFFER_SIZE, FILLER); int ofs = random.nextInt(BUFFER_SIZE / 2); int len = random.nextInt(BUFFER_SIZE / 2); int val = random.nextInt(256); unsafe.setMemory(null, b + ofs, len, (byte)val); check(unsafe, b, 0, ofs - 1, FILLER); check(unsafe, b, ofs, len, val); check(unsafe, b, ofs + len, BUFFER_SIZE - (ofs + len), FILLER); } }
Example 8
Source File: CopyMemory.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static void testSetByteArray(Unsafe unsafe) throws Exception { System.out.println("Testing setMemory() for byte[]..."); byte[] b = new byte[BUFFER_SIZE]; for (int i = 0; i < N; i++) { set(b, 0, BUFFER_SIZE, FILLER); int ofs = random.nextInt(BUFFER_SIZE / 2); int len = random.nextInt(BUFFER_SIZE / 2); int val = random.nextInt(256); unsafe.setMemory(b, Unsafe.ARRAY_BYTE_BASE_OFFSET + ofs, len, (byte)val); check(b, 0, ofs - 1, FILLER); check(b, ofs, len, val); check(b, ofs + len, BUFFER_SIZE - (ofs + len), FILLER); } }
Example 9
Source File: CopyMemory.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static void testSetRawMemory(Unsafe unsafe) throws Exception { System.out.println("Testing setMemory() for raw memory..."); long b = getMemory(BUFFER_SIZE); for (int i = 0; i < N; i++) { set(unsafe, b, 0, BUFFER_SIZE, FILLER); int ofs = random.nextInt(BUFFER_SIZE / 2); int len = random.nextInt(BUFFER_SIZE / 2); int val = random.nextInt(256); unsafe.setMemory(null, b + ofs, len, (byte)val); check(unsafe, b, 0, ofs - 1, FILLER); check(unsafe, b, ofs, len, val); check(unsafe, b, ofs + len, BUFFER_SIZE - (ofs + len), FILLER); } }
Example 10
Source File: CopyMemory.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private static void testSetRawMemory(Unsafe unsafe) throws Exception { System.out.println("Testing setMemory() for raw memory..."); long b = getMemory(BUFFER_SIZE); for (int i = 0; i < N; i++) { set(unsafe, b, 0, BUFFER_SIZE, FILLER); int ofs = random.nextInt(BUFFER_SIZE / 2); int len = random.nextInt(BUFFER_SIZE / 2); int val = random.nextInt(256); unsafe.setMemory(null, b + ofs, len, (byte)val); check(unsafe, b, 0, ofs - 1, FILLER); check(unsafe, b, ofs, len, val); check(unsafe, b, ofs + len, BUFFER_SIZE - (ofs + len), FILLER); } }
Example 11
Source File: CopyMemory.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private static void testSetRawMemory(Unsafe unsafe) throws Exception { System.out.println("Testing setMemory() for raw memory..."); long b = getMemory(BUFFER_SIZE); for (int i = 0; i < N; i++) { set(unsafe, b, 0, BUFFER_SIZE, FILLER); int ofs = random.nextInt(BUFFER_SIZE / 2); int len = random.nextInt(BUFFER_SIZE / 2); int val = random.nextInt(256); unsafe.setMemory(null, b + ofs, len, (byte)val); check(unsafe, b, 0, ofs - 1, FILLER); check(unsafe, b, ofs, len, val); check(unsafe, b, ofs + len, BUFFER_SIZE - (ofs + len), FILLER); } }
Example 12
Source File: CopyMemory.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private static void testSetByteArray(Unsafe unsafe) throws Exception { System.out.println("Testing setMemory() for byte[]..."); byte[] b = new byte[BUFFER_SIZE]; for (int i = 0; i < N; i++) { set(b, 0, BUFFER_SIZE, FILLER); int ofs = random.nextInt(BUFFER_SIZE / 2); int len = random.nextInt(BUFFER_SIZE / 2); int val = random.nextInt(256); unsafe.setMemory(b, Unsafe.ARRAY_BYTE_BASE_OFFSET + ofs, len, (byte)val); check(b, 0, ofs - 1, FILLER); check(b, ofs, len, val); check(b, ofs + len, BUFFER_SIZE - (ofs + len), FILLER); } }
Example 13
Source File: CopyMemory.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
private static void testSetRawMemory(Unsafe unsafe) throws Exception { System.out.println("Testing setMemory() for raw memory..."); long b = getMemory(BUFFER_SIZE); for (int i = 0; i < N; i++) { set(unsafe, b, 0, BUFFER_SIZE, FILLER); int ofs = random.nextInt(BUFFER_SIZE / 2); int len = random.nextInt(BUFFER_SIZE / 2); int val = random.nextInt(256); unsafe.setMemory(null, b + ofs, len, (byte)val); check(unsafe, b, 0, ofs - 1, FILLER); check(unsafe, b, ofs, len, val); check(unsafe, b, ofs + len, BUFFER_SIZE - (ofs + len), FILLER); } }
Example 14
Source File: CopyMemory.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private static void testSetByteArray(Unsafe unsafe) throws Exception { System.out.println("Testing setMemory() for byte[]..."); byte[] b = new byte[BUFFER_SIZE]; for (int i = 0; i < N; i++) { set(b, 0, BUFFER_SIZE, FILLER); int ofs = random.nextInt(BUFFER_SIZE / 2); int len = random.nextInt(BUFFER_SIZE / 2); int val = random.nextInt(256); unsafe.setMemory(b, Unsafe.ARRAY_BYTE_BASE_OFFSET + ofs, len, (byte)val); check(b, 0, ofs - 1, FILLER); check(b, ofs, len, val); check(b, ofs + len, BUFFER_SIZE - (ofs + len), FILLER); } }
Example 15
Source File: CopyMemory.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private static void testSetRawMemory(Unsafe unsafe) throws Exception { System.out.println("Testing setMemory() for raw memory..."); long b = getMemory(BUFFER_SIZE); for (int i = 0; i < N; i++) { set(unsafe, b, 0, BUFFER_SIZE, FILLER); int ofs = random.nextInt(BUFFER_SIZE / 2); int len = random.nextInt(BUFFER_SIZE / 2); int val = random.nextInt(256); unsafe.setMemory(null, b + ofs, len, (byte)val); check(unsafe, b, 0, ofs - 1, FILLER); check(unsafe, b, ofs, len, val); check(unsafe, b, ofs + len, BUFFER_SIZE - (ofs + len), FILLER); } }
Example 16
Source File: CopyMemory.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private static void testSetByteArray(Unsafe unsafe) throws Exception { System.out.println("Testing setMemory() for byte[]..."); byte[] b = new byte[BUFFER_SIZE]; for (int i = 0; i < N; i++) { set(b, 0, BUFFER_SIZE, FILLER); int ofs = random.nextInt(BUFFER_SIZE / 2); int len = random.nextInt(BUFFER_SIZE / 2); int val = random.nextInt(256); unsafe.setMemory(b, Unsafe.ARRAY_BYTE_BASE_OFFSET + ofs, len, (byte)val); check(b, 0, ofs - 1, FILLER); check(b, ofs, len, val); check(b, ofs + len, BUFFER_SIZE - (ofs + len), FILLER); } }
Example 17
Source File: CopyMemory.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private static void testSetRawMemory(Unsafe unsafe) throws Exception { System.out.println("Testing setMemory() for raw memory..."); long b = getMemory(BUFFER_SIZE); for (int i = 0; i < N; i++) { set(unsafe, b, 0, BUFFER_SIZE, FILLER); int ofs = random.nextInt(BUFFER_SIZE / 2); int len = random.nextInt(BUFFER_SIZE / 2); int val = random.nextInt(256); unsafe.setMemory(null, b + ofs, len, (byte)val); check(unsafe, b, 0, ofs - 1, FILLER); check(unsafe, b, ofs, len, val); check(unsafe, b, ofs + len, BUFFER_SIZE - (ofs + len), FILLER); } }
Example 18
Source File: CopyMemory.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private static void testSetByteArray(Unsafe unsafe) throws Exception { System.out.println("Testing setMemory() for byte[]..."); byte[] b = new byte[BUFFER_SIZE]; for (int i = 0; i < N; i++) { set(b, 0, BUFFER_SIZE, FILLER); int ofs = random.nextInt(BUFFER_SIZE / 2); int len = random.nextInt(BUFFER_SIZE / 2); int val = random.nextInt(256); unsafe.setMemory(b, Unsafe.ARRAY_BYTE_BASE_OFFSET + ofs, len, (byte)val); check(b, 0, ofs - 1, FILLER); check(b, ofs, len, val); check(b, ofs + len, BUFFER_SIZE - (ofs + len), FILLER); } }
Example 19
Source File: CopyMemory.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private static void testSetRawMemory(Unsafe unsafe) throws Exception { System.out.println("Testing setMemory() for raw memory..."); long b = getMemory(BUFFER_SIZE); for (int i = 0; i < N; i++) { set(unsafe, b, 0, BUFFER_SIZE, FILLER); int ofs = random.nextInt(BUFFER_SIZE / 2); int len = random.nextInt(BUFFER_SIZE / 2); int val = random.nextInt(256); unsafe.setMemory(null, b + ofs, len, (byte)val); check(unsafe, b, 0, ofs - 1, FILLER); check(unsafe, b, ofs, len, val); check(unsafe, b, ofs + len, BUFFER_SIZE - (ofs + len), FILLER); } }
Example 20
Source File: Crash.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws NoSuchFieldException, IllegalAccessException { Field f = Unsafe.class.getDeclaredField("theUnsafe"); f.setAccessible(true); Unsafe u = (Unsafe) f.get(null); u.setMemory(0, 42, (byte) 0xFF); }