Java源码示例:com.apple.jobjc.PrimitiveCoder.DoubleCoder

示例1
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);
}
 
示例2
public void testDoubleIntLongMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    final int arg1 = 3;
    final long arg2 = 4;
    final float arg3 = 5.5F;
    final double expected = 12.5D;

    final MsgSend sel = new MsgSend(runtime, "add:and:and:", DoubleCoder.INST,
            SIntCoder.INST, SLongLongCoder.INST, FloatCoder.INST);
    sel.init(ctx, instObj);
    SIntCoder.INST.push(ctx, arg1);
    SLongLongCoder.INST.push(ctx, arg2);
    FloatCoder.INST.push(ctx, arg3);
    sel.invoke(ctx);
    final double ret = DoubleCoder.INST.pop(ctx);
    assertEquals(expected, ret);
}
 
示例3
static public Coder getCoderAtRuntimeForType(Class cls){
    if(runtimeCoders == null) runtimeCoders = new Coder[]{
        NSClassCoder.INST, IDCoder.INST, PointerCoder.INST,
        DoubleCoder.INST, FloatCoder.INST, SLongLongCoder.INST,
        SIntCoder.INST, SShortCoder.INST, SCharCoder.INST, BoolCoder.INST,
        VoidCoder.INST
    };

    for(Coder c : runtimeCoders)
        if((c.getJavaClass() != null && c.getJavaClass().isAssignableFrom(cls)) ||
                (c.getJavaPrimitive() != null && c.getJavaPrimitive().isAssignableFrom(cls)))
            return c;

    if(Struct.class.isAssignableFrom(cls)){
        try {
            Method m = cls.getDeclaredMethod("getStructCoder");
            m.setAccessible(true);
            return (Coder) m.invoke(null);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    throw new RuntimeException("Could not find suitable coder for " + cls);
}
 
示例4
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);
}
 
示例5
public void testDoubleIntLongMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    final int arg1 = 3;
    final long arg2 = 4;
    final float arg3 = 5.5F;
    final double expected = 12.5D;

    final MsgSend sel = new MsgSend(runtime, "add:and:and:", DoubleCoder.INST,
            SIntCoder.INST, SLongLongCoder.INST, FloatCoder.INST);
    sel.init(ctx, instObj);
    SIntCoder.INST.push(ctx, arg1);
    SLongLongCoder.INST.push(ctx, arg2);
    FloatCoder.INST.push(ctx, arg3);
    sel.invoke(ctx);
    final double ret = DoubleCoder.INST.pop(ctx);
    assertEquals(expected, ret);
}
 
示例6
static public Coder getCoderAtRuntimeForType(Class cls){
    if(runtimeCoders == null) runtimeCoders = new Coder[]{
        NSClassCoder.INST, IDCoder.INST, PointerCoder.INST,
        DoubleCoder.INST, FloatCoder.INST, SLongLongCoder.INST,
        SIntCoder.INST, SShortCoder.INST, SCharCoder.INST, BoolCoder.INST,
        VoidCoder.INST
    };

    for(Coder c : runtimeCoders)
        if((c.getJavaClass() != null && c.getJavaClass().isAssignableFrom(cls)) ||
                (c.getJavaPrimitive() != null && c.getJavaPrimitive().isAssignableFrom(cls)))
            return c;

    if(Struct.class.isAssignableFrom(cls)){
        try {
            Method m = cls.getDeclaredMethod("getStructCoder");
            m.setAccessible(true);
            return (Coder) m.invoke(null);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    throw new RuntimeException("Could not find suitable coder for " + cls);
}
 
示例7
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);
}
 
示例8
public void testDoubleIntLongMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    final int arg1 = 3;
    final long arg2 = 4;
    final float arg3 = 5.5F;
    final double expected = 12.5D;

    final MsgSend sel = new MsgSend(runtime, "add:and:and:", DoubleCoder.INST,
            SIntCoder.INST, SLongLongCoder.INST, FloatCoder.INST);
    sel.init(ctx, instObj);
    SIntCoder.INST.push(ctx, arg1);
    SLongLongCoder.INST.push(ctx, arg2);
    FloatCoder.INST.push(ctx, arg3);
    sel.invoke(ctx);
    final double ret = DoubleCoder.INST.pop(ctx);
    assertEquals(expected, ret);
}
 
