Mercurial > hg > graal-compiler
changeset 22519:782cccbfa453
added test for Unsafe.allocateInstance
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Thu, 27 Aug 2015 11:15:35 +0200 |
parents | f5a11121bbee |
children | 412c6ac963ed |
files | graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/UnsafeSubstitutionsTest.java |
diffstat | 1 files changed, 29 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/UnsafeSubstitutionsTest.java Thu Aug 27 09:59:35 2015 +0200 +++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/UnsafeSubstitutionsTest.java Thu Aug 27 11:15:35 2015 +0200 @@ -349,6 +349,35 @@ return unsafeDirectMemoryRead(unsafe, address); } + static class MyObject { + int i = 42; + final int j = 24; + final String a = "a"; + final String b; + + public MyObject(String b) { + this.b = b; + Thread.dumpStack(); + } + + @Override + public String toString() { + return j + a + b + i; + } + } + + @SuppressWarnings("all") + public static String unsafeAllocateInstance(Unsafe unsafe) throws InstantiationException { + return unsafe.allocateInstance(MyObject.class).toString(); + } + + @Test + public void testAllocateInstance() throws Exception { + System.out.println("result: " + unsafeAllocateInstance(unsafe)); + test("unsafeAllocateInstance", unsafe); + test("unsafeAllocateInstance", (Object) null); + } + @Test public void testGetAndAddInt() throws Exception { Foo f1 = new Foo();