예제 #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() + "]");
     }
 }
예제 #2
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);
            }
        }