示例9
static public Coder getCoderAtRuntimeForType(Class cls){
    if(runtimeCoders == null) runtimeCoders = new Coder[]{
        NSClassCoder.INST, IDCoder.INST, PointerCoder.INST,
        DoubleCoder.INST, FloatCoder.INST, SLongLongCoder.INST,
        SIntCoder.INST, SShortCoder.INST, SCharCoder.INST, BoolCoder.INST,
        VoidCoder.INST
    };

    for(Coder c : runtimeCoders)
        if((c.getJavaClass() != null && c.getJavaClass().isAssignableFrom(cls)) ||
                (c.getJavaPrimitive() != null && c.getJavaPrimitive().isAssignableFrom(cls)))
            return c;

    if(Struct.class.isAssignableFrom(cls)){
        try {
            Method m = cls.getDeclaredMethod("getStructCoder");
            m.setAccessible(true);
            return (Coder) m.invoke(null);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    throw new RuntimeException("Could not find suitable coder for " + cls);
}
 
示例10
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);
}
 
示例11
public void testDoubleIntLongMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    final int arg1 = 3;
    final long arg2 = 4;
    final float arg3 = 5.5F;
    final double expected = 12.5D;

    final MsgSend sel = new MsgSend(runtime, "add:and:and:", DoubleCoder.INST,
            SIntCoder.INST, SLongLongCoder.INST, FloatCoder.INST);
    sel.init(ctx, instObj);
    SIntCoder.INST.push(ctx, arg1);
    SLongLongCoder.INST.push(ctx, arg2);
    FloatCoder.INST.push(ctx, arg3);
    sel.invoke(ctx);
    final double ret = DoubleCoder.INST.pop(ctx);
    assertEquals(expected, ret);
}
 
示例12
static public Coder getCoderAtRuntimeForType(Class cls){
    if(runtimeCoders == null) runtimeCoders = new Coder[]{
        NSClassCoder.INST, IDCoder.INST, PointerCoder.INST,
        DoubleCoder.INST, FloatCoder.INST, SLongLongCoder.INST,
        SIntCoder.INST, SShortCoder.INST, SCharCoder.INST, BoolCoder.INST,
        VoidCoder.INST
    };

    for(Coder c : runtimeCoders)
        if((c.getJavaClass() != null && c.getJavaClass().isAssignableFrom(cls)) ||
                (c.getJavaPrimitive() != null && c.getJavaPrimitive().isAssignableFrom(cls)))
            return c;

    if(Struct.class.isAssignableFrom(cls)){
        try {
            Method m = cls.getDeclaredMethod("getStructCoder");
            m.setAccessible(true);
            return (Coder) m.invoke(null);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    throw new RuntimeException("Could not find suitable coder for " + cls);
}
 
示例13
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);
}
 
示例14
public void testDoubleIntLongMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    final int arg1 = 3;
    final long arg2 = 4;
    final float arg3 = 5.5F;
    final double expected = 12.5D;

    final MsgSend sel = new MsgSend(runtime, "add:and:and:", DoubleCoder.INST,
            SIntCoder.INST, SLongLongCoder.INST, FloatCoder.INST);
    sel.init(ctx, instObj);
    SIntCoder.INST.push(ctx, arg1);
    SLongLongCoder.INST.push(ctx, arg2);
    FloatCoder.INST.push(ctx, arg3);
    sel.invoke(ctx);
    final double ret = DoubleCoder.INST.pop(ctx);
    assertEquals(expected, ret);
}
 
示例15
static public Coder getCoderAtRuntimeForType(Class cls){
    if(runtimeCoders == null) runtimeCoders = new Coder[]{
        NSClassCoder.INST, IDCoder.INST, PointerCoder.INST,
        DoubleCoder.INST, FloatCoder.INST, SLongLongCoder.INST,
        SIntCoder.INST, SShortCoder.INST, SCharCoder.INST, BoolCoder.INST,
        VoidCoder.INST
    };

    for(Coder c : runtimeCoders)
        if((c.getJavaClass() != null && c.getJavaClass().isAssignableFrom(cls)) ||
                (c.getJavaPrimitive() != null && c.getJavaPrimitive().isAssignableFrom(cls)))
            return c;

    if(Struct.class.isAssignableFrom(cls)){
        try {
            Method m = cls.getDeclaredMethod("getStructCoder");
            m.setAccessible(true);
            return (Coder) m.invoke(null);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    throw new RuntimeException("Could not find suitable coder for " + cls);
}
 
示例16
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);
}
 
