Ejemplo n.º 1
0
 public void GetStaticFieldID()
 {
     using (var System_class = new JniType("java/lang/System")) {
         var System_in = System_class.GetStaticField("in", "Ljava/io/InputStream;");
         Assert.IsNotNull(System_in);
     }
 }
Ejemplo n.º 2
0
        public unsafe void Dispose_Exceptions()
        {
            var t = new JniType("java/lang/Object");

            t.Dispose();
            Assert.Throws <ObjectDisposedException> (() => t.AllocObject());
            Assert.Throws <ObjectDisposedException> (() => t.NewObject(null, null));
            Assert.Throws <ObjectDisposedException> (() => t.GetConstructor(null));
            Assert.Throws <ObjectDisposedException> (() => t.GetInstanceField(null, null));
            Assert.Throws <ObjectDisposedException> (() => t.GetInstanceMethod(null, null));
            Assert.Throws <ObjectDisposedException> (() => t.GetStaticField(null, null));
            Assert.Throws <ObjectDisposedException> (() => t.GetStaticMethod(null, null));
            Assert.Throws <ObjectDisposedException> (() => t.GetSuperclass());
            Assert.Throws <ObjectDisposedException> (() => t.IsAssignableFrom(null));
            Assert.Throws <ObjectDisposedException> (() => t.IsInstanceOfType(new JniObjectReference()));
            Assert.Throws <ObjectDisposedException> (() => t.RegisterWithRuntime());
            Assert.Throws <ObjectDisposedException> (() => t.RegisterNativeMethods(null));
            Assert.Throws <ObjectDisposedException> (() => t.UnregisterNativeMethods());

            JniFieldInfo jif = null;

            Assert.Throws <ObjectDisposedException> (() => t.GetCachedInstanceField(ref jif, null, null));
            JniMethodInfo jim = null;

            Assert.Throws <ObjectDisposedException> (() => t.GetCachedConstructor(ref jim, null));
            Assert.Throws <ObjectDisposedException> (() => t.GetCachedInstanceMethod(ref jim, null, null));
            JniFieldInfo jsf = null;

            Assert.Throws <ObjectDisposedException> (() => t.GetCachedStaticField(ref jsf, null, null));
            JniMethodInfo jsm = null;

            Assert.Throws <ObjectDisposedException> (() => t.GetCachedStaticMethod(ref jsm, null, null));
        }
Ejemplo n.º 3
0
 static JavaModifiers()
 {
     using (var t = new JniType("java/lang/reflect/Modifier")) {
         var s = t.GetStaticField("STATIC", "I");
         Static = JniEnvironment.StaticFields.GetStaticIntField(t.PeerReference, s);
     }
 }