JDK-6655515 : MBeans tab: operation return values of type Component displayed as String
  • Type: Bug
  • Component: tools
  • Sub-Component: jconsole
  • Affected Version: 7
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2008-01-25
  • Updated: 2011-03-08
  • Resolved: 2011-03-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7
6u10Fixed 7 b25Fixed
Description
Operation return values of type java.awt.Component are displayed as java.lan.String
instead of being displayed as AWT/Swing components in a container.

This is a regression introduced in JConsole 6/7.

Comments
EVALUATION I was able to build JConsole using the instructions at <http://nb-openjdk.netbeans.org/get-and-build-jconsole.html> and apply the following fix: diff -r 93cc3fad6803 src/share/classes/sun/tools/jconsole/inspector/XDataViewer.java --- a/src/share/classes/sun/tools/jconsole/inspector/XDataViewer.java Tue Jan 15 13:35:38 2008 +0100 +++ b/src/share/classes/sun/tools/jconsole/inspector/XDataViewer.java Tue Feb 05 18:17:00 2008 +0100 @@ -108,6 +108,7 @@ public class XDataViewer { public Component createOperationViewer(Object value, XMBean mbean) { if(value instanceof Number) return null; + if(value instanceof Component) return (Component) value; return createAttributeViewer(value, mbean, null, null); } So people for whom this is a blocking problem can always install a custom JConsole with this fix. Having said that, it's not clear that it's a good idea for MBean operations to return Swing components. Swing serialization is explicitly stated not to be compatible across releases, so this will only work if your JConsole is running on the same JDK as your application. Furthermore you have to be extremely careful that your component does not reference any application-specific classes. For example, tables created in the usual way are editable, and if you want to make one non-editable then the usual way to do that is to create a subclass of DefaultTableModel that overrides isCellEditable. But if you do that then JConsole won't know your subclass and will fail mysteriously when it tries to read the result of your operation. But it is true that this is a convenient if dangerous way to provide formatted data to human users, and it is very simple to modify JConsole to support it. Given that the JDK 5.0 version did support it we should update JDK 6 to support it too.
05-02-2008

EVALUATION Do not convert Components to Strings.
25-01-2008