--- old/src/java.desktop/windows/native/libawt/windows/awt_Win32GraphicsDevice.cpp 2017-10-18 22:13:15.279976899 +0530 +++ new/src/java.desktop/windows/native/libawt/windows/awt_Win32GraphicsDevice.cpp 2017-10-18 22:13:15.044094890 +0530 @@ -632,22 +632,37 @@ int AwtWin32GraphicsDevice::ScaleUpX(int x) { - return (int)ceil(x * scaleX); + return CheckIntLimits(x * scaleX); } int AwtWin32GraphicsDevice::ScaleUpY(int y) { - return (int)ceil(y * scaleY); + return CheckIntLimits(y * scaleY); } int AwtWin32GraphicsDevice::ScaleDownX(int x) { - return (int)ceil(x / scaleX); + return CheckIntLimits(x / scaleX); } int AwtWin32GraphicsDevice::ScaleDownY(int y) { - return (int)ceil(y / scaleY); + return CheckIntLimits(y / scaleY); +} + +int AwtWin32GraphicsDevice::CheckIntLimits(double value) +{ + if (value < INT_MIN) + { + return INT_MIN; + } + + if (value > INT_MAX) + { + return INT_MAX; + } + + return (int)ceil(value); } void AwtWin32GraphicsDevice::InitDesktopScales()