com.apple.jobjc.Invoke.FunCall Java Examples

The following examples show how to use com.apple.jobjc.Invoke.FunCall. 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: FunctionTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public void testInvokeOneParam() throws Throwable {
    final FunCall getHomeDirFxn = UnsafeRuntimeAccess.createFunCall(TestUtils.getAppKit(), "NSHomeDirectory", PointerCoder.INST);

    getHomeDirFxn.init(nativeBuffer);
    getHomeDirFxn.invoke(nativeBuffer);

    final long homeDirPtr = PrimitivePointerCoder.INST.pop(nativeBuffer);
    System.out.println("0x" + Long.toHexString(homeDirPtr) + ": " + UnsafeRuntimeAccess.getDescriptionForPtr(homeDirPtr));

    final FunCall getTypeOfFxn = UnsafeRuntimeAccess.createFunCall(TestUtils.getFoundation(), "NSLog", PointerCoder.INST, PointerCoder.INST);
    getTypeOfFxn.init(nativeBuffer);
    PrimitivePointerCoder.INST.push(runtime, nativeBuffer, homeDirPtr);
    getTypeOfFxn.invoke(nativeBuffer);

//    long typePtr = PointerCoder.pointer_coder.popPtr(nativeBuffer);
//    System.out.println("0x" + Long.toHexString(typePtr) + ": " + TestUtils.getDescriptionForPtr(typePtr));
}
 
Example #2
Source File: IntroTest.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void testCore(){
    // pass security check and get ahold of a runtime (should cache this)
    final JObjCRuntime RUNTIME = JObjCRuntime.getInstance();
    final NativeArgumentBuffer ARGS = JObjCRuntime.getInstance().getThreadLocalState();

    // create a funcall (should cache this)
    final FunCall fc = new FunCall(RUNTIME, "sin", DoubleCoder.INST, DoubleCoder.INST);

    // start function call
    fc.init(ARGS);
    // push an arg
    DoubleCoder.INST.push(ARGS, 3.14159265 / 2.0);
    // make the call
    fc.invoke(ARGS);
    // read the return value
    double ret = DoubleCoder.INST.pop(ARGS);

    assertEquals(1.0, ret);
}
 
Example #3
Source File: FunctionTest.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void testInvokeOneParam() throws Throwable {
    final FunCall getHomeDirFxn = UnsafeRuntimeAccess.createFunCall(TestUtils.getAppKit(), "NSHomeDirectory", PointerCoder.INST);

    getHomeDirFxn.init(nativeBuffer);
    getHomeDirFxn.invoke(nativeBuffer);

    final long homeDirPtr = PrimitivePointerCoder.INST.pop(nativeBuffer);
    System.out.println("0x" + Long.toHexString(homeDirPtr) + ": " + UnsafeRuntimeAccess.getDescriptionForPtr(homeDirPtr));

    final FunCall getTypeOfFxn = UnsafeRuntimeAccess.createFunCall(TestUtils.getFoundation(), "NSLog", PointerCoder.INST, PointerCoder.INST);
    getTypeOfFxn.init(nativeBuffer);
    PrimitivePointerCoder.INST.push(runtime, nativeBuffer, homeDirPtr);
    getTypeOfFxn.invoke(nativeBuffer);

//    long typePtr = PointerCoder.pointer_coder.popPtr(nativeBuffer);
//    System.out.println("0x" + Long.toHexString(typePtr) + ": " + TestUtils.getDescriptionForPtr(typePtr));
}
 
