diff --git a/src/share/classes/sun/font/FileFontStrike.java b/src/share/classes/sun/font/FileFontStrike.java index 67622411b1908d317893af2e7a5d5736963304f7..2a8cde547a4813eac7f149997fe08c4a92b7352b 100644 --- a/src/share/classes/sun/font/FileFontStrike.java +++ b/src/share/classes/sun/font/FileFontStrike.java @@ -747,14 +747,9 @@ public class FileFontStrike extends PhysicalStrike { return origMinX; } - long pixelData; - if (StrikeCache.nativeAddressSize == 4) { - pixelData = 0xffffffff & - StrikeCache.unsafe.getInt(ptr + StrikeCache.pixelDataOffset); - } else { - pixelData = - StrikeCache.unsafe.getLong(ptr + StrikeCache.pixelDataOffset); - } + long pixelData = + StrikeCache.unsafe.getAddress(ptr + StrikeCache.pixelDataOffset); + if (pixelData == 0L) { return origMinX; } diff --git a/src/share/classes/sun/font/GlyphList.java b/src/share/classes/sun/font/GlyphList.java index c02c7c47efd0e1a06137eac53a0b596412b0d4c2..50446044405aa91ef0409385d2c98ae4df72e760 100644 --- a/src/share/classes/sun/font/GlyphList.java +++ b/src/share/classes/sun/font/GlyphList.java @@ -361,16 +361,10 @@ public final class GlyphList { graybits = new byte[len]; } } - long pixelDataAddress; - if (StrikeCache.nativeAddressSize == 4) { - pixelDataAddress = 0xffffffff & - StrikeCache.unsafe.getInt(images[glyphindex] + + long pixelDataAddress = + StrikeCache.unsafe.getAddress(images[glyphindex] + StrikeCache.pixelDataOffset); - } else { - pixelDataAddress = - StrikeCache.unsafe.getLong(images[glyphindex] + - StrikeCache.pixelDataOffset); - } + if (pixelDataAddress == 0L) { return graybits; } diff --git a/src/solaris/classes/sun/font/XRGlyphCacheEntry.java b/src/solaris/classes/sun/font/XRGlyphCacheEntry.java index 3ed04017b1b9b63c91558a9dfc596f85f833eb13..18ece2b813b9eb00dc34a147030e33c45f00b63a 100644 --- a/src/solaris/classes/sun/font/XRGlyphCacheEntry.java +++ b/src/solaris/classes/sun/font/XRGlyphCacheEntry.java @@ -69,11 +69,28 @@ public class XRGlyphCacheEntry { } public static int getGlyphID(long glyphInfoPtr) { - return (int) StrikeCache.unsafe.getInt(glyphInfoPtr + StrikeCache.cacheCellOffset); + // We need to access the GlyphID with Unsafe.getAddress() because the + // corresponding field in the underlying C data-structure is of type + // 'void*' (see field 'cellInfo' of struct 'GlyphInfo' + // in src/share/native/sun/font/fontscalerdefs.h). + // On 64-bit Big-endian architectures it would be wrong to access this + // field with Unsafe.getInt(). + return (int) StrikeCache.unsafe.getAddress(glyphInfoPtr + + StrikeCache.cacheCellOffset); } public static void setGlyphID(long glyphInfoPtr, int id) { - StrikeCache.unsafe.putInt(glyphInfoPtr + StrikeCache.cacheCellOffset, id); + // We need to access the GlyphID with Unsafe.putAddress() because the + // corresponding field in the underlying C data-structure is of type + // 'void*' (see field 'cellInfo' of struct 'GlyphInfo' in + // src/share/native/sun/font/fontscalerdefs.h). + // On 64-bit Big-endian architectures it would be wrong to write this + // field with Unsafe.putInt() because it is also accessed from native + // code as a 'long'. + // See Java_sun_java2d_xr_XRBackendNative_XRAddGlyphsNative() + // in src/solaris/native/sun/java2d/x11/XRBackendNative.c + StrikeCache.unsafe.putAddress(glyphInfoPtr + + StrikeCache.cacheCellOffset, (long)id); } public int getGlyphID() { @@ -105,12 +122,9 @@ public class XRGlyphCacheEntry { } public void writePixelData(ByteArrayOutputStream os, boolean uploadAsLCD) { - long pixelDataAddress; - if (StrikeCache.nativeAddressSize == 4) { - pixelDataAddress = 0xffffffff & StrikeCache.unsafe.getInt(glyphInfoPtr + StrikeCache.pixelDataOffset); - } else { - pixelDataAddress = StrikeCache.unsafe.getLong(glyphInfoPtr + StrikeCache.pixelDataOffset); - } + long pixelDataAddress = + StrikeCache.unsafe.getAddress(glyphInfoPtr + + StrikeCache.pixelDataOffset); if (pixelDataAddress == 0L) { return; } diff --git a/src/solaris/native/sun/java2d/x11/XRBackendNative.c b/src/solaris/native/sun/java2d/x11/XRBackendNative.c index 0f8d0a8338256f39e23b78af4143bf027ca4280d..3b38bba94bf7573d1dd335393663b464d2bb1bc4 100644 --- a/src/solaris/native/sun/java2d/x11/XRBackendNative.c +++ b/src/solaris/native/sun/java2d/x11/XRBackendNative.c @@ -742,7 +742,12 @@ Java_sun_java2d_xr_XRBackendNative_XRAddGlyphsNative for (i=0; i < glyphCnt; i++) { GlyphInfo *jginfo = (GlyphInfo *) jlong_to_ptr(glyphInfoPtrs[i]); - gid[i] = (Glyph) (0x0ffffffffL & ((unsigned long)(jginfo->cellInfo))); + // 'jginfo->cellInfo' is of type 'void*' + // (see definition of 'GlyphInfo' in fontscalerdefs.h) + // 'Glyph' is typedefed to 'unsigned long' + // (see http://www.x.org/releases/X11R7.7/doc/libXrender/libXrender.txt) + // Maybe we should assert that (sizeof(void*) == sizeof(Glyph)) ? + gid[i] = (Glyph) (jginfo->cellInfo); xginfo[i].x = (-jginfo->topLeftX); xginfo[i].y = (-jginfo->topLeftY); xginfo[i].width = jginfo->width;