On Sun, 17 Oct 2021 00:09:12 GMT, Sergey Bylokhov <[email protected]> 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@17-internal/Native > Method) > at > sun.java2d.cmm.lcms.LCMSProfile.setTag(java.desktop@17-internal/LCMSProfile.java:82) > at sun.java2d.cmm.lcms.LCMS.setTagData(java.desktop@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 prr (Reviewer). "Note that it is also possible to just clear an occurred exception before the creation of the IllegalArgumentException. Any thoughts about it?" I think wrapping it as you do is fine. ------------- PR: https://git.openjdk.java.net/jdk/pull/5975
