Java 8 introduces a behavior change for the visibility requirements for interfaces that are used to create MBeans or MXBeans. All MBean and MXBean interfaces must be public. Prior to Java 8, non-public interfaces were allowed, although the specification defined that they should be public.
Setting the jdk.jmx.mbeans.allowNonPublic system property reverts the management subsystem
to use the old behavior, allowing non-public management interfaces.
This property is considered to be transitional and might be removed in subsequent releases.
To detect non-public MBean and MXBean interfaces, the following situations are flagged in Java code:
@MXBean@MXBean(true)MXBeanMBeanThe following examples show non-public interfaces that are flagged by this rule.
interface Example1MBean {}
interface Example2MXBean {}
@MXBean
interface Example3Interface {}
@MXBean(true)
interface Example4Interface {}
The following examples show interfaces that are not flagged by this rule because they are already public or they are annotated as not an MXBean.
public interface Example5MBean{}
public interface Example6MXBean{}
@MXBean(false)
interface Example7MXBean {}
This rule has an automated fix that sets the interface visibility to public. Copy the
custom configuration to your application build
file to enable the fix automation.
For additional information, see Package javax.management Java documentation.