0

I want to set a field. However, the non SDK interfaces which have been restricted under Android Q has an interface I am using i.e. Ljava/lang/Integer;->value:I The suggested way by Google is to use public API instead. i.e. java.lang.Integer.intValue()

However, I need to do the following:

c = env->FindClass("java/lang/Integer");
id = env->GetFieldID(c, "value", "I");
env->SetIntField(a, id, b);

Even if I use java.lang.Integer.intValue(), I'll only get the value and not the reference. How can I set the field then?

codeignitor
  • 51
  • 1
  • 3
  • What are the `a` and `b`? Anyway, I don't really think you may get a reference on JNI value. – Tomáš Zato Aug 22 '19 at 11:51
  • Can you be more concrete? Especially the API you are trying to use. – Botje Aug 22 '19 at 12:21
  • `a` is a `jobject` and `b` is a count. I want to set the int field which can be done by the above code. However, Google has restricted the non SDK interface `Ljava/lang/Integer;->value:I` in [link](https://developer.android.com/preview/non-sdk-q#greylist-now-restricted) and I need to use intValue() in the Integer class. The Integer class doesn't have a setter so it isn't possible for me to set the value. – codeignitor Aug 23 '19 at 05:53
  • 1
    Modifying a non mutable class is not a good idea. You should create a new integer object assigning the new value. – greywolf82 Aug 23 '19 at 07:41
  • Actually, my app crashes because of the restriction for non SDK interface, because it does not find the field "I". My question is how can I reproduce the above code in an alternate way. Google suggests to use the public API but I'm not able to figure out how to. – codeignitor Aug 23 '19 at 07:57

0 Answers0