Example #4
Source File: FunctionTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public void testInvokeOneParam() throws Throwable {
    final FunCall getHomeDirFxn = UnsafeRuntimeAccess.createFunCall(TestUtils.getAppKit(), "NSHomeDirectory", PointerCoder.INST);

    getHomeDirFxn.init(nativeBuffer);
    getHomeDirFxn.invoke(nativeBuffer);

    final long homeDirPtr = PrimitivePointerCoder.INST.pop(nativeBuffer);
    System.out.println("0x" + Long.toHexString(homeDirPtr) + ": " + UnsafeRuntimeAccess.getDescriptionForPtr(homeDirPtr));

    final FunCall getTypeOfFxn = UnsafeRuntimeAccess.createFunCall(TestUtils.getFoundation(), "NSLog", PointerCoder.INST, PointerCoder.INST);
    getTypeOfFxn.init(nativeBuffer);
    PrimitivePointerCoder.INST.push(runtime, nativeBuffer, homeDirPtr);
    getTypeOfFxn.invoke(nativeBuffer);

//    long typePtr = PointerCoder.pointer_coder.popPtr(nativeBuffer);
//    System.out.println("0x" + Long.toHexString(typePtr) + ": " + TestUtils.getDescriptionForPtr(typePtr));
}
 
Example #5
Source File: FunctionTest.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public void testInvokeOneParam() throws Throwable {
    final FunCall getHomeDirFxn = UnsafeRuntimeAccess.createFunCall(TestUtils.getAppKit(), "NSHomeDirectory", PointerCoder.INST);

    getHomeDirFxn.init(nativeBuffer);
    getHomeDirFxn.invoke(nativeBuffer);

    final long homeDirPtr = PrimitivePointerCoder.INST.pop(nativeBuffer);
    System.out.println("0x" + Long.toHexString(homeDirPtr) + ": " + UnsafeRuntimeAccess.getDescriptionForPtr(homeDirPtr));

    final FunCall getTypeOfFxn = UnsafeRuntimeAccess.createFunCall(TestUtils.getFoundation(), "NSLog", PointerCoder.INST, PointerCoder.INST);
    getTypeOfFxn.init(nativeBuffer);
    PrimitivePointerCoder.INST.push(runtime, nativeBuffer, homeDirPtr);
    getTypeOfFxn.invoke(nativeBuffer);

//    long typePtr = PointerCoder.pointer_coder.popPtr(nativeBuffer);
//    System.out.println("0x" + Long.toHexString(typePtr) + ": " + TestUtils.getDescriptionForPtr(typePtr));
}
 
Example #6
Source File: IntroTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public void testCore(){
    // pass security check and get ahold of a runtime (should cache this)
    final JObjCRuntime RUNTIME = JObjCRuntime.getInstance();
    final NativeArgumentBuffer ARGS = JObjCRuntime.getInstance().getThreadLocalState();

    // create a funcall (should cache this)
    final FunCall fc = new FunCall(RUNTIME, "sin", DoubleCoder.INST, DoubleCoder.INST);

    // start function call
    fc.init(ARGS);
    // push an arg
    DoubleCoder.INST.push(ARGS, 3.14159265 / 2.0);
    // make the call
    fc.invoke(ARGS);
    // read the return value
    double ret = DoubleCoder.INST.pop(ARGS);

    assertEquals(1.0, ret);
}
 
Example #7
Source File: IntroTest.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public void testCore(){
    // pass security check and get ahold of a runtime (should cache this)
    final JObjCRuntime RUNTIME = JObjCRuntime.getInstance();
    final NativeArgumentBuffer ARGS = JObjCRuntime.getInstance().getThreadLocalState();

    // create a funcall (should cache this)
    final FunCall fc = new FunCall(RUNTIME, "sin", DoubleCoder.INST, DoubleCoder.INST);

    // start function call
    fc.init(ARGS);
    // push an arg
    DoubleCoder.INST.push(ARGS, 3.14159265 / 2.0);
    // make the call
    fc.invoke(ARGS);
    // read the return value
    double ret = DoubleCoder.INST.pop(ARGS);

    assertEquals(1.0, ret);
}
 
