Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 4 commits into from

Conversation

mrserb
Copy link
Member

@mrserb mrserb commented Oct 17, 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@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

Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

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

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/5975/head:pull/5975
$ git checkout pull/5975

Update a local copy of the PR:
$ git checkout pull/5975
$ git pull https://git.openjdk.java.net/jdk pull/5975/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 5975

View PR using the GUI difftool:
$ git pr show -t 5975

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/5975.diff

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Oct 17, 2021

👋 Welcome back serb! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

@openjdk openjdk bot commented Oct 17, 2021

@mrserb The following label will be automatically applied to this pull request:

  • client

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the client label Oct 17, 2021
@mrserb mrserb marked this pull request as ready for review Oct 17, 2021
@openjdk openjdk bot added the rfr label Oct 17, 2021
@mlbridge
Copy link

@mlbridge mlbridge bot commented Oct 17, 2021

Webrevs

@openjdk
Copy link

@openjdk openjdk bot commented Oct 19, 2021

@mrserb This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

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

Reviewed-by: azvegint, prr, kizune

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 62 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready label Oct 19, 2021
@prrace
Copy link
Contributor

@prrace prrace commented Oct 19, 2021

"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.

prrace
prrace approved these changes Oct 19, 2021
@mrserb
Copy link
Member Author

@mrserb mrserb commented Oct 22, 2021

/integrate

@openjdk
Copy link

@openjdk openjdk bot commented Oct 22, 2021

Going to push as commit c978ca8.
Since your change was applied there have been 100 commits pushed to the master branch:

  • 6a466fe: 8202056: Expand serial warning to check for bad overloads of serial-related methods and ineffectual fields
  • 4e9dd4b: 8275384: Change nested classes in jdk.jconsole to static nested classes
  • 0961de4: 8275347: ciReplay: staticfield lines not properly terminated
  • 7dd8237: 8275084: CDS warning when building with LOG=debug
  • 49f9d80: 8243585: AlgorithmChecker::check throws confusing exception when it rejects the signer key
  • bef8cf1: 8275714: G1: remove unused variable in G1Policy::transfer_survivors_to_cset
  • af14650: 8275569: Add linux-aarch64 to test-make profiles
  • 0761a4b: 8275688: Suppress warnings on non-serializable non-transient instance fields in DualPivotQuicksort
  • 3cb241a: 8275686: Suppress warnings on non-serializable non-transient instance fields in java.rmi
  • 3b0ce23: 8274888: Dump "-DReproduce=true" to the test VM command line output
  • ... and 90 more: https://git.openjdk.java.net/jdk/compare/831802ddb103f8f9747a9fb139af8365924da801...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot closed this Oct 22, 2021
@openjdk openjdk bot added integrated and removed ready rfr labels Oct 22, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Oct 22, 2021

@mrserb Pushed as commit c978ca8.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@mrserb mrserb deleted the JDK-8275344 branch Oct 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client integrated
4 participants