RFR: 8275344: -Xcheck:jni produces some warnings in the LCMS.c

Alexander Zuev kizune at openjdk.java.net
Tue Oct 19 21:32:08 UTC 2021


On Sun, 17 Oct 2021 00:09:12 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:

> The newly added test MTTransformReplacedProfile(yeah that test again) produce some warning if check:jni is enabled:
> 
> WARNING in native method: JNI call made with exception pending
> at sun.java2d.cmm.lcms.LCMS.setTagDataNative(java.desktop at 17-internal/Native Method)
> at sun.java2d.cmm.lcms.LCMSProfile.setTag(java.desktop at 17-internal/LCMSProfile.java:82)
> at sun.java2d.cmm.lcms.LCMS.setTagData(java.desktop at 17-internal/LCMS.java:84) 
> 
> 
> The root cause is in the "errorHandler", which is called by the lcms library and where we throw a CMSException. So when we get an error code from some lcms API and try to throw the CMSException it is might be already thrown in the "errorHandler".
> 
> The fix contains two parts:
>  * If an exception already occurred we skip the creation of the CMSException. So the first error will be reported to the user.
>  * If an exception already occurred we DO NOT skip the creation of the IllegalArgumentException, because it is required by the specification to be thrown. But we use the initial exception as a "cause" for the new IllegalArgumentException. Note that it is also possible to just clear an occurred exception before the creation of the IllegalArgumentException. Any thoughts about it?
> 
> The second part changed the stack trace which will get the user, an example:
> 
> old:
> 
> java.lang.IllegalArgumentException: Can not write tag data.
> 	at java.desktop/sun.java2d.cmm.lcms.LCMS.setTagDataNative(Native Method)
> 	at java.desktop/sun.java2d.cmm.lcms.LCMSProfile.setTag(LCMSProfile.java:82)
> 	at java.desktop/sun.java2d.cmm.lcms.LCMS.setTagData(LCMS.java:84)
> 	at java.desktop/java.awt.color.ICC_Profile.setData(ICC_Profile.java:1132)
> 	at SetDataTest$TestCase.doTest(SetDataTest.java:77)
> 	at SetDataTest.main(SetDataTest.java:140)
> 
> new:
> 
> java.lang.IllegalArgumentException: Can not write tag data.
> 	at java.desktop/sun.java2d.cmm.lcms.LCMS.setTagDataNative(Native Method)
> 	at java.desktop/sun.java2d.cmm.lcms.LCMSProfile.setTag(LCMSProfile.java:82)
> 	at java.desktop/sun.java2d.cmm.lcms.LCMS.setTagData(LCMS.java:92)
> 	at java.desktop/java.awt.color.ICC_Profile.setData(ICC_Profile.java:1114)
> 	at SetDataTest$TestCase.doTest(SetDataTest.java:77)
> 	at SetDataTest.main(SetDataTest.java:140)
> Caused by: java.awt.color.CMMException: LCMS error 8: Unknown tag type 'AAAA' found.
> 	... 6 more

Marked as reviewed by kizune (Reviewer).

-------------

PR: https://git.openjdk.java.net/jdk/pull/5975



More information about the client-libs-dev mailing list