Example #8
Source File: FunctionTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public void testInvokeOneParam() throws Throwable {
    final FunCall getHomeDirFxn = UnsafeRuntimeAccess.createFunCall(TestUtils.getAppKit(), "NSHomeDirectory", PointerCoder.INST);

    getHomeDirFxn.init(nativeBuffer);
    getHomeDirFxn.invoke(nativeBuffer);

    final long homeDirPtr = PrimitivePointerCoder.INST.pop(nativeBuffer);
    System.out.println("0x" + Long.toHexString(homeDirPtr) + ": " + UnsafeRuntimeAccess.getDescriptionForPtr(homeDirPtr));

    final FunCall getTypeOfFxn = UnsafeRuntimeAccess.createFunCall(TestUtils.getFoundation(), "NSLog", PointerCoder.INST, PointerCoder.INST);
    getTypeOfFxn.init(nativeBuffer);
    PrimitivePointerCoder.INST.push(runtime, nativeBuffer, homeDirPtr);
    getTypeOfFxn.invoke(nativeBuffer);

//    long typePtr = PointerCoder.pointer_coder.popPtr(nativeBuffer);
//    System.out.println("0x" + Long.toHexString(typePtr) + ": " + TestUtils.getDescriptionForPtr(typePtr));
}
 
Example #9
Source File: FunctionTest.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public void testInvokeOneParam() throws Throwable {
    final FunCall getHomeDirFxn = UnsafeRuntimeAccess.createFunCall(TestUtils.getAppKit(), "NSHomeDirectory", PointerCoder.INST);

    getHomeDirFxn.init(nativeBuffer);
    getHomeDirFxn.invoke(nativeBuffer);

    final long homeDirPtr = PrimitivePointerCoder.INST.pop(nativeBuffer);
    System.out.println("0x" + Long.toHexString(homeDirPtr) + ": " + UnsafeRuntimeAccess.getDescriptionForPtr(homeDirPtr));

    final FunCall getTypeOfFxn = UnsafeRuntimeAccess.createFunCall(TestUtils.getFoundation(), "NSLog", PointerCoder.INST, PointerCoder.INST);
    getTypeOfFxn.init(nativeBuffer);
    PrimitivePointerCoder.INST.push(runtime, nativeBuffer, homeDirPtr);
    getTypeOfFxn.invoke(nativeBuffer);

//    long typePtr = PointerCoder.pointer_coder.popPtr(nativeBuffer);
//    System.out.println("0x" + Long.toHexString(typePtr) + ": " + TestUtils.getDescriptionForPtr(typePtr));
}
 
Example #10
Source File: IntroTest.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public void testCore(){
    // pass security check and get ahold of a runtime (should cache this)
    final JObjCRuntime RUNTIME = JObjCRuntime.getInstance();
    final NativeArgumentBuffer ARGS = JObjCRuntime.getInstance().getThreadLocalState();

    // create a funcall (should cache this)
    final FunCall fc = new FunCall(RUNTIME, "sin", DoubleCoder.INST, DoubleCoder.INST);

    // start function call
    fc.init(ARGS);
    // push an arg
    DoubleCoder.INST.push(ARGS, 3.14159265 / 2.0);
    // make the call
    fc.invoke(ARGS);
    // read the return value
    double ret = DoubleCoder.INST.pop(ARGS);

    assertEquals(1.0, ret);
}
 
Example #11
Source File: FunctionTest.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public void testInvokeOneParam() throws Throwable {
    final FunCall getHomeDirFxn = UnsafeRuntimeAccess.createFunCall(TestUtils.getAppKit(), "NSHomeDirectory", PointerCoder.INST);

    getHomeDirFxn.init(nativeBuffer);
    getHomeDirFxn.invoke(nativeBuffer);

    final long homeDirPtr = PrimitivePointerCoder.INST.pop(nativeBuffer);
    System.out.println("0x" + Long.toHexString(homeDirPtr) + ": " + UnsafeRuntimeAccess.getDescriptionForPtr(homeDirPtr));

    final FunCall getTypeOfFxn = UnsafeRuntimeAccess.createFunCall(TestUtils.getFoundation(), "NSLog", PointerCoder.INST, PointerCoder.INST);
    getTypeOfFxn.init(nativeBuffer);
    PrimitivePointerCoder.INST.push(runtime, nativeBuffer, homeDirPtr);
    getTypeOfFxn.invoke(nativeBuffer);

//    long typePtr = PointerCoder.pointer_coder.popPtr(nativeBuffer);
//    System.out.println("0x" + Long.toHexString(typePtr) + ": " + TestUtils.getDescriptionForPtr(typePtr));
}
 
