Re: How to invoke assignment operator in a native method?
- From: Chris Smith <cdsmith@xxxxxxx>
- Date: Wed, 30 Aug 2006 22:10:35 -0600
HappyHippy <karenman@xxxxxxx> wrote:
I want to achieve the effect of the following assignment (which can be
done in Java)
SomeNumber = 5;
where SomeNumber is of type java.lang.Integer
But in a native method I do not have an Integer object, I have jobject
instead.
In addition to Gordon and Oliver's replies, let me be explicit about
something. When you write:
SomeNumber = 5;
which is equivalent to:
SomeNumber = Integer.valueOf(5);
you are not doing *anything* the object that SomeNumber currently points
to. You are reassigning SomeNumber to point to a completely new object.
You say you've got a jobject, but you don't say which one it is. The
jobject that SomeNumber points *to* doesn't help you at all.
Presumably, SomeNumber is a field (you can't access local variables of
Java methods from JNI at all), and you need the jobject that *contains*
the SomeNumber field. Once you've got that, then you can call
SetObjectField as Gordon described.
Incidentally, naming conventions are there for a reason, and are
absolutely universal among professional Java programmers. Call the
field someNumber, not SomeNumber.
--
Chris Smith
.
- References:
- How to invoke assignment operator in a native method?
- From: HappyHippy
- Re: How to invoke assignment operator in a native method?
- From: HappyHippy
- How to invoke assignment operator in a native method?
- Prev by Date: Re: Configuration params for a webapp - best practice?
- Next by Date: Re: Where can I find SNTP server in Java?
- Previous by thread: Re: How to invoke assignment operator in a native method?
- Next by thread: Windows XP with no JVM?
- Index(es):