-
Bug
-
Resolution: Fixed
-
P4
-
23, 24
-
b21
In the JDK mainline, sun/font/HBShaper uses foreign functions feature of the Java language to invoke native functions.
One such function is a upcall which gets invoked from the native function into the Java code. That upcall is constructed as follows https://github.com/openjdk/jdk/blob/master/src/java.desktop/share/classes/sun/font/HBShaper.java#L281-L296
FunctionDescriptor store_layout_fd =
FunctionDescriptor.ofVoid(
...);
MethodHandle store_layout_mh =
getMethodHandle("store_layout_results", store_layout_fd);
MemorySegment tmp10 = LINKER.upcallStub(store_layout_mh, store_layout_fd, garena);
store_layout_results_stub = tmp10;
So the upcall is declared to return a void type. The corresponding java method (correctly) is defined to return void too https://github.com/openjdk/jdk/blob/master/src/java.desktop/share/classes/sun/font/HBShaper.java#L590
/* Upcall to receive results of layout */
private static void store_layout_results(
...
However, the native code for this corresponding function is declared to return int type and infact the upcall invocation from within the native code even expects and assigns an int return value from that invocation:
https://github.com/openjdk/jdk/blob/master/src/java.desktop/share/native/libfontmanager/hb-jdk-p.h#L59
typedef int (*store_layoutdata_func_t)
(int slot, int baseIndex, int offset,
float startX, float startY, float devScale,
int charCount, int glyphCount,
hb_glyph_info_t *glyphInfo, hb_glyph_position_t *glyphPos);
https://github.com/openjdk/jdk/blob/master/src/java.desktop/share/native/libfontmanager/HBShaper_Panama.c#L135
ret = (*store_layout_results_fn)
(slot, baseIndex, offset, startX, startY, devScale,
charCount, glyphCount, glyphInfo, glyphPos);
One such function is a upcall which gets invoked from the native function into the Java code. That upcall is constructed as follows https://github.com/openjdk/jdk/blob/master/src/java.desktop/share/classes/sun/font/HBShaper.java#L281-L296
FunctionDescriptor store_layout_fd =
FunctionDescriptor.ofVoid(
...);
MethodHandle store_layout_mh =
getMethodHandle("store_layout_results", store_layout_fd);
MemorySegment tmp10 = LINKER.upcallStub(store_layout_mh, store_layout_fd, garena);
store_layout_results_stub = tmp10;
So the upcall is declared to return a void type. The corresponding java method (correctly) is defined to return void too https://github.com/openjdk/jdk/blob/master/src/java.desktop/share/classes/sun/font/HBShaper.java#L590
/* Upcall to receive results of layout */
private static void store_layout_results(
...
However, the native code for this corresponding function is declared to return int type and infact the upcall invocation from within the native code even expects and assigns an int return value from that invocation:
https://github.com/openjdk/jdk/blob/master/src/java.desktop/share/native/libfontmanager/hb-jdk-p.h#L59
typedef int (*store_layoutdata_func_t)
(int slot, int baseIndex, int offset,
float startX, float startY, float devScale,
int charCount, int glyphCount,
hb_glyph_info_t *glyphInfo, hb_glyph_position_t *glyphPos);
https://github.com/openjdk/jdk/blob/master/src/java.desktop/share/native/libfontmanager/HBShaper_Panama.c#L135
ret = (*store_layout_results_fn)
(slot, baseIndex, offset, startX, startY, devScale,
charCount, glyphCount, glyphInfo, glyphPos);
- links to
-
Commit(master) openjdk/jdk/e0c6480c
-
Review(master) openjdk/jdk/21588