Example #12
Source File: FunctionTest.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public void testInvokeOneParam() throws Throwable {
    final FunCall getHomeDirFxn = UnsafeRuntimeAccess.createFunCall(TestUtils.getAppKit(), "NSHomeDirectory", PointerCoder.INST);

    getHomeDirFxn.init(nativeBuffer);
    getHomeDirFxn.invoke(nativeBuffer);

    final long homeDirPtr = PrimitivePointerCoder.INST.pop(nativeBuffer);
    System.out.println("0x" + Long.toHexString(homeDirPtr) + ": " + UnsafeRuntimeAccess.getDescriptionForPtr(homeDirPtr));

    final FunCall getTypeOfFxn = UnsafeRuntimeAccess.createFunCall(TestUtils.getFoundation(), "NSLog", PointerCoder.INST, PointerCoder.INST);
    getTypeOfFxn.init(nativeBuffer);
    PrimitivePointerCoder.INST.push(runtime, nativeBuffer, homeDirPtr);
    getTypeOfFxn.invoke(nativeBuffer);

//    long typePtr = PointerCoder.pointer_coder.popPtr(nativeBuffer);
//    System.out.println("0x" + Long.toHexString(typePtr) + ": " + TestUtils.getDescriptionForPtr(typePtr));
}
 
Example #13
Source File: FunctionTest.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public void testInvokeOneParam() throws Throwable {
    final FunCall getHomeDirFxn = UnsafeRuntimeAccess.createFunCall(TestUtils.getAppKit(), "NSHomeDirectory", PointerCoder.INST);

    getHomeDirFxn.init(nativeBuffer);
    getHomeDirFxn.invoke(nativeBuffer);

    final long homeDirPtr = PrimitivePointerCoder.INST.pop(nativeBuffer);
    System.out.println("0x" + Long.toHexString(homeDirPtr) + ": " + UnsafeRuntimeAccess.getDescriptionForPtr(homeDirPtr));

    final FunCall getTypeOfFxn = UnsafeRuntimeAccess.createFunCall(TestUtils.getFoundation(), "NSLog", PointerCoder.INST, PointerCoder.INST);
    getTypeOfFxn.init(nativeBuffer);
    PrimitivePointerCoder.INST.push(runtime, nativeBuffer, homeDirPtr);
    getTypeOfFxn.invoke(nativeBuffer);

//    long typePtr = PointerCoder.pointer_coder.popPtr(nativeBuffer);
//    System.out.println("0x" + Long.toHexString(typePtr) + ": " + TestUtils.getDescriptionForPtr(typePtr));
}
 
Example #14
Source File: IntroTest.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public void testCore(){
    // pass security check and get ahold of a runtime (should cache this)
    final JObjCRuntime RUNTIME = JObjCRuntime.getInstance();
    final NativeArgumentBuffer ARGS = JObjCRuntime.getInstance().getThreadLocalState();

    // create a funcall (should cache this)
    final FunCall fc = new FunCall(RUNTIME, "sin", DoubleCoder.INST, DoubleCoder.INST);

    // start function call
    fc.init(ARGS);
    // push an arg
    DoubleCoder.INST.push(ARGS, 3.14159265 / 2.0);
    // make the call
    fc.invoke(ARGS);
    // read the return value
    double ret = DoubleCoder.INST.pop(ARGS);

    assertEquals(1.0, ret);
}
 
