From: Eliot M. <mo...@cs...> - 2009-05-20 10:45:36
|
Da Feng wrote: > Does magic treat these setInt, setLong, setByte differently? > long bits = Magic.getLongAtOffset(obj, offset); > > then > Magic.setLongAtOffset(newObj, offset, bits); Differently from what? They are for fetching and setting ranges of bytes at specified offsets, and can be used to index into any kind of object at positive or negative offsets. If the offset is a constant, and corresponds to the position of a declared field, then they will act like a field access (though possibly without any associated barrier (non-pointer fields do not usually have a barrier, however)). But you can use these to access into any structure, and could even read or update a byte in the middle of a pointer or something, that is, they are not type safe and therefore need to be used with care. The offset also need not be a constant, but can be calculated. Typically these are appropriate for internal system components, such as garbage collectors. Best wishes -- Eliot Moss |