-
Notifications
You must be signed in to change notification settings - Fork 5.8k
8318707: Remove the Java Management Extension (JMX) Management Applet (m-let) feature #16363
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
Conversation
👋 Welcome back kevinw! A progress list of the required criteria for merging this PR into |
@kevinjwalls The following labels will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command. |
@kevinjwalls This pull request has been inactive for more than 8 weeks and will be automatically closed if another 8 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
Additional test updates, a few more to come... |
Webrevs
|
test/jdk/javax/management/remote/mandatory/connection/IdleTimeoutTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kevin, thank you for the answers! Looks okay to me.
@kevinjwalls 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:
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 167 new commits pushed to the
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 |
testLoader = null; | ||
ObjectName testName = new ObjectName("x:name=Test"); | ||
Test mbean = new Test(); | ||
mbs.registerMBean(mbean, testName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect this test should first register an MBean which is a ClassLoader implementing PrivateClassLoader, through which the TestMBean would be loaded in order to preserve the semantics of the test.
In other words, replace the MLet with a regular MBean that extends URLClassLoader and implements PrivateClassLoader and do the same thing than the original test was doing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't see great value in it, as we no longer provide an MBean which is a ClassLoader.
Having a test MBean that extends URLClassLoader, and calling its loadClass()... is basically testing URLClassLoader? 8-)
Implementing PrivateClassLoader affects ClassLoaderRepository behaviour, but that's not tested here.
If you think this has value, we can do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My thinking is that this tests for a leak when an MBean is created using a ClassLoader which is also an MBean. MLet was such a ready-to-use ClassLoader. We no longer have MLets, but it's still possible to register an MBean that is a class loader and use that to create another MBean whose concrete class gets loaded by that ClassLoader MBean. We're testing that the Introspector doesn't create a leak in this case. And I believe the fact that the ClassLoader MBean is a PrivateClassLoader may also be of importance in the tested scenario (maybe).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checking on the original problem noted in the test, looks like it wasn't really about ClassLoaders and MLets:
JDK-4909536: Standard MBean introspector keeps reference to last class introspected
This is what the test still tests.
Do we see value in having the MBean be a ClassLoader and checking if such MBeans are held on to...? 8-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's the whole point of the test. Without using an MBean which is a ClassLoader the fix cannot be tested.
- you need to create an MBean which is an URLClassLoader, and it needs to be a PrivateClassLoader so that it's not added to the ClassLoaderRepository - let's call it LoaderMBean.
- you need to use that LoaderMBean to load another MBean - let's call it TestMBean. The concrete class of TestMBean needs to be loaded by the LoaderMBean - that is - LoaderMBean needs to be the defining ClassLoader for that class (the TestMBean class must not be loaded by the System/Application ClassLoader).
- In the MBeanServer you then end up with two MBeans, one is the LoaderMBean, the other is the TestMBean whose class has been loaded by the LoaderMBean.
- you then keep a weak reference on the LoaderMBean, and unregister both MBeans.
- at that point - if the Introspector still has a strong reference to the class of the TestMBean, then the LoaderMBean WeakReference will never be enqueued, because the class of the TestMBean will have a strong reference to its ClassLoader, which is LoaderMBean.
So you can only test that if you have an MBean which is loaded by a custom ClassLoader, because you want to verify that the Introspector doesn't hold on that ClassLoader (through the TestMBean class).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Daniel -
I am missing see how being a ClassLoader relates to the leak where the Introspector holds on to a reference to the most recent MBean. I didn't locate the jdk5 change, I only read a short synopsis.
I can make this test create an MBean which is a ClassLoader, and the test can do its check that having the loader MBean load a class, creates a distinct class. I can add that update here. But it looks like an MLet test which leaked into the Introspector test. 8-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Kevin,
To verify whether the Introspector holds a reference to a Class Object you need that class to be loaded by a custom class loader, and verify that the custom class loader that loaded that class can be garbage collected.
If the class loader that loaded that class has not been garbage collected after you released all references to it, then it's because the class it loaded is still referenced somewhere.
The logic of the test is as follows:
You create an MBean L which is a class loader and able to load class C. L must be the defining class loader for C.
You register L in the MBeanServer.
You ask the MBeanServer to create an MBean of class C through L (this is why you must use the variant of createMBean that takes a loader name).
You keep a weak ref to L
You unregister L and the MBean of class C from the MBeanServer and make sure the test doesn't have any strong reference to them (or to class C).
Then you start GC and wait until the weak ref to L is enqueued. If that doesn't happen, it's because the Introspector still hold a reference to class C.
You cannot test that if C has been loaded by the system class loader.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am updating those two tests.
I read the test as checking that an Object instance is collected, rather than Class Object, so was favouring making it simpler.
But we can use an MBean which is a URLClassLoader, and things will be more similar to the originals.
Some of MXBeanLoadingTest1 is duplicating some of ClassLeakTest, so something for future auditing perhaps...
} | ||
testLoader = null; | ||
|
||
ObjectInstance mb = mbs.createMBean(Test.class.getName(), testName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same remark here - I think we need to first register an MBean which is a ClassLoader and implements PrivateClassLoader to replace the MLet in this test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks better. I would have kept the LoaderMBean and the TestMBean separate - as using the same class for both makes the test harder to understand (it's not obvious that there are two separate copies of the TestMBean class, one loaded by the System ClassLoader, one loaded by the TestMBean itself when acting as a loader), but otherwise looks good.
Thanks Daniel and Serguei for reviewing! |
/integrate |
Going to push as commit 8c238ed.
Your commit was automatically rebased without conflicts. |
@kevinjwalls Pushed as commit 8c238ed. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Remove the MLet feature and its tests.
Some tests use MLet classes but are not testing MLets. These are updated, to use another test MBean or an MBean which is a URLClassLoader, e.g.
test/jdk/javax/management/MBeanServer/PostExceptionTest.java
test/jdk/javax/management/remote/mandatory/loading/TargetMBeanTest.java
Progress
Issues
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/16363/head:pull/16363
$ git checkout pull/16363
Update a local copy of the PR:
$ git checkout pull/16363
$ git pull https://git.openjdk.org/jdk.git pull/16363/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 16363
View PR using the GUI difftool:
$ git pr show -t 16363
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/16363.diff
Webrev
Link to Webrev Comment