Example #15
Source File: FunctionTest.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public void testInvokeOneParam() throws Throwable {
    final FunCall getHomeDirFxn = UnsafeRuntimeAccess.createFunCall(TestUtils.getAppKit(), "NSHomeDirectory", PointerCoder.INST);

    getHomeDirFxn.init(nativeBuffer);
    getHomeDirFxn.invoke(nativeBuffer);

    final long homeDirPtr = PrimitivePointerCoder.INST.pop(nativeBuffer);
    System.out.println("0x" + Long.toHexString(homeDirPtr) + ": " + UnsafeRuntimeAccess.getDescriptionForPtr(homeDirPtr));

    final FunCall getTypeOfFxn = UnsafeRuntimeAccess.createFunCall(TestUtils.getFoundation(), "NSLog", PointerCoder.INST, PointerCoder.INST);
    getTypeOfFxn.init(nativeBuffer);
    PrimitivePointerCoder.INST.push(runtime, nativeBuffer, homeDirPtr);
    getTypeOfFxn.invoke(nativeBuffer);

//    long typePtr = PointerCoder.pointer_coder.popPtr(nativeBuffer);
//    System.out.println("0x" + Long.toHexString(typePtr) + ": " + TestUtils.getDescriptionForPtr(typePtr));
}
 
Example #16
Source File: IntroTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public void testCore(){
    // pass security check and get ahold of a runtime (should cache this)
    final JObjCRuntime RUNTIME = JObjCRuntime.getInstance();
    final NativeArgumentBuffer ARGS = JObjCRuntime.getInstance().getThreadLocalState();

    // create a funcall (should cache this)
    final FunCall fc = new FunCall(RUNTIME, "sin", DoubleCoder.INST, DoubleCoder.INST);

    // start function call
    fc.init(ARGS);
    // push an arg
    DoubleCoder.INST.push(ARGS, 3.14159265 / 2.0);
    // make the call
    fc.invoke(ARGS);
    // read the return value
    double ret = DoubleCoder.INST.pop(ARGS);

    assertEquals(1.0, ret);
}
 
Example #17
Source File: IntroTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public void testCore(){
    // pass security check and get ahold of a runtime (should cache this)
    final JObjCRuntime RUNTIME = JObjCRuntime.getInstance();
    final NativeArgumentBuffer ARGS = JObjCRuntime.getInstance().getThreadLocalState();

    // create a funcall (should cache this)
    final FunCall fc = new FunCall(RUNTIME, "sin", DoubleCoder.INST, DoubleCoder.INST);

    // start function call
    fc.init(ARGS);
    // push an arg
    DoubleCoder.INST.push(ARGS, 3.14159265 / 2.0);
    // make the call
    fc.invoke(ARGS);
    // read the return value
    double ret = DoubleCoder.INST.pop(ARGS);

    assertEquals(1.0, ret);
}
 
Example #18
Source File: IntroTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public void testCore(){
    // pass security check and get ahold of a runtime (should cache this)
    final JObjCRuntime RUNTIME = JObjCRuntime.getInstance();
    final NativeArgumentBuffer ARGS = JObjCRuntime.getInstance().getThreadLocalState();

    // create a funcall (should cache this)
    final FunCall fc = new FunCall(RUNTIME, "sin", DoubleCoder.INST, DoubleCoder.INST);

    // start function call
    fc.init(ARGS);
    // push an arg
    DoubleCoder.INST.push(ARGS, 3.14159265 / 2.0);
    // make the call
    fc.invoke(ARGS);
    // read the return value
    double ret = DoubleCoder.INST.pop(ARGS);

    assertEquals(1.0, ret);
}
 
Example #19
Source File: FunctionTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public void testInvokeOneParam() throws Throwable {
    final FunCall getHomeDirFxn = UnsafeRuntimeAccess.createFunCall(TestUtils.getAppKit(), "NSHomeDirectory", PointerCoder.INST);

    getHomeDirFxn.init(nativeBuffer);
    getHomeDirFxn.invoke(nativeBuffer);

    final long homeDirPtr = PrimitivePointerCoder.INST.pop(nativeBuffer);
    System.out.println("0x" + Long.toHexString(homeDirPtr) + ": " + UnsafeRuntimeAccess.getDescriptionForPtr(homeDirPtr));

    final FunCall getTypeOfFxn = UnsafeRuntimeAccess.createFunCall(TestUtils.getFoundation(), "NSLog", PointerCoder.INST, PointerCoder.INST);
    getTypeOfFxn.init(nativeBuffer);
    PrimitivePointerCoder.INST.push(runtime, nativeBuffer, homeDirPtr);
    getTypeOfFxn.invoke(nativeBuffer);

//    long typePtr = PointerCoder.pointer_coder.popPtr(nativeBuffer);
//    System.out.println("0x" + Long.toHexString(typePtr) + ": " + TestUtils.getDescriptionForPtr(typePtr));
}
 
