             obj.set_field_from_offset rs, offset, new_obj
         o 'defineClass(Ljava/lang/String;[BIILjava/lang/ClassLoader;Ljava/security/ProtectionDomain;)Ljava/lang/Class;', (rs, _this, name, bytes, offset, len, loader, pd) ->
             native_define_class rs, name, bytes, offset, len, loader
+        o 'pageSize()I', (rs) ->
+            # Keep this in sync with sun/nio/ch/FileChannelImpl/initIDs for Mac
+            # JCL compatibility.
+            1024
       ]
     nio:
       ch:
         FileChannelImpl: [
           # this poorly-named method actually specifies the page size for mmap
+          # This is the Mac name for sun/misc/Unsafe::pageSize. Apparently they
+          # wanted to ensure page sizes can be > 2GB...
           o 'initIDs()J', (rs) -> gLong.fromNumber(1024)  # arbitrary
         ]
         FileDispatcher: [

    nio:
      Bits: [
        o 'byteOrder()L!/!/ByteOrder;', (rs) -> rs.static_get {class:'java/nio/ByteOrder',name:'LITTLE_ENDIAN'}
      ]
      charset:
        Charset$3: [

    j++
  # CoffeeScript, we are not returning an array.
  return

unsafe_memcpy = (rs, src_base, src_offset, dest_base, dest_offset, num_bytes) ->
  # XXX assumes base object is an array if non-null
  # TODO: optimize by copying chunks at a time
  num_bytes = num_bytes.toNumber()
  if src_base?
    src_offset = src_offset.toNumber()
    if dest_base?
      # both are java arrays
      arraycopy_no_check(src_base, src_offset, dest_base, dest_offset.toNumber(), num_bytes)
    else
      # src is an array, dest is a mem block
      dest_addr = rs.block_addr(dest_offset)
      if DataView?
        for i in [0...num_bytes] by 1
          rs.mem_blocks[dest_addr].setInt8(i, src_base.array[src_offset+i])
      else
        for i in [0...num_bytes] by 1
          rs.mem_blocks[dest_addr+i] = src_base.array[src_offset+i]
  else
    src_addr = rs.block_addr(src_offset)
    if dest_base?
      # src is a mem block, dest is an array
      dest_offset = dest_offset.toNumber()
      if DataView?
        for i in [0...num_bytes] by 1
          dest_base.array[dest_offset+i] = rs.mem_blocks[src_addr].getInt8(i)
      else
        for i in [0...num_bytes] by 1
          dest_base.array[dest_offset+i] = rs.mem_blocks[src_addr+i]
    else
      # both are mem blocks
      dest_addr = rs.block_addr(dest_offset)
      if DataView?
        for i in [0...num_bytes] by 1
          rs.mem_blocks[dest_addr].setInt8(i, rs.mem_blocks[src_addr].getInt8(i))
      else
        for i in [0...num_bytes] by 1
          rs.mem_blocks[dest_addr+i] = rs.mem_blocks[src_addr+i]

unsafe_compare_and_swap = (rs, _this, obj, offset, expected, x) ->
  actual = obj.get_field_from_offset rs, offset
