Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

How to use “unsafe” in JNI?  RSS feed

Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let's say I have a value pointed to by a (base,offset) tuple.


(runnable version: )

I now want to execute

in `C`.

Why? Because a different process may move the data and change``base`` and ``off`` to point to the new location. I want to make use of intel RTM to make sure moving the data does not interfere with regular accesses to the field.

So let's create a new class

and replace

we run this through javah to get the header, copy the method signatures to an ``RTM_transct.cpp`` and get something like

The "heart" of the transaction are these three lines that (are supposed to)
correspond to what Accessor used to do:


Ideally, of course, I'd like to do something akin to ``base[offset] = value``, but I very much doubt that would work.

What do I put here for unsafe.setInt?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!