Example #20
Source File: IntroTest.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public void testCore(){
    // pass security check and get ahold of a runtime (should cache this)
    final JObjCRuntime RUNTIME = JObjCRuntime.getInstance();
    final NativeArgumentBuffer ARGS = JObjCRuntime.getInstance().getThreadLocalState();

    // create a funcall (should cache this)
    final FunCall fc = new FunCall(RUNTIME, "sin", DoubleCoder.INST, DoubleCoder.INST);

    // start function call
    fc.init(ARGS);
    // push an arg
    DoubleCoder.INST.push(ARGS, 3.14159265 / 2.0);
    // make the call
    fc.invoke(ARGS);
    // read the return value
    double ret = DoubleCoder.INST.pop(ARGS);

    assertEquals(1.0, ret);
}
 
Example #21
Source File: IntroTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public void testCore(){
    // pass security check and get ahold of a runtime (should cache this)
    final JObjCRuntime RUNTIME = JObjCRuntime.getInstance();
    final NativeArgumentBuffer ARGS = JObjCRuntime.getInstance().getThreadLocalState();

    // create a funcall (should cache this)
    final FunCall fc = new FunCall(RUNTIME, "sin", DoubleCoder.INST, DoubleCoder.INST);

    // start function call
    fc.init(ARGS);
    // push an arg
    DoubleCoder.INST.push(ARGS, 3.14159265 / 2.0);
    // make the call
    fc.invoke(ARGS);
    // read the return value
    double ret = DoubleCoder.INST.pop(ARGS);

    assertEquals(1.0, ret);
}
 
Example #22
Source File: IntroTest.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public void testCore(){
    // pass security check and get ahold of a runtime (should cache this)
    final JObjCRuntime RUNTIME = JObjCRuntime.getInstance();
    final NativeArgumentBuffer ARGS = JObjCRuntime.getInstance().getThreadLocalState();

    // create a funcall (should cache this)
    final FunCall fc = new FunCall(RUNTIME, "sin", DoubleCoder.INST, DoubleCoder.INST);

    // start function call
    fc.init(ARGS);
    // push an arg
    DoubleCoder.INST.push(ARGS, 3.14159265 / 2.0);
    // make the call
    fc.invoke(ARGS);
    // read the return value
    double ret = DoubleCoder.INST.pop(ARGS);

    assertEquals(1.0, ret);
}
 
Example #23
Source File: FunctionTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public void testInvokeOneParam() throws Throwable {
    final FunCall getHomeDirFxn = UnsafeRuntimeAccess.createFunCall(TestUtils.getAppKit(), "NSHomeDirectory", PointerCoder.INST);

    getHomeDirFxn.init(nativeBuffer);
    getHomeDirFxn.invoke(nativeBuffer);

    final long homeDirPtr = PrimitivePointerCoder.INST.pop(nativeBuffer);
    System.out.println("0x" + Long.toHexString(homeDirPtr) + ": " + UnsafeRuntimeAccess.getDescriptionForPtr(homeDirPtr));

    final FunCall getTypeOfFxn = UnsafeRuntimeAccess.createFunCall(TestUtils.getFoundation(), "NSLog", PointerCoder.INST, PointerCoder.INST);
    getTypeOfFxn.init(nativeBuffer);
    PrimitivePointerCoder.INST.push(runtime, nativeBuffer, homeDirPtr);
    getTypeOfFxn.invoke(nativeBuffer);

//    long typePtr = PointerCoder.pointer_coder.popPtr(nativeBuffer);
//    System.out.println("0x" + Long.toHexString(typePtr) + ": " + TestUtils.getDescriptionForPtr(typePtr));
}
 
