RFR: 8275344: -Xcheck:jni produces some warnings in the LCMS.c
Sergey Bylokhov
serb at openjdk.java.net
Sun Oct 17 00:36:00 UTC 2021
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
-------------
Commit messages:
- Update LCMS.c
- Update LCMS.c
- Init the cause of the IllegalArgumentException
- 8275344: -Xcheck:jni produces some warnings in the LCMS.c
Changes: https://git.openjdk.java.net/jdk/pull/5975/files
Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=5975&range=00
Issue: https://bugs.openjdk.java.net/browse/JDK-8275344
Stats: 67 lines in 2 files changed: 47 ins; 1 del; 19 mod
Patch: https://git.openjdk.java.net/jdk/pull/5975.diff
Fetch: git fetch https://git.openjdk.java.net/jdk pull/5975/head:pull/5975
PR: https://git.openjdk.java.net/jdk/pull/5975
More information about the client-libs-dev
mailing list