示例17
public void testDoubleIntLongMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    final int arg1 = 3;
    final long arg2 = 4;
    final float arg3 = 5.5F;
    final double expected = 12.5D;

    final MsgSend sel = new MsgSend(runtime, "add:and:and:", DoubleCoder.INST,
            SIntCoder.INST, SLongLongCoder.INST, FloatCoder.INST);
    sel.init(ctx, instObj);
    SIntCoder.INST.push(ctx, arg1);
    SLongLongCoder.INST.push(ctx, arg2);
    FloatCoder.INST.push(ctx, arg3);
    sel.invoke(ctx);
    final double ret = DoubleCoder.INST.pop(ctx);
    assertEquals(expected, ret);
}
 
示例18
static public Coder getCoderAtRuntimeForType(Class cls){
    if(runtimeCoders == null) runtimeCoders = new Coder[]{
        NSClassCoder.INST, IDCoder.INST, PointerCoder.INST,
        DoubleCoder.INST, FloatCoder.INST, SLongLongCoder.INST,
        SIntCoder.INST, SShortCoder.INST, SCharCoder.INST, BoolCoder.INST,
        VoidCoder.INST
    };

    for(Coder c : runtimeCoders)
        if((c.getJavaClass() != null && c.getJavaClass().isAssignableFrom(cls)) ||
                (c.getJavaPrimitive() != null && c.getJavaPrimitive().isAssignableFrom(cls)))
            return c;

    if(Struct.class.isAssignableFrom(cls)){
        try {
            Method m = cls.getDeclaredMethod("getStructCoder");
            m.setAccessible(true);
            return (Coder) m.invoke(null);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    throw new RuntimeException("Could not find suitable coder for " + cls);
}
 
示例19
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);
}
 
示例20
public void testDoubleIntLongMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    final int arg1 = 3;
    final long arg2 = 4;
    final float arg3 = 5.5F;
    final double expected = 12.5D;

    final MsgSend sel = new MsgSend(runtime, "add:and:and:", DoubleCoder.INST,
            SIntCoder.INST, SLongLongCoder.INST, FloatCoder.INST);
    sel.init(ctx, instObj);
    SIntCoder.INST.push(ctx, arg1);
    SLongLongCoder.INST.push(ctx, arg2);
    FloatCoder.INST.push(ctx, arg3);
    sel.invoke(ctx);
    final double ret = DoubleCoder.INST.pop(ctx);
    assertEquals(expected, ret);
}
 
示例21
static public Coder getCoderAtRuntimeForType(Class cls){
    if(runtimeCoders == null) runtimeCoders = new Coder[]{
        NSClassCoder.INST, IDCoder.INST, PointerCoder.INST,
        DoubleCoder.INST, FloatCoder.INST, SLongLongCoder.INST,
        SIntCoder.INST, SShortCoder.INST, SCharCoder.INST, BoolCoder.INST,
        VoidCoder.INST
    };

    for(Coder c : runtimeCoders)
        if((c.getJavaClass() != null && c.getJavaClass().isAssignableFrom(cls)) ||
                (c.getJavaPrimitive() != null && c.getJavaPrimitive().isAssignableFrom(cls)))
            return c;

    if(Struct.class.isAssignableFrom(cls)){
        try {
            Method m = cls.getDeclaredMethod("getStructCoder");
            m.setAccessible(true);
            return (Coder) m.invoke(null);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    throw new RuntimeException("Could not find suitable coder for " + cls);
}
 
示例22
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);
}
 
示例23
public void testDoubleIntLongMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    final int arg1 = 3;
    final long arg2 = 4;
    final float arg3 = 5.5F;
    final double expected = 12.5D;

    final MsgSend sel = new MsgSend(runtime, "add:and:and:", DoubleCoder.INST,
            SIntCoder.INST, SLongLongCoder.INST, FloatCoder.INST);
    sel.init(ctx, instObj);
    SIntCoder.INST.push(ctx, arg1);
    SLongLongCoder.INST.push(ctx, arg2);
    FloatCoder.INST.push(ctx, arg3);
    sel.invoke(ctx);
    final double ret = DoubleCoder.INST.pop(ctx);
    assertEquals(expected, ret);
}
 