Example #24
Source File: IntroTest.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public void testCore(){
    // pass security check and get ahold of a runtime (should cache this)
    final JObjCRuntime RUNTIME = JObjCRuntime.getInstance();
    final NativeArgumentBuffer ARGS = JObjCRuntime.getInstance().getThreadLocalState();

    // create a funcall (should cache this)
    final FunCall fc = new FunCall(RUNTIME, "sin", DoubleCoder.INST, DoubleCoder.INST);

    // start function call
    fc.init(ARGS);
    // push an arg
    DoubleCoder.INST.push(ARGS, 3.14159265 / 2.0);
    // make the call
    fc.invoke(ARGS);
    // read the return value
    double ret = DoubleCoder.INST.pop(ARGS);

    assertEquals(1.0, ret);
}
 
Example #25
Source File: FunctionTest.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void testInvokeNoParams() throws Throwable {
    final FunCall fxn = UnsafeRuntimeAccess.createFunCall(TestUtils.getFoundation(), "NSFullUserName", PointerCoder.INST);

    fxn.init(nativeBuffer);
    fxn.invoke(nativeBuffer);

    final long ptr = PrimitivePointerCoder.INST.pop(nativeBuffer);
    System.out.println("0x" + Long.toHexString(ptr) + ": " + UnsafeRuntimeAccess.getDescriptionForPtr(ptr));
}
 
Example #26
Source File: FunctionTest.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void testInvokeNoParams() throws Throwable {
    final FunCall fxn = UnsafeRuntimeAccess.createFunCall(TestUtils.getFoundation(), "NSFullUserName", PointerCoder.INST);

    fxn.init(nativeBuffer);
    fxn.invoke(nativeBuffer);

    final long ptr = PrimitivePointerCoder.INST.pop(nativeBuffer);
    System.out.println("0x" + Long.toHexString(ptr) + ": " + UnsafeRuntimeAccess.getDescriptionForPtr(ptr));
}
 
Example #27
Source File: FunctionTest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void testInvokeNoParams() throws Throwable {
    final FunCall fxn = UnsafeRuntimeAccess.createFunCall(TestUtils.getFoundation(), "NSFullUserName", PointerCoder.INST);

    fxn.init(nativeBuffer);
    fxn.invoke(nativeBuffer);

    final long ptr = PrimitivePointerCoder.INST.pop(nativeBuffer);
    System.out.println("0x" + Long.toHexString(ptr) + ": " + UnsafeRuntimeAccess.getDescriptionForPtr(ptr));
}
 
Example #28
Source File: FunctionTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void testInvokeNoParams() throws Throwable {
    final FunCall fxn = UnsafeRuntimeAccess.createFunCall(TestUtils.getFoundation(), "NSFullUserName", PointerCoder.INST);

    fxn.init(nativeBuffer);
    fxn.invoke(nativeBuffer);

    final long ptr = PrimitivePointerCoder.INST.pop(nativeBuffer);
    System.out.println("0x" + Long.toHexString(ptr) + ": " + UnsafeRuntimeAccess.getDescriptionForPtr(ptr));
}
 
Example #29
Source File: FunctionTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void testInvokeNoParams() throws Throwable {
    final FunCall fxn = UnsafeRuntimeAccess.createFunCall(TestUtils.getFoundation(), "NSFullUserName", PointerCoder.INST);

    fxn.init(nativeBuffer);
    fxn.invoke(nativeBuffer);

    final long ptr = PrimitivePointerCoder.INST.pop(nativeBuffer);
    System.out.println("0x" + Long.toHexString(ptr) + ": " + UnsafeRuntimeAccess.getDescriptionForPtr(ptr));
}
 
Example #30
Source File: FunctionTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void testInvokeNoParams() throws Throwable {
    final FunCall fxn = UnsafeRuntimeAccess.createFunCall(TestUtils.getFoundation(), "NSFullUserName", PointerCoder.INST);

    fxn.init(nativeBuffer);
    fxn.invoke(nativeBuffer);

    final long ptr = PrimitivePointerCoder.INST.pop(nativeBuffer);
    System.out.println("0x" + Long.toHexString(ptr) + ": " + UnsafeRuntimeAccess.getDescriptionForPtr(ptr));
}