Example #1
0
 public JavaObject(JavaENV _env, JavaClass _cls, JavaConstructor _constructor, object[] _args)
 {
     env   = _env;
     klass = _cls;
     id    = env.NewObject(klass.GetID(), _constructor.GetID(), ToJNIObjects(_args));
     if (id <= 0)
     {
         throw new Exception("fail to new a object[" + klass.GetClassFullName() + "]");
     }
 }
Example #2
0
 public JavaArray(JavaClass _cls, JavaConstructor _constructor, JavaObject[] _arr)
     : base(Java.GetEnvironment(), _cls, 0)
 {
     id = env.NewObjectArray(_arr.Length, _cls.GetID(), _constructor.GetID());
     if (id <= 0)
     {
         throw new Exception("fail to create an array of object[" + klass.GetClassFullName() + "]");
     }
     for (int i = 0; i < _arr.Length; i++)
     {
         env.SetObjectArrayElement(id, i, _arr[i].GetID());
     }
 }
Example #3
0
        public JavaArray(string[] _arr)
            : base(Java.GetEnvironment(), null, 0)
        {
            klass = new JavaClass(env, "java.lang.String");
            JavaConstructor constructor = klass.GetConstructor();

            id = env.NewObjectArray(_arr.Length, klass.GetID(), constructor.GetID());
            if (id <= 0)
            {
                throw new Exception("fail to create an array of object[" + klass.GetClassFullName() + "]");
            }
            for (int i = 0; i < _arr.Length; i++)
            {
                int strtmpid = env.NewStringUTF(_arr[i]);
                env.SetObjectArrayElement(id, i, strtmpid);
                env.DeleteLocalRef(strtmpid);
            }
        }