JDK-8163408 : Fix wrong prototype of getNativeScaleFactor() in systemScale.h
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 9
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2016-08-08
  • Updated: 2016-08-18
  • Resolved: 2016-08-10
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9 b132Fixed
Related Reports
Relates :  
Description
The fix for "8149115: [hidpi] Linux: display-wise scaling factor should probably be taken into account" changed the prototype for getNativeScaleFactor() in systemScale.h from:

int getNativeScaleFactor();

to

double getNativeScaleFactor();

But forgot to add the "char*" parameter to the signature which is required by the implementation in systemScale.c (and the various call sites):

double getNativeScaleFactor(char *output_name) {

This leads to the following waring/error:

/OpenJDK/jdk9-hs-comp-s390x/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c: In function ���Ja
va_sun_awt_X11GraphicsDevice_getNativeScaleFactor���:
/OpenJDK/jdk9-hs-comp-s390x/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c:2185:5: error: c
all to function ���getNativeScaleFactor��� without a real prototype [-Werror=unprototyped-calls]
     double scale = getNativeScaleFactor(name);
     ^
In file included from /OpenJDK/jdk9-hs-comp-s390x/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_Graphics
Env.c:46:0:
/OpenJDK/jdk9-hs-comp-s390x/jdk/src/java.desktop/unix/native/common/awt/systemscale/systemScale.h:29:8: note: ���
getNativeScaleFactor��� was declared here
 double getNativeScaleFactor();
        ^
cc1: all warnings being treated as errors

If we fix that we will get:

/usr/work/d046063/OpenJDK/jdk9-hs-comp-s390x/jdk/src/java.desktop/unix/native/libsplashscreen/splashscreen_sys.c: In function ���S
plashGetScaledImageName���:
/usr/work/d046063/OpenJDK/jdk9-hs-comp-s390x/jdk/src/java.desktop/unix/native/libsplashscreen/splashscreen_sys.c:809:5: error: t
oo few arguments to function ���getNativeScaleFactor���
     *scaleFactor = getNativeScaleFactor();
     ^

I observed these warnings/errors with 4.8.5 and it is a miracle for me why newer versions of GCC (apparently 4.9.2 which seems to be Oracles officially supported compiler according to  https://wiki.openjdk.java.net/display/Build/Supported+Build+Platforms) or gcc 5.4.0 whiohc I've tried on Ubuntu 16.04 don't detect this problem?


Comments
At least I could find out why I couldn't see this problem with other compilers. -Wunprototyped-calls seems to be an undocumented Suse extension which is only available on SLES/OpenSuse GCC builds. Somehow it never made its way into upstream GCC. The only reference I could find is the following mail thread on the GCC mailing list: https://gcc.gnu.org/ml/gcc-patches/2013-04/threads.html#00363
10-08-2016