690 private static final int MAX_FRAMES = 8; |
665 private static final int MAX_FRAMES = 8; |
691 |
666 |
692 /** |
667 /** |
693 * Returns a {@code ThreadInfo} object represented by the |
668 * Returns a {@code ThreadInfo} object represented by the |
694 * given {@code CompositeData}. |
669 * given {@code CompositeData}. |
695 * The given {@code CompositeData} must contain the following attributes |
670 * |
696 * unless otherwise specified below: |
671 * <a id="attributes"></a> |
|
672 * A {@code CompositeData} representing a {@code ThreadInfo} of |
|
673 * version <em>N</em> must contain all of the attributes defined |
|
674 * in version ≤ <em>N</em> unless specified otherwise. |
|
675 * The same rule applies the composite type of the given |
|
676 * {@code CompositeData} and transitively to attributes whose |
|
677 * {@linkplain CompositeData#getCompositeType() type} or |
|
678 * {@linkplain ArrayType#getElementOpenType() component type} is |
|
679 * {@code CompositeType}. |
|
680 * <p> |
|
681 * A {@code CompositeData} representing {@code ThreadInfo} of |
|
682 * version <em>N</em> contains {@code "stackTrace"} attribute and |
|
683 * {@code "lockedMonitors"} attribute representing |
|
684 * an array of {@code StackTraceElement} and |
|
685 * an array of {@link MonitorInfo} respectively |
|
686 * and their types are of version <em>N</em>. |
|
687 * The {@code "lockedStackFrame"} attribute in |
|
688 * {@link MonitorInfo#from(CompositeData) MonitorInfo}'s composite type |
|
689 * must represent {@code StackTraceElement} of the same version <em>N</em>. |
|
690 * Otherwise, this method will throw {@code IllegalArgumentException}. |
|
691 * |
697 * <table class="striped" style="margin-left:2em"> |
692 * <table class="striped" style="margin-left:2em"> |
698 * <caption style="display:none">The attributes and their types the given CompositeData contains</caption> |
693 * <caption style="display:none">The attributes and their types for ThreadInfo's composite data</caption> |
699 * <thead> |
694 * <thead> |
700 * <tr> |
695 * <tr> |
701 * <th scope="col">Attribute Name</th> |
696 * <th scope="col">Attribute Name</th> |
702 * <th scope="col">Type</th> |
697 * <th scope="col">Type</th> |
|
698 * <th scope="col">Since</th> |
703 * </tr> |
699 * </tr> |
704 * </thead> |
700 * </thead> |
705 * <tbody style="text-align:left"> |
701 * <tbody style="text-align:left"> |
706 * <tr> |
702 * <tr> |
707 * <th scope="row">threadId</th> |
703 * <th scope="row">threadId</th> |
708 * <td>{@code java.lang.Long}</td> |
704 * <td>{@code java.lang.Long}</td> |
|
705 * <td>5</td> |
709 * </tr> |
706 * </tr> |
710 * <tr> |
707 * <tr> |
711 * <th scope="row">threadName</th> |
708 * <th scope="row">threadName</th> |
712 * <td>{@code java.lang.String}</td> |
709 * <td>{@code java.lang.String}</td> |
|
710 * <td>5</td> |
713 * </tr> |
711 * </tr> |
714 * <tr> |
712 * <tr> |
715 * <th scope="row">threadState</th> |
713 * <th scope="row">threadState</th> |
716 * <td>{@code java.lang.String}</td> |
714 * <td>{@code java.lang.String}</td> |
|
715 * <td>5</td> |
717 * </tr> |
716 * </tr> |
718 * <tr> |
717 * <tr> |
719 * <th scope="row">suspended</th> |
718 * <th scope="row">suspended</th> |
720 * <td>{@code java.lang.Boolean}</td> |
719 * <td>{@code java.lang.Boolean}</td> |
|
720 * <td>5</td> |
721 * </tr> |
721 * </tr> |
722 * <tr> |
722 * <tr> |
723 * <th scope="row">inNative</th> |
723 * <th scope="row">inNative</th> |
724 * <td>{@code java.lang.Boolean}</td> |
724 * <td>{@code java.lang.Boolean}</td> |
|
725 * <td>5</td> |
725 * </tr> |
726 * </tr> |
726 * <tr> |
727 * <tr> |
727 * <th scope="row">blockedCount</th> |
728 * <th scope="row">blockedCount</th> |
728 * <td>{@code java.lang.Long}</td> |
729 * <td>{@code java.lang.Long}</td> |
|
730 * <td>5</td> |
729 * </tr> |
731 * </tr> |
730 * <tr> |
732 * <tr> |
731 * <th scope="row">blockedTime</th> |
733 * <th scope="row">blockedTime</th> |
732 * <td>{@code java.lang.Long}</td> |
734 * <td>{@code java.lang.Long}</td> |
|
735 * <td>5</td> |
733 * </tr> |
736 * </tr> |
734 * <tr> |
737 * <tr> |
735 * <th scope="row">waitedCount</th> |
738 * <th scope="row">waitedCount</th> |
736 * <td>{@code java.lang.Long}</td> |
739 * <td>{@code java.lang.Long}</td> |
|
740 * <td>5</td> |
737 * </tr> |
741 * </tr> |
738 * <tr> |
742 * <tr> |
739 * <th scope="row">waitedTime</th> |
743 * <th scope="row">waitedTime</th> |
740 * <td>{@code java.lang.Long}</td> |
744 * <td>{@code java.lang.Long}</td> |
|
745 * <td>5</td> |
|
746 * </tr> |
|
747 * <tr> |
|
748 * <th scope="row">lockName</th> |
|
749 * <td>{@code java.lang.String}</td> |
|
750 * <td>5</td> |
|
751 * </tr> |
|
752 * <tr> |
|
753 * <th scope="row">lockOwnerId</th> |
|
754 * <td>{@code java.lang.Long}</td> |
|
755 * <td>5</td> |
|
756 * </tr> |
|
757 * <tr> |
|
758 * <th scope="row">lockOwnerName</th> |
|
759 * <td>{@code java.lang.String}</td> |
|
760 * <td>5</td> |
|
761 * </tr> |
|
762 * <tr> |
|
763 * <th scope="row"><a id="StackTrace">stackTrace</a></th> |
|
764 * <td>{@code javax.management.openmbean.CompositeData[]}, each element |
|
765 * is a {@code CompositeData} representing {@code StackTraceElement} |
|
766 * as specified <a href="#stackTraceElement">below</a>. |
|
767 * </td> |
|
768 * <td>5</td> |
741 * </tr> |
769 * </tr> |
742 * <tr> |
770 * <tr> |
743 * <th scope="row">lockInfo</th> |
771 * <th scope="row">lockInfo</th> |
744 * <td>{@code javax.management.openmbean.CompositeData} |
772 * <td>{@code javax.management.openmbean.CompositeData} |
745 * - the mapped type for {@link LockInfo} as specified in the |
773 * - the mapped type for {@link LockInfo} as specified in the |
746 * {@link LockInfo#from} method. |
774 * {@link LockInfo#from} method. |
747 * <p> |
775 * <p> |
748 * If {@code cd} does not contain this attribute, |
776 * If the given {@code CompositeData} does not contain this attribute, |
749 * the {@code LockInfo} object will be constructed from |
777 * the {@code LockInfo} object will be constructed from |
750 * the value of the {@code lockName} attribute. </td> |
778 * the value of the {@code lockName} attribute.</td> |
751 * </tr> |
779 * <td>6</td> |
752 * <tr> |
|
753 * <th scope="row">lockName</th> |
|
754 * <td>{@code java.lang.String}</td> |
|
755 * </tr> |
|
756 * <tr> |
|
757 * <th scope="row">lockOwnerId</th> |
|
758 * <td>{@code java.lang.Long}</td> |
|
759 * </tr> |
|
760 * <tr> |
|
761 * <th scope="row">lockOwnerName</th> |
|
762 * <td>{@code java.lang.String}</td> |
|
763 * </tr> |
|
764 * <tr> |
|
765 * <th scope="row"><a id="StackTrace">stackTrace</a></th> |
|
766 * <td>{@code javax.management.openmbean.CompositeData[]} |
|
767 * <p> |
|
768 * Each element is a {@code CompositeData} representing |
|
769 * StackTraceElement containing the following attributes: |
|
770 * <table class="striped" style="margin-left:2em"> |
|
771 * <caption style="display:none">The attributes and their types the given CompositeData contains</caption> |
|
772 * <thead style="text-align:center"> |
|
773 * <tr> |
|
774 * <th scope="col">Attribute Name</th> |
|
775 * <th scope="col">Type</th> |
|
776 * </tr> |
|
777 * </thead> |
|
778 * <tbody style="text-align:left"> |
|
779 * <tr> |
|
780 * <th scope="row">moduleName</th> |
|
781 * <td>{@code java.lang.String}</td> |
|
782 * </tr> |
|
783 * <tr> |
|
784 * <th scope="row">moduleVersion</th> |
|
785 * <td>{@code java.lang.String}</td> |
|
786 * </tr> |
|
787 * <tr> |
|
788 * <th scope="row">className</th> |
|
789 * <td>{@code java.lang.String}</td> |
|
790 * </tr> |
|
791 * <tr> |
|
792 * <th scope="row">methodName</th> |
|
793 * <td>{@code java.lang.String}</td> |
|
794 * </tr> |
|
795 * <tr> |
|
796 * <th scope="row">fileName</th> |
|
797 * <td>{@code java.lang.String}</td> |
|
798 * </tr> |
|
799 * <tr> |
|
800 * <th scope="row">lineNumber</th> |
|
801 * <td>{@code java.lang.Integer}</td> |
|
802 * </tr> |
|
803 * <tr> |
|
804 * <th scope="row">nativeMethod</th> |
|
805 * <td>{@code java.lang.Boolean}</td> |
|
806 * </tr> |
|
807 * </tbody> |
|
808 * </table> |
|
809 * </td> |
|
810 * </tr> |
780 * </tr> |
811 * <tr> |
781 * <tr> |
812 * <th scope="row">lockedMonitors</th> |
782 * <th scope="row">lockedMonitors</th> |
813 * <td>{@code javax.management.openmbean.CompositeData[]} |
783 * <td>{@code javax.management.openmbean.CompositeData[]} |
814 * whose element type is the mapped type for |
784 * whose element type is the mapped type for |
815 * {@link MonitorInfo} as specified in the |
785 * {@link MonitorInfo} as specified in the |
816 * {@link MonitorInfo#from Monitor.from} method. |
786 * {@link MonitorInfo#from MonitorInfo.from} method. |
817 * <p> |
787 * <p> |
818 * If {@code cd} does not contain this attribute, |
788 * If the given {@code CompositeData} does not contain this attribute, |
819 * this attribute will be set to an empty array. </td> |
789 * this attribute will be set to an empty array.</td> |
|
790 * <td>6</td> |
820 * </tr> |
791 * </tr> |
821 * <tr> |
792 * <tr> |
822 * <th scope="row">lockedSynchronizers</th> |
793 * <th scope="row">lockedSynchronizers</th> |
823 * <td>{@code javax.management.openmbean.CompositeData[]} |
794 * <td>{@code javax.management.openmbean.CompositeData[]} |
824 * whose element type is the mapped type for |
795 * whose element type is the mapped type for |
825 * {@link LockInfo} as specified in the {@link LockInfo#from} method. |
796 * {@link LockInfo} as specified in the {@link LockInfo#from} method. |
826 * <p> |
797 * <p> |
827 * If {@code cd} does not contain this attribute, |
798 * If the given {@code CompositeData} does not contain this attribute, |
828 * this attribute will be set to an empty array. </td> |
799 * this attribute will be set to an empty array.</td> |
|
800 * <td>6</td> |
829 * </tr> |
801 * </tr> |
830 * <tr> |
802 * <tr> |
831 * <th scope="row">daemon</th> |
803 * <th scope="row">daemon</th> |
832 * <td>{@code java.lang.Boolean}</td> |
804 * <td>{@code java.lang.Boolean} |
|
805 * <p> |
|
806 * If the given {@code CompositeData} does not contain this attribute, |
|
807 * this attribute will be set to {@code false}.</td> |
|
808 * <td>9</td> |
833 * </tr> |
809 * </tr> |
834 * <tr> |
810 * <tr> |
835 * <th scope="row">priority</th> |
811 * <th scope="row">priority</th> |
836 * <td>{@code java.lang.Integer}</td> |
812 * <td>{@code java.lang.Integer} |
|
813 * <p> |
|
814 * If the given {@code CompositeData} does not contain this attribute, |
|
815 * This attribute will be set to {@link Thread#NORM_PRIORITY}.</td> |
|
816 * <td>9</td> |
837 * </tr> |
817 * </tr> |
838 * </tbody> |
818 * </tbody> |
839 * </table> |
819 * </table> |
840 * |
820 * |
|
821 * <a id="stackTraceElement">A {@code CompositeData} representing |
|
822 * {@code StackTraceElement}</a> of version <em>N</em> must contain |
|
823 * all of the attributes defined in version ≤ <em>N</em> |
|
824 * unless specified otherwise. |
|
825 * |
|
826 * <table class="striped" style="margin-left:2em"> |
|
827 * <caption style="display:none">The attributes and their types for StackTraceElement's composite data</caption> |
|
828 * <thead style="text-align:center"> |
|
829 * <tr> |
|
830 * <th scope="col">Attribute Name</th> |
|
831 * <th scope="col">Type</th> |
|
832 * <th scope="col">Since</th> |
|
833 * </tr> |
|
834 * </thead> |
|
835 * <tbody style="text-align:left"> |
|
836 * <tr> |
|
837 * <th scope="row">classLoaderName</th> |
|
838 * <td>{@code java.lang.String}</td> |
|
839 * <td>9</td> |
|
840 * </tr> |
|
841 * <tr> |
|
842 * <th scope="row">moduleName</th> |
|
843 * <td>{@code java.lang.String}</td> |
|
844 * <td>9</td> |
|
845 * </tr> |
|
846 * <tr> |
|
847 * <th scope="row">moduleVersion</th> |
|
848 * <td>{@code java.lang.String}</td> |
|
849 * <td>9</td> |
|
850 * </tr> |
|
851 * <tr> |
|
852 * <th scope="row">className</th> |
|
853 * <td>{@code java.lang.String}</td> |
|
854 * <td>5</td> |
|
855 * </tr> |
|
856 * <tr> |
|
857 * <th scope="row">methodName</th> |
|
858 * <td>{@code java.lang.String}</td> |
|
859 * <td>5</td> |
|
860 * </tr> |
|
861 * <tr> |
|
862 * <th scope="row">fileName</th> |
|
863 * <td>{@code java.lang.String}</td> |
|
864 * <td>5</td> |
|
865 * </tr> |
|
866 * <tr> |
|
867 * <th scope="row">lineNumber</th> |
|
868 * <td>{@code java.lang.Integer}</td> |
|
869 * <td>5</td> |
|
870 * </tr> |
|
871 * <tr> |
|
872 * <th scope="row">nativeMethod</th> |
|
873 * <td>{@code java.lang.Boolean}</td> |
|
874 * <td>5</td> |
|
875 * </tr> |
|
876 * </tbody> |
|
877 * </table> |
|
878 * |
841 * @param cd {@code CompositeData} representing a {@code ThreadInfo} |
879 * @param cd {@code CompositeData} representing a {@code ThreadInfo} |
842 * |
880 * |
843 * @throws IllegalArgumentException if {@code cd} does not |
881 * @throws IllegalArgumentException if the given {@code cd} and |
844 * represent a {@code ThreadInfo} with the attributes described |
882 * its composite type does not contain all of |
845 * above. |
883 * <a href="#attributes">the attributes</a> defined for a |
|
884 * {@code ThreadInfo} of a specific runtime version. |
846 * |
885 * |
847 * @return a {@code ThreadInfo} object represented |
886 * @return a {@code ThreadInfo} object represented |
848 * by {@code cd} if {@code cd} is not {@code null}; |
887 * by {@code cd} if {@code cd} is not {@code null}; |
849 * {@code null} otherwise. |
888 * {@code null} otherwise. |
850 * |
889 * |