示例24
static public Coder getCoderAtRuntimeForType(Class cls){
    if(runtimeCoders == null) runtimeCoders = new Coder[]{
        NSClassCoder.INST, IDCoder.INST, PointerCoder.INST,
        DoubleCoder.INST, FloatCoder.INST, SLongLongCoder.INST,
        SIntCoder.INST, SShortCoder.INST, SCharCoder.INST, BoolCoder.INST,
        VoidCoder.INST
    };

    for(Coder c : runtimeCoders)
        if((c.getJavaClass() != null && c.getJavaClass().isAssignableFrom(cls)) ||
                (c.getJavaPrimitive() != null && c.getJavaPrimitive().isAssignableFrom(cls)))
            return c;

    if(Struct.class.isAssignableFrom(cls)){
        try {
            Method m = cls.getDeclaredMethod("getStructCoder");
            m.setAccessible(true);
            return (Coder) m.invoke(null);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    throw new RuntimeException("Could not find suitable coder for " + cls);
}
 
示例25
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);
}
 
示例26
public void testDoubleIntLongMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    final int arg1 = 3;
    final long arg2 = 4;
    final float arg3 = 5.5F;
    final double expected = 12.5D;

    final MsgSend sel = new MsgSend(runtime, "add:and:and:", DoubleCoder.INST,
            SIntCoder.INST, SLongLongCoder.INST, FloatCoder.INST);
    sel.init(ctx, instObj);
    SIntCoder.INST.push(ctx, arg1);
    SLongLongCoder.INST.push(ctx, arg2);
    FloatCoder.INST.push(ctx, arg3);
    sel.invoke(ctx);
    final double ret = DoubleCoder.INST.pop(ctx);
    assertEquals(expected, ret);
}
 
示例27
static public Coder getCoderAtRuntimeForType(Class cls){
    if(runtimeCoders == null) runtimeCoders = new Coder[]{
        NSClassCoder.INST, IDCoder.INST, PointerCoder.INST,
        DoubleCoder.INST, FloatCoder.INST, SLongLongCoder.INST,
        SIntCoder.INST, SShortCoder.INST, SCharCoder.INST, BoolCoder.INST,
        VoidCoder.INST
    };

    for(Coder c : runtimeCoders)
        if((c.getJavaClass() != null && c.getJavaClass().isAssignableFrom(cls)) ||
                (c.getJavaPrimitive() != null && c.getJavaPrimitive().isAssignableFrom(cls)))
            return c;

    if(Struct.class.isAssignableFrom(cls)){
        try {
            Method m = cls.getDeclaredMethod("getStructCoder");
            m.setAccessible(true);
            return (Coder) m.invoke(null);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    throw new RuntimeException("Could not find suitable coder for " + cls);
}
 
示例28
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);
}
 
示例29
public void testDoubleIntLongMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    final int arg1 = 3;
    final long arg2 = 4;
    final float arg3 = 5.5F;
    final double expected = 12.5D;

    final MsgSend sel = new MsgSend(runtime, "add:and:and:", DoubleCoder.INST,
            SIntCoder.INST, SLongLongCoder.INST, FloatCoder.INST);
    sel.init(ctx, instObj);
    SIntCoder.INST.push(ctx, arg1);
    SLongLongCoder.INST.push(ctx, arg2);
    FloatCoder.INST.push(ctx, arg3);
    sel.invoke(ctx);
    final double ret = DoubleCoder.INST.pop(ctx);
    assertEquals(expected, ret);
}
 
示例30
static public Coder getCoderAtRuntimeForType(Class cls){
    if(runtimeCoders == null) runtimeCoders = new Coder[]{
        NSClassCoder.INST, IDCoder.INST, PointerCoder.INST,
        DoubleCoder.INST, FloatCoder.INST, SLongLongCoder.INST,
        SIntCoder.INST, SShortCoder.INST, SCharCoder.INST, BoolCoder.INST,
        VoidCoder.INST
    };

    for(Coder c : runtimeCoders)
        if((c.getJavaClass() != null && c.getJavaClass().isAssignableFrom(cls)) ||
                (c.getJavaPrimitive() != null && c.getJavaPrimitive().isAssignableFrom(cls)))
            return c;

    if(Struct.class.isAssignableFrom(cls)){
        try {
            Method m = cls.getDeclaredMethod("getStructCoder");
            m.setAccessible(true);
            return (Coder) m.invoke(null);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    throw new RuntimeException("Could not find suitable coder for " + cls);
}