8020190: Fatal: Bug in native code: jfieldID must match object
Reviewed-by: jgodinez, vadim
--- a/jdk/src/share/classes/sun/font/FreetypeFontScaler.java Fri Sep 27 13:04:54 2013 -0700
+++ b/jdk/src/share/classes/sun/font/FreetypeFontScaler.java Fri Sep 27 13:06:47 2013 -0700
@@ -169,7 +169,7 @@
public synchronized void dispose() {
if (nativeScaler != 0L) {
- disposeNativeScaler(nativeScaler);
+ disposeNativeScaler(font.get(), nativeScaler);
nativeScaler = 0L;
}
}
@@ -190,7 +190,7 @@
synchronized int getGlyphCode(char charCode) throws FontScalerException {
if (nativeScaler != 0L) {
- return getGlyphCodeNative(nativeScaler, charCode);
+ return getGlyphCodeNative(font.get(), nativeScaler, charCode);
}
return FontScaler.getNullScaler().getGlyphCode(charCode);
}
@@ -245,9 +245,9 @@
private native long getLayoutTableCacheNative(long pScaler);
- private native void disposeNativeScaler(long pScaler);
+ private native void disposeNativeScaler(Font2D font2D, long pScaler);
- private native int getGlyphCodeNative(long pScaler, char charCode);
+ private native int getGlyphCodeNative(Font2D font, long pScaler, char charCode);
private native int getNumGlyphsNative(long pScaler);
private native int getMissingGlyphCodeNative(long pScaler);
--- a/jdk/src/share/native/sun/font/freetypeScaler.c Fri Sep 27 13:04:54 2013 -0700
+++ b/jdk/src/share/native/sun/font/freetypeScaler.c Fri Sep 27 13:06:47 2013 -0700
@@ -902,13 +902,13 @@
*/
JNIEXPORT void JNICALL
Java_sun_font_FreetypeFontScaler_disposeNativeScaler(
- JNIEnv *env, jobject scaler, jlong pScaler) {
+ JNIEnv *env, jobject scaler, jobject font2D, jlong pScaler) {
FTScalerInfo* scalerInfo = (FTScalerInfo *) jlong_to_ptr(pScaler);
/* Freetype functions *may* cause callback to java
that can use cached values. Make sure our cache is up to date.
NB: scaler context is not important at this point, can use NULL. */
- int errCode = setupFTContext(env, scaler, scalerInfo, NULL);
+ int errCode = setupFTContext(env, font2D, scalerInfo, NULL);
if (errCode) {
return;
}
@@ -957,7 +957,8 @@
*/
JNIEXPORT jint JNICALL
Java_sun_font_FreetypeFontScaler_getGlyphCodeNative(
- JNIEnv *env, jobject scaler, jlong pScaler, jchar charCode) {
+ JNIEnv *env, jobject scaler,
+ jobject font2D, jlong pScaler, jchar charCode) {
FTScalerInfo* scalerInfo = (FTScalerInfo *) jlong_to_ptr(pScaler);
int errCode;
@@ -970,7 +971,7 @@
/* Freetype functions *may* cause callback to java
that can use cached values. Make sure our cache is up to date.
Scaler context is not important here, can use NULL. */
- errCode = setupFTContext(env, scaler, scalerInfo, NULL);
+ errCode = setupFTContext(env, font2D, scalerInfo, NULL);
if (errCode) {
return 0;
}