├── .gitignore ├── .idea ├── .gitignore ├── ant.xml ├── artifacts │ ├── _JDKThreadCPU_jar.xml │ ├── visualgc_idea_jar.xml │ └── visualgc_java8_jar.xml ├── codeStyles │ ├── Project.xml │ └── codeStyleConfig.xml ├── compiler.xml ├── description.html ├── encodings.xml ├── hotswap_agent.xml ├── inspectionProfiles │ └── Project_Default.xml ├── libraries │ ├── junit.xml │ └── tools.xml ├── misc.xml ├── modules.xml ├── project-template.xml ├── runConfigurations │ └── vgc_idea.xml ├── uiDesigner.xml └── vcs.xml ├── LICENSE ├── README.md ├── _JDKThreadCPU ├── README.md ├── _JDKThreadCPU.iml ├── _JDKThreadCPU.ipr ├── _JDKThreadCPU.iws ├── bean_topthreads.iml ├── bean_topthreads.jar ├── jconsole.jar ├── jconsoleTopThread.cmd ├── jconsoleTopThread.sh ├── libs │ ├── jansi-1.12.jar │ └── junit.jar ├── src │ ├── META-INF │ │ ├── MANIFEST.MF │ │ └── services │ │ │ └── com.sun.tools.jconsole.JConsolePlugin │ ├── ThreadInfosPureJava.java │ ├── ThreadStatsTest.java │ ├── beansoft │ │ └── profiler │ │ │ └── global │ │ │ ├── Bundle.properties │ │ │ └── CommonConstants.java │ ├── biz │ │ └── beansoft │ │ │ └── jmx │ │ │ └── topthreads │ │ │ ├── JTopPlugin.java │ │ │ ├── Main.java │ │ │ ├── PluginAdapter.java │ │ │ ├── ThreadInfoStats.java │ │ │ └── TopThreadsPanel.java │ ├── net │ │ └── luminis │ │ │ └── jmx │ │ │ ├── sun │ │ │ └── LocalConnectorImpl.java │ │ │ └── topthreads │ │ │ ├── AbstractInfoStats.java │ │ │ ├── ColoredHistoryRenderer.java │ │ │ ├── ColoredIntegerCellRenderer.java │ │ │ ├── ConfigurationException.java │ │ │ ├── CustomClassloader.java │ │ │ ├── CustomTableCellRendererBase.java │ │ │ ├── Data.java │ │ │ ├── DiffStackTraces.java │ │ │ ├── InfoStats.java │ │ │ ├── LocalConnector.java │ │ │ ├── PluginAdapter.java │ │ │ ├── PreferencesPanel.java │ │ │ ├── ProcessInfoStats.java │ │ │ ├── SwingUI.java │ │ │ ├── TextUI.java │ │ │ ├── ThreadDataCollector.java │ │ │ ├── ThreadInfoStats.java │ │ │ ├── TopThreads.java │ │ │ └── TopThreadsPanel.java │ └── org │ │ └── jdesktop │ │ └── swingworker │ │ ├── AccumulativeRunnable.java │ │ ├── SwingPropertyChangeSupport.java │ │ └── SwingWorker.java ├── sun.license ├── topthread_cn.png └── visualvmPlugin.cmd ├── devkit-helper ├── .idea │ ├── .gitignore │ ├── codeStyles │ │ ├── Project.xml │ │ └── codeStyleConfig.xml │ ├── inspectionProfiles │ │ └── Project_Default.xml │ ├── kotlinc.xml │ ├── libraries │ │ └── devkit.xml │ ├── misc.xml │ ├── modules.xml │ ├── uiDesigner.xml │ └── vcs.xml ├── api.json ├── devkit-helper.iml ├── lib │ └── devkit.jar ├── readme.md ├── resources │ ├── META-INF │ │ ├── plugin.xml │ │ ├── pluginIcon.svg │ │ └── pluginIcon_dark.svg │ ├── colorSchemes │ │ ├── JdcrLangDarcula.xml │ │ └── JdcrLangDefault.xml │ ├── icons │ │ └── gutter │ │ │ ├── descriptionFile.svg │ │ │ ├── descriptionFile_dark.svg │ │ │ ├── diff.svg │ │ │ ├── diff_dark.svg │ │ │ ├── plugin.svg │ │ │ ├── plugin_dark.svg │ │ │ ├── properties.svg │ │ │ └── properties_dark.svg │ └── messages │ │ ├── DevkitHelperBundle.properties │ │ ├── JavaDocBundle.properties │ │ └── JavaDocBundle_zh_CN.properties └── src │ ├── com │ └── github │ │ └── beansoft │ │ └── devkit │ │ ├── DevkitHelperBundle.java │ │ ├── helper │ │ ├── MyAction.java │ │ ├── PluginHtmlInjector.java │ │ └── QuickFixAction.kt │ │ ├── javadoc │ │ ├── JavaDocBundle.java │ │ ├── JdcrAnnotator.java │ │ ├── JdcrColorSettingsPage.java │ │ ├── JdcrFoldingBuilder.java │ │ └── utils │ │ │ ├── JdcrPsiTreeUtils.java │ │ │ ├── JdcrStringUtils.java │ │ │ └── Tag.java │ │ ├── navigation │ │ ├── DevkitRelatedClassLineMarkerProviderBase.java │ │ ├── ExtensionDeclarationRelatedItemLineMarkerProvider.java │ │ ├── ExtensionPointDeclarationRelatedItemLineMarkerProvider.java │ │ └── LineMarkerInfoHelper.java │ │ ├── provider │ │ ├── ByteCodeDocumentationProvider.java │ │ ├── PluginXmlLineMarkerProvider.java │ │ ├── PluginXmlRefLineMarkerProvider.java │ │ └── SimpleLineMarkerProvider.java │ │ └── util │ │ ├── ActionLocator.kt │ │ ├── ActionLocatorJava.java │ │ ├── ExtensionLocator.kt │ │ ├── JavaUtils.java │ │ ├── PairProcessor.java │ │ ├── PluginXmlUtil.java │ │ └── text │ │ ├── HtmlBuilder.java │ │ ├── HtmlChunk.java │ │ └── NlsSafe.java │ └── icons │ └── PluginIcons.java ├── visualgc.iml ├── visualgc_fix ├── .classpath ├── .gitignore ├── .project ├── README.md ├── src │ ├── beansoft │ │ └── jvm │ │ │ └── hotspot │ │ │ └── util │ │ │ ├── Exceptions.java │ │ │ └── GetProcessID.java │ ├── com │ │ └── sun │ │ │ └── jvmstat │ │ │ ├── graph │ │ │ ├── FIFOList.java │ │ │ ├── GridDrawer.java │ │ │ ├── Level.java │ │ │ └── Line.java │ │ │ ├── tools │ │ │ └── visualgc │ │ │ │ ├── Arguments.java │ │ │ │ ├── GCSample.java │ │ │ │ ├── GCSpacePanel.java │ │ │ │ ├── GraphGC.java │ │ │ │ ├── JpsHelper.java │ │ │ │ ├── Model.java │ │ │ │ ├── ModelFixer.java │ │ │ │ ├── MonitoredVmModel.java │ │ │ │ ├── VisualAgeHistogram.java │ │ │ │ ├── VisualGC.java │ │ │ │ └── VisualHeap.java │ │ │ └── util │ │ │ ├── Converter.java │ │ │ └── gc │ │ │ ├── GCCollector.java │ │ │ ├── GCGeneration.java │ │ │ ├── GCPolicy.java │ │ │ └── GCSpace.java │ └── version ├── test │ └── PID.java └── visualgc_fix.iml ├── visualgc_idea ├── .run │ ├── VisualGCPane.run.xml │ ├── plugin ZGC.run.xml │ ├── plugin jdk 17.run.xml │ └── plugin.run.xml ├── CompilerArgs.md ├── JDK 17 Guide.md ├── LICENSE ├── README.md ├── bugreport.txt ├── compiler_error.png ├── guide_cn.md ├── jdk 17 ZGC counters.txt ├── lib │ └── tools.jar ├── resources │ ├── META-INF │ │ ├── plugin.xml │ │ ├── pluginIcon.svg │ │ └── withJava.xml │ ├── closePanel.png │ ├── images │ │ ├── CustomGdbRunConfiguration.svg │ │ ├── MemoryView(RiderDark).svg │ │ ├── MemoryView(RiderLight).svg │ │ ├── debugWithVisualGC.svg │ │ ├── debugWithVisualGC_13.svg │ │ ├── debugWithVisualGC_13_dark.svg │ │ ├── debugWithVisualGC_dark.svg │ │ ├── donate.gif │ │ ├── donate.png │ │ ├── mug.png │ │ ├── mug@2x.png │ │ ├── runWithVisualGC.svg │ │ ├── runWithVisualGC_13.svg │ │ ├── runWithVisualGC_13_dark.svg │ │ ├── runWithVisualGC_dark.svg │ │ └── runnableMark.svg │ ├── visualgc.png │ ├── visualgc.properties │ ├── visualgc.svg │ ├── visualgc_dark.svg │ └── visualgc_zh_CN.properties ├── screenshot │ ├── vgc_idea.png │ ├── vgc_idea_cn.png │ ├── vgc_idea_cn_ps.png │ ├── vgc_idea_mac_en.png │ ├── visualgc_dark.png │ ├── visualgc_idea_spring_boot.png │ ├── visualgc_idea_tomcat_dark.png │ └── zgc_en.png ├── src │ ├── TextPaneTest.java │ ├── beansoft │ │ └── swing │ │ │ └── OptionPane.java │ ├── com │ │ ├── beansoft │ │ │ ├── NewWindowAction.java │ │ │ └── lic │ │ │ │ └── CheckLicense.java │ │ ├── github │ │ │ └── beansoft │ │ │ │ ├── idea │ │ │ │ ├── BaseTooltipAction.java │ │ │ │ └── EditCustomSettingsAction.kt │ │ │ │ ├── jvm │ │ │ │ ├── ApplicationSettingsService.java │ │ │ │ ├── Donate.java │ │ │ │ ├── Hacks.java │ │ │ │ ├── LogHelper.java │ │ │ │ ├── MyConfigurable.java │ │ │ │ ├── PluginSettings.java │ │ │ │ ├── SettingsDialog.form │ │ │ │ ├── SettingsDialog.java │ │ │ │ ├── action │ │ │ │ │ ├── SettingsAction.java │ │ │ │ │ └── StartVisualGCConsoleAction.java │ │ │ │ ├── executor │ │ │ │ │ ├── DebugVisualGCExecutor.java │ │ │ │ │ └── RunVisualGCExecutor.java │ │ │ │ ├── integration │ │ │ │ │ ├── VisualGCConsoleActionsPostProcessor.java │ │ │ │ │ ├── VisualGCContext.java │ │ │ │ │ ├── VisualGCHelper.java │ │ │ │ │ └── VisualGCJavaProgramPatcher.java │ │ │ │ ├── jprofiler │ │ │ │ │ ├── ProfilerRunner.java │ │ │ │ │ └── RunVisualGCAddTabsRunner.java │ │ │ │ └── runner │ │ │ │ │ ├── AdditionalTabBase.java │ │ │ │ │ ├── DebugVisualGCRunner.java │ │ │ │ │ ├── JProfilerTab.java │ │ │ │ │ ├── MyAdditionalTabComponentManager.java │ │ │ │ │ ├── RunVisualGCRunner.java │ │ │ │ │ └── RunnerUtil.java │ │ │ │ └── visualgc │ │ │ │ └── idea │ │ │ │ ├── MakeCoffeeAction.java │ │ │ │ ├── VisualGCAction.java │ │ │ │ ├── VisualGCPaneIdea.java │ │ │ │ └── VisualGCToolWindowFactory.java │ │ ├── sun │ │ │ └── jvmstat │ │ │ │ ├── graph │ │ │ │ ├── FIFOList.java │ │ │ │ ├── GridDrawer.java │ │ │ │ ├── Level.java │ │ │ │ └── Line.java │ │ │ │ ├── monitor │ │ │ │ ├── AbstractHolderMonitor.java │ │ │ │ ├── HolderLongMonitor.java │ │ │ │ └── HolderStringMonitor.java │ │ │ │ ├── tools │ │ │ │ └── visualgc │ │ │ │ │ ├── Arguments.java │ │ │ │ │ ├── GCSample.java │ │ │ │ │ ├── GCSpacePanel.java │ │ │ │ │ ├── GraphGC.java │ │ │ │ │ ├── Model.java │ │ │ │ │ ├── ModelFixer.java │ │ │ │ │ ├── MonitoredVmModel.java │ │ │ │ │ ├── VisualAgeHistogram.java │ │ │ │ │ ├── VisualGC.java │ │ │ │ │ ├── VisualGCPane.java │ │ │ │ │ ├── VisualGCPatch.java │ │ │ │ │ ├── VisualGCPerfTest.java │ │ │ │ │ ├── VisualHeap.java │ │ │ │ │ └── resource │ │ │ │ │ └── Res.java │ │ │ │ └── util │ │ │ │ └── Converter.java │ │ └── yworks │ │ │ └── util │ │ │ └── annotation │ │ │ └── Obfuscation.java │ ├── demo │ │ ├── BarChartKotlinDemo.kt │ │ └── LineChartKotlinDemo.kt │ ├── github │ │ └── beansoftapp │ │ │ └── visualgc │ │ │ ├── Exceptions.java │ │ │ ├── GetProcessID.java │ │ │ ├── IdeaParser.java │ │ │ ├── JpsHelper.java │ │ │ ├── MonitoredHostHelper.java │ │ │ └── NetbeansParser.java │ ├── icons │ │ └── PluginIcons.java │ ├── org │ │ ├── graalvm │ │ │ └── visualvm │ │ │ │ ├── core │ │ │ │ ├── datasupport │ │ │ │ │ ├── ClassNameComparator.java │ │ │ │ │ └── Positionable.java │ │ │ │ └── ui │ │ │ │ │ └── components │ │ │ │ │ ├── DataViewComponent.java │ │ │ │ │ ├── DisplayArea.java │ │ │ │ │ ├── DisplayAreaSupport.java │ │ │ │ │ ├── JExtendedSplitPane.java │ │ │ │ │ └── NotSupportedDisplayer.java │ │ │ │ ├── lib │ │ │ │ └── ui │ │ │ │ │ └── UIUtils.java │ │ │ │ └── uisupport │ │ │ │ └── UISupport.java │ │ ├── netbeans │ │ │ └── modules │ │ │ │ └── bugtracking │ │ │ │ └── tasks │ │ │ │ └── LinkLabel.java │ │ └── openide │ │ │ ├── awt │ │ │ └── Windows8VectorCloseButton.java │ │ │ └── util │ │ │ └── VectorIcon.java │ └── sun │ │ ├── jvmstat │ │ ├── monitor │ │ │ └── remote │ │ │ │ ├── RemoteHost.java │ │ │ │ └── RemoteVm.java │ │ └── perfdata │ │ │ └── monitor │ │ │ └── protocol │ │ │ └── rmi │ │ │ ├── MonitoredHostProvider.java │ │ │ ├── MonitoredHostRmiService.java │ │ │ ├── PerfDataBuffer.java │ │ │ ├── RemoteMonitoredVm.java │ │ │ └── RemoteVmManager.java │ │ └── tools │ │ └── jstatd │ │ ├── Jstatd.java │ │ ├── RemoteHostImpl.java │ │ └── RemoteVmImpl.java ├── visualgc.html ├── visualgc_idea.iml ├── visualgc_idea.jar └── visualgc_remote.md ├── visualgc_java8.iml └── visualgc_java8 ├── README.md ├── aliasmap ├── bug.txt ├── hotspot_counter.html ├── lib └── tools.jar ├── resources ├── closePanel.png ├── visualgc.png ├── visualgc.properties └── visualgc_zh_CN.properties ├── screenshot ├── vgc_cn.png ├── visualgc_cn.png ├── visualgc_en.png └── visualgc_ps_en.png ├── src ├── META-INF │ └── MANIFEST.MF ├── beansoft │ └── swing │ │ └── OptionPane.java ├── com │ ├── sun │ │ └── jvmstat │ │ │ ├── graph │ │ │ ├── FIFOList.java │ │ │ ├── GridDrawer.java │ │ │ ├── Level.java │ │ │ └── Line.java │ │ │ ├── tools │ │ │ └── visualgc │ │ │ │ ├── Arguments.java │ │ │ │ ├── GCSample.java │ │ │ │ ├── GCSpacePanel.java │ │ │ │ ├── GraphGC.java │ │ │ │ ├── Model.java │ │ │ │ ├── ModelFixer.java │ │ │ │ ├── MonitoredVmModel.java │ │ │ │ ├── VisualAgeHistogram.java │ │ │ │ ├── VisualGC.java │ │ │ │ ├── VisualGCPane.java │ │ │ │ ├── VisualGCPatch.java │ │ │ │ ├── VisualGCPerfTest.java │ │ │ │ ├── VisualHeap.java │ │ │ │ └── resource │ │ │ │ └── Res.java │ │ │ └── util │ │ │ └── Converter.java │ └── yworks │ │ └── util │ │ └── annotation │ │ └── Obfuscation.java ├── github │ └── beansoftapp │ │ └── visualgc │ │ ├── Exceptions.java │ │ ├── GetProcessID.java │ │ ├── IdeaParser.java │ │ ├── JpsHelper.java │ │ └── NetbeansParser.java └── org │ ├── graalvm │ └── visualvm │ │ ├── core │ │ ├── datasupport │ │ │ ├── ClassNameComparator.java │ │ │ └── Positionable.java │ │ └── ui │ │ │ └── components │ │ │ ├── DataViewComponent.java │ │ │ ├── DisplayArea.java │ │ │ ├── DisplayAreaSupport.java │ │ │ ├── JExtendedSplitPane.java │ │ │ └── NotSupportedDisplayer.java │ │ ├── lib │ │ └── ui │ │ │ └── UIUtils.java │ │ └── uisupport │ │ └── UISupport.java │ ├── netbeans │ └── modules │ │ └── bugtracking │ │ └── tasks │ │ └── LinkLabel.java │ └── openide │ ├── awt │ └── Windows8VectorCloseButton.java │ └── util │ └── VectorIcon.java ├── visualgc.cmd ├── visualgc.sh └── visualgc_java8.iml /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | #*.jar 15 | *.war 16 | *.nar 17 | *.ear 18 | #*.zip 19 | *.tar.gz 20 | *.rar 21 | 22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 23 | hs_err_pid* 24 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /.idea/ant.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/artifacts/_JDKThreadCPU_jar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | $PROJECT_DIR$/_JDKThreadCPU 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/artifacts/visualgc_idea_jar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | $PROJECT_DIR$/visualgc_idea/out 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/artifacts/visualgc_java8_jar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | $PROJECT_DIR$/out/artifacts/visualgc_java8_jar 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | -------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /.idea/description.html: -------------------------------------------------------------------------------- 1 | Simple Java application that includes a class with main() method -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/hotswap_agent.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.idea/libraries/junit.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/libraries/tools.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/project-template.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.idea/runConfigurations/vgc_idea.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2020, BeanSoft 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Java Perf Tools and IDEA Plugin DevKit Helper 2 | 3 | This repo contains mainly two parts: 4 | 5 | ## A. Visual Garbage Collection Monitoring Tool and JConsole performance tool 6 | 7 | a graphical tool for monitoring the HotSpot Garbage Collector, Compiler, and class loader. It can monitor both local and remote JVMs. 8 | 1. visualgc_fix 9 | minimal fix with original visualgc code to run under Java 8. 10 | 2. visualgc_java8 11 | Fix visualgc to run and add more gc details. 12 | 3. visualgc_idea 13 | A IDEA plugin with visualgc embed. 14 | 4. _JDKThreadCPU 15 | a JConsole plugin that displays the most active threads of the (Java) application being monitored by JConsole. 16 | 17 | ## B. An IDEA Plugin DevKit Helper 18 | 19 | This plugin will provides some feature on IDEA Plugin DevKit. The 1.0 only provides a small function that when 20 | you editing plugin.xml, the HTML content in description and change-notes will be treated as HTML so syntax highlighting 21 | and tag completion will work. 22 | -------------------------------------------------------------------------------- /_JDKThreadCPU/README.md: -------------------------------------------------------------------------------- 1 | # TopThreads Chinese Version 2 | TopThreads is a JConsole plugin that displays the most active threads of the (Java) application being monitored by JConsole. 3 | 4 | The original article introduction: https://sharing.luminis.eu/blog/new-version-of-topthreads-jconsole-plugin/ 5 | 6 | The original latest code version at: https://bitbucket.org/pjtr/topthreads/src/master/, and I'll create a IDEA plugin version in the near future. 7 | 8 | 9 | 10 | ## Usage 11 | 12 | To run TopThreads as JConsole plugin, pass the path to the jar file with the `-pluginpath` option: 13 | 14 | jconsole -pluginpath bean_topthreads.jar 15 | 16 | TopThreads can also be run as stand alone (Swing) application, and even as console application that runs in a terminal window! The latter is very usefull if you only have telnet or ssh access to a server you want to monitor and ssh tunneling and/or enabling remote jmx monitoring is not possible. 17 | 18 | ![](topthread_cn.png) 19 | -------------------------------------------------------------------------------- /_JDKThreadCPU/_JDKThreadCPU.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /_JDKThreadCPU/bean_topthreads.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /_JDKThreadCPU/bean_topthreads.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beansoft/visualgc_java8/aba0de83482f48aa1e861ccaea0c0031f0f1b852/_JDKThreadCPU/bean_topthreads.jar -------------------------------------------------------------------------------- /_JDKThreadCPU/jconsole.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beansoft/visualgc_java8/aba0de83482f48aa1e861ccaea0c0031f0f1b852/_JDKThreadCPU/jconsole.jar -------------------------------------------------------------------------------- /_JDKThreadCPU/jconsoleTopThread.cmd: -------------------------------------------------------------------------------- 1 | jconsole -pluginpath bean_topthreads.jar 2 | pause -------------------------------------------------------------------------------- /_JDKThreadCPU/jconsoleTopThread.sh: -------------------------------------------------------------------------------- 1 | jconsole -pluginpath bean_topthreads.jar 2 | -------------------------------------------------------------------------------- /_JDKThreadCPU/libs/jansi-1.12.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beansoft/visualgc_java8/aba0de83482f48aa1e861ccaea0c0031f0f1b852/_JDKThreadCPU/libs/jansi-1.12.jar -------------------------------------------------------------------------------- /_JDKThreadCPU/libs/junit.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beansoft/visualgc_java8/aba0de83482f48aa1e861ccaea0c0031f0f1b852/_JDKThreadCPU/libs/junit.jar -------------------------------------------------------------------------------- /_JDKThreadCPU/src/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Ant-Version: Apache Ant 1.6.5 3 | Created-By: 1.5.0_07-87 ("Apple Computer, Inc.") 4 | Main-Class: biz.beansoft.jmx.topthreads.Main 5 | 6 | -------------------------------------------------------------------------------- /_JDKThreadCPU/src/META-INF/services/com.sun.tools.jconsole.JConsolePlugin: -------------------------------------------------------------------------------- 1 | net.luminis.jmx.topthreads.PluginAdapter 2 | -------------------------------------------------------------------------------- /_JDKThreadCPU/src/biz/beansoft/jmx/topthreads/PluginAdapter.java: -------------------------------------------------------------------------------- 1 | package biz.beansoft.jmx.topthreads; 2 | 3 | import com.sun.tools.jconsole.JConsoleContext; 4 | import com.sun.tools.jconsole.JConsoleContext.ConnectionState; 5 | import com.sun.tools.jconsole.JConsolePlugin; 6 | import java.beans.PropertyChangeEvent; 7 | import java.beans.PropertyChangeListener; 8 | import java.util.Collections; 9 | import java.util.Map; 10 | import javax.management.MBeanServerConnection; 11 | import javax.swing.JPanel; 12 | import javax.swing.SwingWorker; 13 | 14 | /** 15 | * 此类似乎不能正确被VisualVM所识别. 16 | * @author BeanSoft 17 | * 18 | */ 19 | public class PluginAdapter extends JConsolePlugin 20 | { 21 | public static final String TAB_NAME = "线程CPU性能诊断"; 22 | 23 | public Map getTabs() 24 | { 25 | TopThreadsPanel topthreadspanel = new TopThreadsPanel(); 26 | ConnectionListener connectionlistener = new ConnectionListener(topthreadspanel); 27 | addContextPropertyChangeListener(connectionlistener); 28 | connectionlistener.checkConnection(); 29 | JPanel pane = topthreadspanel; 30 | return Collections.singletonMap(TAB_NAME, pane); 31 | } 32 | 33 | public SwingWorker newSwingWorker() 34 | { 35 | return null; 36 | } 37 | 38 | private class ConnectionListener 39 | implements PropertyChangeListener 40 | { 41 | private TopThreadsPanel jtopp; 42 | 43 | public ConnectionListener(TopThreadsPanel topthreadspanel) 44 | { 45 | jtopp = topthreadspanel; 46 | } 47 | 48 | public void checkConnection() 49 | { 50 | MBeanServerConnection localMBeanServerConnection = PluginAdapter.this.getContext().getMBeanServerConnection(); 51 | if (localMBeanServerConnection != null) 52 | this.jtopp.setMBeanServerConnection(localMBeanServerConnection); 53 | } 54 | 55 | public void propertyChange(PropertyChangeEvent paramPropertyChangeEvent) 56 | { 57 | if (paramPropertyChangeEvent.getPropertyName() == "connectionState") 58 | { 59 | JConsoleContext localJConsoleContext = PluginAdapter.this.getContext(); 60 | if (paramPropertyChangeEvent.getNewValue().equals(JConsoleContext.ConnectionState.CONNECTED)) 61 | { 62 | if (localJConsoleContext != null) 63 | this.jtopp.setMBeanServerConnection(localJConsoleContext.getMBeanServerConnection()); 64 | } 65 | else 66 | this.jtopp.setMBeanServerConnection(null); 67 | } 68 | } 69 | } 70 | } 71 | 72 | /* Location: C:\Users\BeanSoft\Downloads\topthreads.jar 73 | * Qualified Name: biz.beansoft.jmx.topthreads.PluginAdapter 74 | * JD-Core Version: 0.6.2 75 | */ -------------------------------------------------------------------------------- /_JDKThreadCPU/src/net/luminis/jmx/topthreads/ColoredHistoryRenderer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2016 Peter Doornbosch 3 | * 4 | * This file is part of TopThreads, a JConsole plugin to analyse CPU-usage per thread. 5 | * 6 | * All rights reserved. This program and the accompanying materials 7 | * are made available under the terms of the GNU Lesser General Public License 8 | * (LGPL) version 2.1 which accompanies this distribution, and is available at 9 | * http://www.gnu.org/licenses/lgpl-2.1.html 10 | * 11 | * TopThreads is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | */ 16 | package net.luminis.jmx.topthreads; 17 | 18 | import java.awt.Color; 19 | import java.awt.Graphics; 20 | import java.awt.Rectangle; 21 | 22 | /** 23 | * Cell renderer for the history of values. Each value is represented by a colored box, color 24 | * depends on value. 25 | */ 26 | public class ColoredHistoryRenderer extends CustomTableCellRendererBase 27 | { 28 | @Override 29 | protected void paintComponent(Graphics g) { 30 | Rectangle bounds = g.getClipBounds(); 31 | g.setColor(getBackground()); 32 | g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); 33 | 34 | int[] values = (int[]) table.getValueAt(row, column); 35 | int sum = 0; 36 | for (int value: values) 37 | sum += value; 38 | 39 | int height = getHeight(); 40 | int width = getWidth(); 41 | int partWidth = 25; 42 | for (int index = values.length - 1; index >= 0; index--) { 43 | Color color = determineColor(values[index]); 44 | int x0 = width - partWidth; 45 | int x1 = partWidth; 46 | width -= partWidth; 47 | float percentage = (float) Math.min(values[index], 100) / 100; 48 | int realHeigth = Math.round(percentage * height); 49 | int y0 = height - realHeigth; 50 | int y1 = height; 51 | g.setColor(color); 52 | g.fillRect(x0, y0, x1, y1); 53 | if (sum > 0) { 54 | g.setColor(Color.BLACK); 55 | g.drawString("" + values[index], x0 + 3, y1 - 5); 56 | } 57 | if (x0 <= 0) 58 | break; 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /_JDKThreadCPU/src/net/luminis/jmx/topthreads/ColoredIntegerCellRenderer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2016 Peter Doornbosch 3 | * 4 | * This file is part of TopThreads, a JConsole plugin to analyse CPU-usage per thread. 5 | * 6 | * All rights reserved. This program and the accompanying materials 7 | * are made available under the terms of the GNU Lesser General Public License 8 | * (LGPL) version 2.1 which accompanies this distribution, and is available at 9 | * http://www.gnu.org/licenses/lgpl-2.1.html 10 | * 11 | * TopThreads is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | */ 16 | package net.luminis.jmx.topthreads; 17 | 18 | import java.awt.Color; 19 | import java.awt.Graphics; 20 | import java.awt.Rectangle; 21 | 22 | /** 23 | * Cell renderer for the current value (percentage). Background of this cell is a colored box, 24 | * color depends on value. 25 | */ 26 | public class ColoredIntegerCellRenderer extends CustomTableCellRendererBase 27 | { 28 | @Override 29 | protected void paintComponent(Graphics g) { 30 | Rectangle bounds = g.getClipBounds(); 31 | g.setColor(getBackground()); 32 | g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); 33 | 34 | int value = (Integer) table.getValueAt(row, column); 35 | Color color = determineColor(value); 36 | g.setColor(color); 37 | int width = getWidth(); 38 | int height = getHeight(); 39 | int colorHeight = Math.round(Math.min(value, 100) * height / 100); 40 | g.fillRect(0, height - colorHeight, width, height); 41 | g.setColor(Color.BLACK); 42 | g.drawString("" + value, 0 + 3, height - 5); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /_JDKThreadCPU/src/net/luminis/jmx/topthreads/ConfigurationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2016 Peter Doornbosch 3 | * 4 | * This file is part of TopThreads, a JConsole plugin to analyse CPU-usage per thread. 5 | * 6 | * All rights reserved. This program and the accompanying materials 7 | * are made available under the terms of the GNU Lesser General Public License 8 | * (LGPL) version 2.1 which accompanies this distribution, and is available at 9 | * http://www.gnu.org/licenses/lgpl-2.1.html 10 | * 11 | * TopThreads is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | */ 16 | package net.luminis.jmx.topthreads; 17 | 18 | public class ConfigurationException extends Exception { 19 | 20 | public ConfigurationException(String message) { 21 | super(message); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /_JDKThreadCPU/src/net/luminis/jmx/topthreads/CustomClassloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2016 Peter Doornbosch 3 | * 4 | * This file is part of TopThreads, a JConsole plugin to analyse CPU-usage per thread. 5 | * 6 | * All rights reserved. This program and the accompanying materials 7 | * are made available under the terms of the GNU Lesser General Public License 8 | * (LGPL) version 2.1 which accompanies this distribution, and is available at 9 | * http://www.gnu.org/licenses/lgpl-2.1.html 10 | * 11 | * TopThreads is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | */ 16 | package net.luminis.jmx.topthreads; 17 | 18 | import java.io.ByteArrayOutputStream; 19 | import java.io.IOException; 20 | import java.io.InputStream; 21 | import java.net.URL; 22 | import java.net.URLClassLoader; 23 | 24 | public class CustomClassloader extends URLClassLoader { 25 | 26 | public CustomClassloader(URL[] urls, ClassLoader parent) { 27 | super(urls, parent); 28 | } 29 | 30 | @Override 31 | protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException { 32 | if (name.startsWith("net.luminis.jmx.sun")) { 33 | try { 34 | InputStream input = getSystemClassLoader().getResourceAsStream(name.replace('.', '/') + ".class"); 35 | byte[] buffer = new byte[1024]; 36 | int bytesRead; 37 | ByteArrayOutputStream output = new ByteArrayOutputStream(); 38 | while ((bytesRead = input.read(buffer)) != -1) { 39 | output.write(buffer, 0, bytesRead); 40 | } 41 | byte[] classBytes = output.toByteArray(); 42 | return defineClass(name, classBytes, 0, classBytes.length); 43 | } catch (IOException e) { 44 | e.printStackTrace(); 45 | throw new ClassNotFoundException("cannot find resource"); 46 | } 47 | } 48 | else { 49 | return super.loadClass(name, resolve); 50 | } 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /_JDKThreadCPU/src/net/luminis/jmx/topthreads/CustomTableCellRendererBase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2016 Peter Doornbosch 3 | * 4 | * This file is part of TopThreads, a JConsole plugin to analyse CPU-usage per thread. 5 | * 6 | * All rights reserved. This program and the accompanying materials 7 | * are made available under the terms of the GNU Lesser General Public License 8 | * (LGPL) version 2.1 which accompanies this distribution, and is available at 9 | * http://www.gnu.org/licenses/lgpl-2.1.html 10 | * 11 | * TopThreads is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | */ 16 | package net.luminis.jmx.topthreads; 17 | 18 | import javax.swing.JComponent; 19 | import javax.swing.JTable; 20 | import javax.swing.table.TableCellRenderer; 21 | import java.awt.Color; 22 | import java.awt.Component; 23 | 24 | public class CustomTableCellRendererBase extends JComponent implements TableCellRenderer 25 | { 26 | protected int row; 27 | protected int column; 28 | protected JTable table; 29 | 30 | @Override 31 | public Component getTableCellRendererComponent(JTable table, Object color, boolean isSelected, boolean hasFocus, int row, int column) { 32 | this.table = table; 33 | this.row = row; 34 | this.column = column; 35 | return this; 36 | } 37 | 38 | protected Color determineColor(int percentage) { 39 | // Guard against out-of-range values 40 | if (percentage < 0) 41 | percentage = 0; 42 | if (percentage > 100) 43 | percentage = 100; 44 | 45 | int red, green, blue; 46 | if (percentage < 50) { 47 | // Green to yellow gradient 48 | red = (int) (5.1 * percentage); 49 | green = 255; 50 | } else { 51 | // Yellow to read gradient 52 | red = 255; 53 | green = 255 - (int) ((percentage - 50) * 5.1); 54 | } 55 | blue = 0; 56 | return new Color(red, green, blue); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /_JDKThreadCPU/src/net/luminis/jmx/topthreads/Data.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2016 Peter Doornbosch 3 | * 4 | * This file is part of TopThreads, a JConsole plugin to analyse CPU-usage per thread. 5 | * 6 | * All rights reserved. This program and the accompanying materials 7 | * are made available under the terms of the GNU Lesser General Public License 8 | * (LGPL) version 2.1 which accompanies this distribution, and is available at 9 | * http://www.gnu.org/licenses/lgpl-2.1.html 10 | * 11 | * TopThreads is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | */ 16 | package net.luminis.jmx.topthreads; 17 | 18 | import java.util.List; 19 | import java.util.Map; 20 | 21 | public class Data 22 | { 23 | public List threadList; 24 | public Map threadStats; 25 | public int threadCount; 26 | public int cpuUsagePercentage; 27 | public StackTraceElement[] stackTrace; 28 | public Exception error; 29 | } 30 | -------------------------------------------------------------------------------- /_JDKThreadCPU/src/net/luminis/jmx/topthreads/InfoStats.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2016 Peter Doornbosch 3 | * 4 | * This file is part of TopThreads, a JConsole plugin to analyse CPU-usage per thread. 5 | * 6 | * All rights reserved. This program and the accompanying materials 7 | * are made available under the terms of the GNU Lesser General Public License 8 | * (LGPL) version 2.1 which accompanies this distribution, and is available at 9 | * http://www.gnu.org/licenses/lgpl-2.1.html 10 | * 11 | * TopThreads is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | */ 16 | package net.luminis.jmx.topthreads; 17 | 18 | public interface InfoStats 19 | { 20 | public long getId(); 21 | 22 | public String getName(); 23 | 24 | public int getPercentage(); 25 | 26 | public int[] getHistory(); 27 | 28 | public int getAverageUsage(); 29 | 30 | public Thread.State getState(); 31 | 32 | public long getCpuUsage(); 33 | 34 | public boolean getSelect(); 35 | 36 | public void setSelect(boolean on); 37 | 38 | public void setIndex(int index); 39 | } 40 | -------------------------------------------------------------------------------- /_JDKThreadCPU/src/net/luminis/jmx/topthreads/LocalConnector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2016 Peter Doornbosch 3 | * 4 | * This file is part of TopThreads, a JConsole plugin to analyse CPU-usage per thread. 5 | * 6 | * All rights reserved. This program and the accompanying materials 7 | * are made available under the terms of the GNU Lesser General Public License 8 | * (LGPL) version 2.1 which accompanies this distribution, and is available at 9 | * http://www.gnu.org/licenses/lgpl-2.1.html 10 | * 11 | * TopThreads is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | */ 16 | package net.luminis.jmx.topthreads; 17 | 18 | import javax.management.MBeanServerConnection; 19 | import java.io.IOException; 20 | import java.util.Map; 21 | 22 | /** 23 | * Provides methods for connecting to local JVM's. Depends on "sun" internal JDK classes! 24 | */ 25 | public interface LocalConnector { 26 | 27 | /** 28 | * @return map: pid -> process name (shortened) 29 | */ 30 | public Map getLocalVMs(); 31 | 32 | public MBeanServerConnection connect(Integer pid) throws IOException; 33 | } 34 | -------------------------------------------------------------------------------- /_JDKThreadCPU/src/net/luminis/jmx/topthreads/ProcessInfoStats.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2016 Peter Doornbosch 3 | * 4 | * This file is part of TopThreads, a JConsole plugin to analyse CPU-usage per thread. 5 | * 6 | * All rights reserved. This program and the accompanying materials 7 | * are made available under the terms of the GNU Lesser General Public License 8 | * (LGPL) version 2.1 which accompanies this distribution, and is available at 9 | * http://www.gnu.org/licenses/lgpl-2.1.html 10 | * 11 | * TopThreads is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | */ 16 | package net.luminis.jmx.topthreads; 17 | 18 | import java.lang.Thread.State; 19 | 20 | public class ProcessInfoStats extends AbstractInfoStats 21 | { 22 | private String name; 23 | 24 | public ProcessInfoStats(String name) { 25 | this.name = name; 26 | } 27 | 28 | @Override 29 | public String getName() { 30 | return name; 31 | } 32 | 33 | @Override 34 | public State getState() { 35 | return null; 36 | } 37 | 38 | @Override 39 | public boolean getSelect() { 40 | return false; 41 | } 42 | 43 | @Override 44 | public long getId() { 45 | return -1; 46 | } 47 | 48 | @Override 49 | public void setIndex(int index) { 50 | } 51 | 52 | @Override 53 | public void setSelect(boolean on) { 54 | } 55 | 56 | public long update(long cpuTime) 57 | { 58 | // First, save previous value in history. 59 | usageHistory[historyIndex] = percentage; 60 | historyIndex = ++historyIndex % historyLength; // The first real value will have index 1, but what the hack. 61 | if (nrOfValidValues <= historyLength) { 62 | // Note that nrOfValidValues will eventually be 1 larger than history length, 63 | // because the (current) percentage is also a valid value, and used for computing 64 | // the average, see getAverageUsage() 65 | nrOfValidValues++; 66 | } 67 | 68 | lastCpuUsage = cpuTime; 69 | return lastCpuUsage; 70 | } 71 | 72 | public void setPercentage(int cpuUsagePercentage) 73 | { 74 | percentage = cpuUsagePercentage; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /_JDKThreadCPU/src/net/luminis/jmx/topthreads/SwingUI.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2016 Peter Doornbosch 3 | * 4 | * This file is part of TopThreads, a JConsole plugin to analyse CPU-usage per thread. 5 | * 6 | * All rights reserved. This program and the accompanying materials 7 | * are made available under the terms of the GNU Lesser General Public License 8 | * (LGPL) version 2.1 which accompanies this distribution, and is available at 9 | * http://www.gnu.org/licenses/lgpl-2.1.html 10 | * 11 | * TopThreads is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | */ 16 | package net.luminis.jmx.topthreads; 17 | 18 | import javax.management.MBeanServerConnection; 19 | import javax.swing.JComponent; 20 | import javax.swing.JFrame; 21 | import javax.swing.JOptionPane; 22 | import javax.swing.border.EmptyBorder; 23 | import java.io.IOException; 24 | 25 | public class SwingUI 26 | { 27 | public SwingUI(String hostname, int port, String role, String password) 28 | { 29 | JFrame frame = null; 30 | 31 | try { 32 | MBeanServerConnection serverConnection = TopThreads.connect(hostname, port, role, password); 33 | 34 | frame = new JFrame(TopThreads.PROGRAM_NAME); 35 | 36 | TopThreadsPanel topThreadsPanel = new TopThreadsPanel(); 37 | JComponent contentPane = (JComponent) frame.getContentPane(); 38 | contentPane.add(topThreadsPanel); 39 | int borderWidth = 10; 40 | contentPane.setBorder(new EmptyBorder(borderWidth, borderWidth, borderWidth, borderWidth)); 41 | 42 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 43 | frame.setContentPane(contentPane); 44 | frame.setLocation(400, 0); 45 | frame.pack(); 46 | frame.setVisible(true); 47 | 48 | topThreadsPanel.connect(serverConnection); 49 | } catch (SecurityException e) { 50 | JOptionPane.showMessageDialog(frame, "Could not connect to " + hostname + ":" + port + ".\n" 51 | + (e.getMessage() != null && e.getMessage().trim() != ""? e.getMessage(): e), 52 | TopThreads.PROGRAM_NAME, JOptionPane.ERROR_MESSAGE); 53 | System.exit(1); 54 | } catch (IOException e) { 55 | JOptionPane.showMessageDialog(frame, "Could not connect to " + hostname + ":" + port 56 | + (e.getCause() != null && e.getCause().toString().contains("ConnectException")? " (connection refused).\n": ".\n") 57 | + "Check that the application you want to monitor has remote jmx monitoring enabled.", 58 | TopThreads.PROGRAM_NAME, JOptionPane.ERROR_MESSAGE); 59 | System.exit(1); 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /_JDKThreadCPU/src/org/jdesktop/swingworker/SwingPropertyChangeSupport.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beansoft/visualgc_java8/aba0de83482f48aa1e861ccaea0c0031f0f1b852/_JDKThreadCPU/src/org/jdesktop/swingworker/SwingPropertyChangeSupport.java -------------------------------------------------------------------------------- /_JDKThreadCPU/sun.license: -------------------------------------------------------------------------------- 1 | TopThreads was inspired by the JTop example provided by the Java 6 SDK, that included the following license. 2 | 3 | /* 4 | * @(#)JTop.java 1.5 06/05/08 5 | * 6 | * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions are met: 10 | * 11 | * -Redistribution of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 14 | * -Redistribution in binary form must reproduce the above copyright notice, 15 | * this list of conditions and the following disclaimer in the documentation 16 | * and/or other materials provided with the distribution. 17 | * 18 | * Neither the name of Sun Microsystems, Inc. or the names of contributors may 19 | * be used to endorse or promote products derived from this software without 20 | * specific prior written permission. 21 | * 22 | * This software is provided "AS IS," without a warranty of any kind. ALL 23 | * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING 24 | * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE 25 | * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") 26 | * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE 27 | * AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS 28 | * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST 29 | * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, 30 | * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY 31 | * OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, 32 | * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 33 | * 34 | * You acknowledge that this software is not designed, licensed or intended 35 | * for use in the design, construction, operation or maintenance of any 36 | * nuclear facility. 37 | */ 38 | -------------------------------------------------------------------------------- /_JDKThreadCPU/topthread_cn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beansoft/visualgc_java8/aba0de83482f48aa1e861ccaea0c0031f0f1b852/_JDKThreadCPU/topthread_cn.png -------------------------------------------------------------------------------- /_JDKThreadCPU/visualvmPlugin.cmd: -------------------------------------------------------------------------------- 1 | jvisualvm -J-Djconsole.plugin.path="%cd%\bean_topthreads.jar" 2 | pause -------------------------------------------------------------------------------- /devkit-helper/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /devkit-helper/.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | -------------------------------------------------------------------------------- /devkit-helper/.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /devkit-helper/.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /devkit-helper/.idea/kotlinc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /devkit-helper/.idea/libraries/devkit.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /devkit-helper/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 18 | 19 | 26 | -------------------------------------------------------------------------------- /devkit-helper/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /devkit-helper/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /devkit-helper/devkit-helper.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /devkit-helper/lib/devkit.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beansoft/visualgc_java8/aba0de83482f48aa1e861ccaea0c0031f0f1b852/devkit-helper/lib/devkit.jar -------------------------------------------------------------------------------- /devkit-helper/readme.md: -------------------------------------------------------------------------------- 1 | https://plugins.jetbrains.com/api/plugins/17501 -------------------------------------------------------------------------------- /devkit-helper/resources/META-INF/pluginIcon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /devkit-helper/resources/META-INF/pluginIcon_dark.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /devkit-helper/resources/colorSchemes/JdcrLangDarcula.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 12 | 17 | -------------------------------------------------------------------------------- /devkit-helper/resources/colorSchemes/JdcrLangDefault.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 12 | 17 | -------------------------------------------------------------------------------- /devkit-helper/resources/icons/gutter/descriptionFile.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /devkit-helper/resources/icons/gutter/descriptionFile_dark.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /devkit-helper/resources/icons/gutter/diff.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /devkit-helper/resources/icons/gutter/diff_dark.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /devkit-helper/resources/icons/gutter/plugin.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /devkit-helper/resources/icons/gutter/plugin_dark.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /devkit-helper/resources/icons/gutter/properties.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /devkit-helper/resources/icons/gutter/properties_dark.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /devkit-helper/resources/messages/DevkitHelperBundle.properties: -------------------------------------------------------------------------------- 1 | #module type 2 | module.title=IntelliJ Platform Plugin 3 | module.description=Plugin modules are used for developing plugins for IntelliJ Platform-based IDEs.
\ 4 | They provide IntelliJ Platform Plugin SDK and Run Configuration for running and debugging plugins inside an IDE. 5 | plugin.descriptor=IntelliJ Platform Plugin Descriptor 6 | 7 | line.marker.tooltip.extension.declaration={2} declaration in {3} 8 | line.marker.tooltip.extension.point.declaration={2} EP declaration in {3} 9 | 10 | gutter.related.option.description=Description 11 | gutter.related.option.before.after.templates=Before/After templates 12 | gutter.related.option.name=Description / Before|After templates 13 | gutter.related.navigation.popup.template.title=Select Template 14 | gutter.related.navigation.popup.template.tooltip=Before/After Templates 15 | gutter.related.extension.declaration=Declaration 16 | gutter.related.navigation.popup.description.tooltip=Description 17 | gutter.related.navigation.choose.extension=Choose Extension 18 | gutter.related.navigation.choose.extension.point=Choose Extension Point 19 | 20 | -------------------------------------------------------------------------------- /devkit-helper/resources/messages/JavaDocBundle.properties: -------------------------------------------------------------------------------- 1 | # Javadoc 2 | @author=Author: 3 | @create=Create: 4 | @date=Date: 5 | @see=See also: 6 | @since=Since: 7 | @throws=Throws: 8 | @exception=Exception: 9 | @return=Returns: 10 | @param=Params: 11 | @deprecated=Deprecated. 12 | @version=Version: 13 | @serial=Serializable field: 14 | @link=Link: 15 | 16 | # Java lang annotation 17 | java.lang.annotation.Documented=Documented 18 | java.lang.annotation.Inherited=Inherited 19 | java.lang.annotation.Native=Native 20 | java.lang.annotation.Repeatable=Repeatable 21 | java.lang.annotation.Target=Target 22 | java.lang.annotation.Retention=Retention 23 | 24 | # Java lang 25 | java.lang.Deprecated=Deprecated 26 | java.lang.Override=Override 27 | java.lang.SuppressWarnings=Suppress Warnings 28 | java.lang.SafeVarargs=Safe Var Args 29 | java.lang.FunctionalInterface=Functional Interface 30 | javax.validation.Valid=Valid 31 | 32 | jdk.internal.vm.annotation.Stable=Stable 33 | 34 | com.fasterxml.jackson.annotation.JsonFormat=Json Format 35 | 36 | # IDEA 37 | org.jetbrains.annotations.NotNull=Not Null 38 | org.jetbrains.annotations.Nullable=Allow Null 39 | org.jetbrains.annotations.ApiStatus.Internal=Internal API 40 | org.jetbrains.annotations.ApiStatus.Experimental=Experimental API 41 | org.jetbrains.annotations.ApiStatus.ScheduledForRemoval=API Scheduled For Removal 42 | org.jetbrains.annotations.ApiStatus.AvailableSince=API Available Since 43 | org.jetbrains.annotations.ApiStatus.NonExtendable=Non Extendable API 44 | org.jetbrains.annotations.ApiStatus.OverrideOnly=Override Only API 45 | org.jetbrains.annotations.NonNls=Non Nls 46 | com.intellij.openapi.util.NlsContexts.DetailedDescription=Nls Detailed Description 47 | com.intellij.openapi.util.NlsContexts.Tooltip=Nls Tooltip 48 | org.jetbrains.annotations.PropertyKey=Property Key 49 | com.intellij.openapi.util.NlsSafe=Nls Safe 50 | org.jetbrains.annotations.SystemIndependent=System Independent Path 51 | org.jetbrains.annotations.SystemDependent=System Dependent Path 52 | com.intellij.util.concurrency.annotations.RequiresBackgroundThread=Requires Background Thread 53 | com.intellij.util.concurrency.annotations.RequiresEdt=Requires Event Dispatch Thread 54 | com.intellij.util.concurrency.annotations.RequiresReadLock=Requires Read Lock 55 | com.intellij.util.concurrency.annotations.RequiresWriteLock=Requires Write Lock 56 | -------------------------------------------------------------------------------- /devkit-helper/resources/messages/JavaDocBundle_zh_CN.properties: -------------------------------------------------------------------------------- 1 | @author=作者: 2 | @create=创建于: 3 | @date=日期: 4 | @see=请参阅: 5 | @since=从以下版本开始: 6 | @throws=抛出: 7 | @exception=异常: 8 | @return=返回: 9 | @param=参数: 10 | @deprecated=过时的。 11 | @version=版本: 12 | @serial=序列化字段: 13 | @link=链接: 14 | java.lang.annotation.Documented=已文档记录 15 | java.lang.annotation.Inherited=继承的 16 | java.lang.annotation.Native=原生 17 | java.lang.annotation.Repeatable=可重复的 18 | java.lang.annotation.Target=目标 19 | java.lang.annotation.Retention=保留 20 | java.lang.Deprecated=已过时的 21 | java.lang.Override=覆盖 22 | java.lang.SuppressWarnings=抑制警告 23 | java.lang.SafeVarargs=安全的可变参数 24 | java.lang.FunctionalInterface=功能接口 25 | javax.validation.Valid=校验 26 | jdk.internal.vm.annotation.Stable=稳定的 27 | 28 | com.fasterxml.jackson.annotation.JsonFormat=Json格式 29 | 30 | # IDEA 31 | org.jetbrains.annotations.NotNull=非空 32 | org.jetbrains.annotations.Nullable=可空 33 | org.jetbrains.annotations.ApiStatus.Internal=内部 API 34 | org.jetbrains.annotations.ApiStatus.Experimental=体验版 API 35 | org.jetbrains.annotations.ApiStatus.ScheduledForRemoval=API 即将移除 36 | org.jetbrains.annotations.ApiStatus.AvailableSince=API 从版本可用 37 | org.jetbrains.annotations.ApiStatus.NonExtendable=不可扩展 API 38 | org.jetbrains.annotations.ApiStatus.OverrideOnly=只允许重载API 39 | org.jetbrains.annotations.NonNls=不可国际化 40 | com.intellij.openapi.util.NlsContexts.DetailedDescription=国际化 详细描述 41 | com.intellij.openapi.util.NlsContexts.Tooltip=国际化 提示信息 42 | org.jetbrains.annotations.PropertyKey=属性键 43 | com.intellij.openapi.util.NlsSafe=安全国际化 44 | org.jetbrains.annotations.SystemIndependent=操作系统无关的路径 45 | org.jetbrains.annotations.SystemDependent=操作系统相关的路径 46 | com.intellij.util.concurrency.annotations.RequiresBackgroundThread=需要后台线程执行 47 | com.intellij.util.concurrency.annotations.RequiresEdt=需要事件调度线程 48 | com.intellij.util.concurrency.annotations.RequiresReadLock=需要读取锁 49 | com.intellij.util.concurrency.annotations.RequiresWriteLock=需要写入锁 50 | -------------------------------------------------------------------------------- /devkit-helper/src/com/github/beansoft/devkit/DevkitHelperBundle.java: -------------------------------------------------------------------------------- 1 | package com.github.beansoft.devkit; 2 | 3 | import com.intellij.AbstractBundle; 4 | import com.intellij.BundleBase; 5 | import org.jetbrains.annotations.NonNls; 6 | import org.jetbrains.annotations.NotNull; 7 | import org.jetbrains.annotations.PropertyKey; 8 | 9 | import java.lang.ref.Reference; 10 | import java.lang.ref.SoftReference; 11 | import java.util.ResourceBundle; 12 | 13 | public final class DevkitHelperBundle { 14 | @NonNls public static final String BUNDLE = "messages.DevkitHelperBundle"; 15 | 16 | private DevkitHelperBundle() { 17 | } 18 | 19 | private static Reference ourBundle; 20 | 21 | @NotNull 22 | public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { 23 | return AbstractBundle.message(getBundle(), key, params);// 修正 by BeanSoft 去掉旧API调用 24 | } 25 | 26 | private static ResourceBundle getBundle() { 27 | ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle); 28 | if (bundle == null) { 29 | bundle = ResourceBundle.getBundle(BUNDLE); 30 | ourBundle = new SoftReference<>(bundle); 31 | } 32 | return bundle; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /devkit-helper/src/com/github/beansoft/devkit/helper/MyAction.java: -------------------------------------------------------------------------------- 1 | package com.github.beansoft.devkit.helper; 2 | 3 | import com.intellij.openapi.actionSystem.AnAction; 4 | import com.intellij.openapi.actionSystem.AnActionEvent; 5 | 6 | public class MyAction extends AnAction { 7 | 8 | @Override 9 | public void actionPerformed(AnActionEvent e) { 10 | // TODO: insert action logic here 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /devkit-helper/src/com/github/beansoft/devkit/javadoc/JavaDocBundle.java: -------------------------------------------------------------------------------- 1 | package com.github.beansoft.devkit.javadoc; 2 | 3 | import com.intellij.AbstractBundle; 4 | import org.jetbrains.annotations.NonNls; 5 | import org.jetbrains.annotations.NotNull; 6 | import org.jetbrains.annotations.PropertyKey; 7 | 8 | import java.lang.ref.Reference; 9 | import java.lang.ref.SoftReference; 10 | import java.util.ResourceBundle; 11 | 12 | public class JavaDocBundle { 13 | 14 | private static Reference ourBundle; 15 | @NonNls private static final String BUNDLE = "messages.JavaDocBundle"; 16 | 17 | public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { 18 | return AbstractBundle.message(getBundle(), key, params);// 修正 by BeanSoft 去掉旧API调用 19 | } 20 | 21 | public static boolean containsKey(String key) { 22 | return getBundle().containsKey(key); 23 | } 24 | 25 | private JavaDocBundle() { 26 | } 27 | 28 | private static ResourceBundle getBundle() { 29 | ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle); 30 | if (bundle == null) { 31 | bundle = ResourceBundle.getBundle(BUNDLE); 32 | ourBundle = new SoftReference<>(bundle); 33 | } 34 | return bundle; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /devkit-helper/src/com/github/beansoft/devkit/javadoc/utils/Tag.java: -------------------------------------------------------------------------------- 1 | package com.github.beansoft.devkit.javadoc.utils; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | public class Tag { 6 | 7 | @NotNull private String open; 8 | @NotNull private String close; 9 | 10 | public Tag(@NotNull String openTag, @NotNull String closeTag) { 11 | this.open = removeWS(openTag); 12 | this.close = removeWS(closeTag); 13 | } 14 | 15 | public boolean openIn(@NotNull String text){ 16 | return removeWS(text).contains(this.open); 17 | } 18 | 19 | public boolean closeIn(@NotNull String text){ 20 | return removeWS(text).contains(this.close); 21 | } 22 | 23 | private static final char ws = ' '; 24 | 25 | /** Remove spaces from given string. Optimised copy of Apache remove() */ 26 | @NotNull 27 | private String removeWS(@NotNull String text){ 28 | int index = text.indexOf(ws); 29 | if (index < 0) { 30 | return text; 31 | } 32 | final char[] chars = text.toCharArray(); 33 | int pos = index; 34 | for (int i = index; i < chars.length; i++) { 35 | if (chars[i] != ws) { 36 | chars[pos++] = chars[i]; 37 | } 38 | } 39 | return (new String(chars, 0, pos)); } 40 | } 41 | -------------------------------------------------------------------------------- /devkit-helper/src/com/github/beansoft/devkit/navigation/DevkitRelatedClassLineMarkerProviderBase.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. 2 | package com.github.beansoft.devkit.navigation; 3 | 4 | import com.intellij.codeInsight.daemon.RelatedItemLineMarkerInfo; 5 | import com.intellij.psi.PsiClass; 6 | import com.intellij.psi.PsiElement; 7 | import org.jetbrains.annotations.NotNull; 8 | import org.jetbrains.idea.devkit.navigation.DevkitRelatedLineMarkerProviderBase; 9 | import org.jetbrains.uast.UClass; 10 | import org.jetbrains.uast.UElement; 11 | import org.jetbrains.uast.UElementKt; 12 | import org.jetbrains.uast.UastUtils; 13 | 14 | import java.util.Collection; 15 | 16 | abstract class DevkitRelatedClassLineMarkerProviderBase extends DevkitRelatedLineMarkerProviderBase { 17 | @Override 18 | protected final void collectNavigationMarkers(@NotNull PsiElement element, @NotNull Collection> result) { 19 | // UAST is used for getting the class identifier to work for all UAST languages (not possible in plain PSI) 20 | UElement uElement = UastUtils.getUParentForIdentifier(element); 21 | if (!(uElement instanceof UClass)) { 22 | return; 23 | } 24 | PsiElement identifier = UElementKt.getSourcePsiElement(((UClass)uElement).getUastAnchor()); 25 | if (identifier == null) { 26 | return; 27 | } 28 | process(identifier, ((UClass)uElement).getJavaPsi(), result); 29 | } 30 | 31 | protected abstract void process(@NotNull PsiElement identifier, 32 | @NotNull PsiClass psiClass, 33 | @NotNull Collection> result); 34 | } 35 | -------------------------------------------------------------------------------- /devkit-helper/src/com/github/beansoft/devkit/navigation/ExtensionDeclarationRelatedItemLineMarkerProvider.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. 2 | package com.github.beansoft.devkit.navigation; 3 | 4 | import com.github.beansoft.devkit.DevkitHelperBundle; 5 | import com.github.beansoft.devkit.util.ActionLocatorJava; 6 | import com.github.beansoft.devkit.util.ActionLocatorKt; 7 | import com.intellij.codeInsight.daemon.RelatedItemLineMarkerInfo; 8 | import com.intellij.psi.PsiClass; 9 | import com.intellij.psi.PsiElement; 10 | import icons.DevkitIcons; 11 | import icons.PluginIcons; 12 | import org.jetbrains.annotations.NotNull; 13 | import org.jetbrains.idea.devkit.util.ExtensionCandidate; 14 | 15 | import javax.swing.*; 16 | import java.util.Collection; 17 | import java.util.List; 18 | // UAST, for Java and Kotlin is all OK 19 | public final class ExtensionDeclarationRelatedItemLineMarkerProvider extends DevkitRelatedClassLineMarkerProviderBase { 20 | 21 | @Override 22 | public String getName() { 23 | // This name will displays in Preferences | Editor | General | Gutter Icons 24 | return DevkitHelperBundle.message("gutter.related.extension.declaration"); 25 | } 26 | 27 | @NotNull 28 | @Override 29 | public Icon getIcon() { 30 | return PluginIcons.Gutter_Plugin; //DevkitIcons.Gutter.Plugin; 31 | } 32 | 33 | @Override 34 | protected void process(@NotNull PsiElement identifier, 35 | @NotNull PsiClass psiClass, 36 | @NotNull Collection> result) { 37 | // List targets = ExtensionLocatorKt.locateExtensionsByPsiClass(psiClass); 38 | // List targets = ActionLocatorKt.locateActionsByPsiClass(psiClass); 39 | List targets = ActionLocatorJava.locateActionsByPsiClass(psiClass); 40 | if (targets.isEmpty()) { 41 | return; 42 | } 43 | 44 | // System.out.println("ExtensionDeclarationRelatedItemLineMarkerProvider targets.size() =" + targets.size()); 45 | 46 | result.add(LineMarkerInfoHelper.createExtensionLineMarkerInfo(targets, identifier)); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /devkit-helper/src/com/github/beansoft/devkit/provider/SimpleLineMarkerProvider.java: -------------------------------------------------------------------------------- 1 | package com.github.beansoft.devkit.provider; 2 | 3 | import com.intellij.codeInsight.daemon.GutterIconNavigationHandler; 4 | import com.intellij.codeInsight.daemon.LineMarkerInfo; 5 | import com.intellij.codeInsight.daemon.LineMarkerProvider; 6 | import com.intellij.openapi.editor.markup.GutterIconRenderer; 7 | import com.intellij.pom.Navigatable; 8 | import com.intellij.psi.PsiElement; 9 | import com.intellij.util.Function; 10 | import org.jetbrains.annotations.NotNull; 11 | import org.jetbrains.annotations.Nullable; 12 | import org.slf4j.Logger; 13 | import org.slf4j.LoggerFactory; 14 | 15 | import javax.swing.*; 16 | import java.util.Collection; 17 | import java.util.List; 18 | import java.util.Optional; 19 | 20 | /** 21 | * TODO performance issue 22 | * @author beansoft@126.com 23 | */ 24 | public abstract class SimpleLineMarkerProvider implements LineMarkerProvider { 25 | 26 | private static final Logger logger = LoggerFactory.getLogger(SimpleLineMarkerProvider.class); 27 | 28 | @SuppressWarnings("unchecked") 29 | @Nullable 30 | @Override 31 | public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement element) { 32 | if (!isTheElement(element)) return null; 33 | logger.info("getLineMarkerInfo start, element: {}", element); 34 | logger.info("xml加入跳转图标开始"); 35 | Optional processResult = apply((F) element); 36 | Optional> optional = 37 | processResult.map(t -> new LineMarkerInfo<>( 38 | (F) element, 39 | element.getTextRange(), 40 | getIcon(), 41 | getTooltipProvider(t), 42 | getNavigationHandler(t), 43 | GutterIconRenderer.Alignment.CENTER 44 | )); 45 | logger.info("getLineMarkerInfo end"); 46 | return optional.orElse(null); 47 | } 48 | 49 | private Function getTooltipProvider(final T target) { 50 | return from -> getTooltip(from, target); 51 | } 52 | 53 | private GutterIconNavigationHandler getNavigationHandler(final T target) { 54 | return (e, from) -> getNavigatable(from, target).navigate(true); 55 | } 56 | 57 | public abstract boolean isTheElement(@NotNull PsiElement element); 58 | 59 | public abstract Optional apply(@NotNull F from); 60 | 61 | @NotNull 62 | public abstract Navigatable getNavigatable(@NotNull F from, @NotNull T target); 63 | 64 | @NotNull 65 | public abstract String getTooltip(@NotNull F from, @NotNull T target); 66 | 67 | @NotNull 68 | public abstract Icon getIcon(); 69 | } 70 | -------------------------------------------------------------------------------- /devkit-helper/src/com/github/beansoft/devkit/util/JavaUtils.java: -------------------------------------------------------------------------------- 1 | package com.github.beansoft.devkit.util; 2 | 3 | import com.intellij.openapi.project.Project; 4 | import com.intellij.psi.JavaPsiFacade; 5 | import com.intellij.psi.PsiClass; 6 | import com.intellij.psi.search.GlobalSearchScope; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | import java.util.Optional; 10 | 11 | public class JavaUtils { 12 | public static Optional findClazz(@NotNull Project project, @NotNull String clazzName) { 13 | return Optional.ofNullable(JavaPsiFacade.getInstance(project).findClass(clazzName, GlobalSearchScope.allScope(project))); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /devkit-helper/src/com/github/beansoft/devkit/util/PairProcessor.java: -------------------------------------------------------------------------------- 1 | package com.github.beansoft.devkit.util; 2 | 3 | /** 4 | * Generic callback with two params. 5 | * 6 | */ 7 | @FunctionalInterface 8 | public interface PairProcessor { 9 | 10 | boolean process(L left, R right); 11 | } 12 | -------------------------------------------------------------------------------- /devkit-helper/src/com/github/beansoft/devkit/util/PluginXmlUtil.java: -------------------------------------------------------------------------------- 1 | package com.github.beansoft.devkit.util; 2 | 3 | import com.intellij.lang.injection.InjectedLanguageManager; 4 | import com.intellij.psi.PsiElement; 5 | import com.intellij.psi.PsiFile; 6 | import com.intellij.psi.impl.source.html.HtmlDocumentImpl; 7 | import com.intellij.psi.util.PsiTreeUtil; 8 | import com.intellij.psi.xml.XmlDocument; 9 | import com.intellij.psi.xml.XmlFile; 10 | 11 | public class PluginXmlUtil { 12 | public static boolean isIdeaPluginTagContainingFile(PsiElement element) { 13 | if (element == null) { 14 | return false; 15 | } 16 | final PsiFile file = element.getContainingFile(); 17 | if (file != null) { 18 | if (file instanceof XmlFile && !InjectedLanguageManager.getInstance(element.getProject()).isInjectedFragment(file)) { 19 | final XmlDocument document = PsiTreeUtil.getParentOfType(element, XmlDocument.class, false); 20 | if (document instanceof HtmlDocumentImpl) { 21 | return false; 22 | } 23 | if (document == null || document.getRootTag() == null) { 24 | return false; 25 | } 26 | 27 | if ("idea-plugin".equals(document.getRootTag().getLocalName())) { 28 | return true; 29 | } 30 | } 31 | } 32 | return false; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /devkit-helper/src/com/github/beansoft/devkit/util/text/NlsSafe.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. 2 | package com.github.beansoft.devkit.util.text; 3 | 4 | import org.jetbrains.annotations.ApiStatus; 5 | 6 | import java.lang.annotation.*; 7 | 8 | /** 9 | * Marker annotation for strings that don't require localization but still could be displayed in UI. 10 | * Examples: 11 | *
    12 | *
  • File name or path
  • 13 | *
  • Project name
  • 14 | *
  • URL
  • 15 | *
  • Programming language or framework name
  • 16 | *
17 | */ 18 | @ApiStatus.Experimental 19 | @Retention(RetentionPolicy.CLASS) 20 | @Documented 21 | @Target({ElementType.TYPE_USE, ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD, ElementType.LOCAL_VARIABLE}) 22 | public @interface NlsSafe { 23 | } 24 | -------------------------------------------------------------------------------- /devkit-helper/src/icons/PluginIcons.java: -------------------------------------------------------------------------------- 1 | package icons; 2 | 3 | import com.intellij.openapi.util.IconLoader; 4 | import com.intellij.ui.LayeredIcon; 5 | import com.intellij.util.IconUtil; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import javax.swing.*; 9 | 10 | public class PluginIcons { 11 | public static final Icon Gutter_Plugin = load("/icons/gutter/plugin.svg"); 12 | 13 | @NotNull private static Icon load(String path) { 14 | try { 15 | return IconLoader.getIcon(path, PluginIcons.class); 16 | } catch (IllegalStateException e) { 17 | return null; 18 | } 19 | } 20 | 21 | public static @NotNull Icon scaleIconToSize(Icon icon, int size) { 22 | int width = icon.getIconWidth(); 23 | if (width == size) return icon; 24 | 25 | float scale = size / (float)width; 26 | icon = IconUtil.scale(icon, null, scale); 27 | return icon; 28 | } 29 | /** 30 | * see https://github.com/flutter/flutter-intellij/issues/4937 31 | * I've found the reason, the Jetbrains' developer had removed this method overlayIcons(javax.swing.Icon[]) from latest IJ CE code in ElementBase.java, but the LayeredIcon.java stays untouched. 32 | * The git log said: 33 | * platform.core.impl — remove dependency on intellij.platform.util.ui and intellij.platform.core.ui 34 | * java.psi.iml — remove dependency on intellij.platform.core.ui 35 | * @param icons 36 | * @return 37 | */ 38 | @NotNull 39 | public static Icon overlayIcons(@NotNull Icon ... icons) { 40 | final LayeredIcon icon = new LayeredIcon(icons.length); 41 | int i = 0; 42 | for (Icon ic : icons) { 43 | icon.setIcon(ic, i++); 44 | } 45 | return icon; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /visualgc.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /visualgc_fix/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /visualgc_fix/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | *.jar 15 | *.war 16 | *.nar 17 | *.ear 18 | #*.zip 19 | *.tar.gz 20 | *.rar 21 | 22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 23 | hs_err_pid* 24 | -------------------------------------------------------------------------------- /visualgc_fix/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | visualgc 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /visualgc_fix/README.md: -------------------------------------------------------------------------------- 1 | # visualgc 2 | original visualgc from Oracle.com with core fix to run under JDK 1.8+ 3 | -------------------------------------------------------------------------------- /visualgc_fix/src/beansoft/jvm/hotspot/util/GetProcessID.java: -------------------------------------------------------------------------------- 1 | package beansoft.jvm.hotspot.util; 2 | 3 | import java.lang.management.ManagementFactory; 4 | import java.lang.management.RuntimeMXBean; 5 | 6 | /** 7 | * http://rednaxelafx.iteye.com/blog/716918 8 | * Note: this class only works at Sun JDK and JRockit. 9 | * see:jrcmd.exe jrockit.tools.jrcmd.JrCmd in tools.jar 10 | * see:jps.exe 11 | * @author beansoft 12 | * 2012-01-31 13 | */ 14 | public class GetProcessID { 15 | 16 | public static int getPid() { 17 | RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean(); 18 | String name = runtime.getName(); // format: "pid@hostname" 19 | // System.out.println("name:" + name); 20 | try { 21 | return Integer.parseInt(name.substring(0, name.indexOf('@'))); 22 | } catch (Exception e) { 23 | return -1; 24 | } 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /visualgc_fix/src/com/sun/jvmstat/graph/GridDrawer.java: -------------------------------------------------------------------------------- 1 | package com.sun.jvmstat.graph; 2 | 3 | import java.awt.Color; 4 | import java.awt.Graphics; 5 | 6 | public class GridDrawer 7 | { 8 | 9 | private static Color defaultColor = new Color(0, 130, 66); 10 | private Color color; 11 | private Color secondaryColor; 12 | private double splitLevel; 13 | private int xIncrement; 14 | private int yIncrement; 15 | 16 | public GridDrawer(int i, int j, Color color1) 17 | { 18 | xIncrement = i; 19 | yIncrement = j; 20 | color = color1; 21 | } 22 | 23 | public GridDrawer(int i, int j) 24 | { 25 | this(i, j, defaultColor); 26 | } 27 | 28 | public GridDrawer() 29 | { 30 | this(10, 10); 31 | } 32 | 33 | public Color getPrimaryColor() 34 | { 35 | return color; 36 | } 37 | 38 | public void setPrimaryColor(Color color1) 39 | { 40 | color = color1; 41 | } 42 | 43 | public Color getSecondaryColor() 44 | { 45 | return secondaryColor; 46 | } 47 | 48 | public void setSecondaryColor(Color color1) 49 | { 50 | secondaryColor = color1; 51 | } 52 | 53 | public void splitRange(double d, Color color1) 54 | { 55 | secondaryColor = color1; 56 | splitRange(d); 57 | } 58 | 59 | public void splitRange(double d) 60 | { 61 | splitLevel = d; 62 | } 63 | 64 | protected void draw(Graphics g, int i, int j) 65 | { 66 | int k = (int)((double)(i * j) * splitLevel); 67 | int l = k / i; 68 | if (l > j) 69 | l = j; 70 | if (splitLevel != 0.0D && l == 0) 71 | l = 1; 72 | if (l != 0) 73 | { 74 | g.setColor(secondaryColor); 75 | for (int i1 = 0; i1 < i; i1 += xIncrement) 76 | g.drawLine(i1, 0, i1, l - 1); 77 | 78 | g.drawLine(i - 1, 0, i - 1, l - 1); 79 | for (int j1 = 0; j1 <= l - 1; j1 += yIncrement) 80 | g.drawLine(0, j1, i - 1, j1); 81 | 82 | } 83 | g.setColor(color); 84 | for (int k1 = 0; k1 < i; k1 += xIncrement) 85 | g.drawLine(k1, l, k1, j - 1); 86 | 87 | g.drawLine(i - 1, l, i - 1, j - 1); 88 | if (splitLevel == 0.0D || l % yIncrement == 0) 89 | g.drawLine(0, l, i - 1, l); 90 | l = ((l + yIncrement) / yIncrement) * yIncrement; 91 | for (int l1 = l; l1 < j; l1 += yIncrement) 92 | g.drawLine(0, l1, i - 1, l1); 93 | 94 | g.drawLine(0, j - 1, i, j - 1); 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /visualgc_fix/src/com/sun/jvmstat/graph/Level.java: -------------------------------------------------------------------------------- 1 | package com.sun.jvmstat.graph; 2 | 3 | import java.awt.Color; 4 | import java.awt.Graphics; 5 | import javax.swing.JComponent; 6 | 7 | public class Level extends JComponent 8 | { 9 | 10 | private Color color; 11 | private double level; 12 | private GridDrawer gridDrawer; 13 | 14 | public Level(Color color1) 15 | { 16 | color = color1; 17 | gridDrawer = new GridDrawer(10, 10); 18 | } 19 | 20 | public Level() 21 | { 22 | this(Color.WHITE); 23 | } 24 | 25 | public void draw() 26 | { 27 | repaint(); 28 | } 29 | 30 | public void update(Graphics g) 31 | { 32 | paint(g); 33 | } 34 | 35 | public void updateLevel(double d) 36 | { 37 | level = d; 38 | } 39 | 40 | public void updateGrayLevel(double d) 41 | { 42 | gridDrawer.splitRange(d, Color.DARK_GRAY); 43 | } 44 | 45 | public void drawLevel(Graphics g) 46 | { 47 | int i = getHeight(); 48 | int j = getWidth(); 49 | int k = (int)((double)(j * i) * level); 50 | int l = k / j; 51 | if (l > i) 52 | l = i; 53 | if (level != 0.0D && l == 0) 54 | l = 1; 55 | g.setColor(color); 56 | g.fill3DRect(0, i - l, j, i, true); 57 | } 58 | 59 | public Color getColor() 60 | { 61 | return color; 62 | } 63 | 64 | public void paint(Graphics g) 65 | { 66 | gridDrawer.draw(g, getWidth(), getHeight()); 67 | drawLevel(g); 68 | super.paint(g); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /visualgc_fix/src/com/sun/jvmstat/tools/visualgc/ModelFixer.java: -------------------------------------------------------------------------------- 1 | package com.sun.jvmstat.tools.visualgc; 2 | 3 | import beansoft.jvm.hotspot.util.Exceptions; 4 | import com.sun.jvmstat.tools.visualgc.MonitoredVmModel; 5 | import sun.jvmstat.monitor.MonitorException; 6 | import sun.jvmstat.monitor.MonitoredVm; 7 | 8 | import java.lang.reflect.Field; 9 | 10 | public class ModelFixer { 11 | public static final boolean fixMetaspace(MonitoredVmModel testModel, MonitoredVm monitoredVm) { 12 | try { 13 | Field PERM_SIZE = MonitoredVmModel.class.getDeclaredField("permSize"); 14 | Field PERM_CAPACITY = MonitoredVmModel.class.getDeclaredField("permCapacity"); 15 | Field PERM_USED = MonitoredVmModel.class.getDeclaredField("permUsed"); 16 | PERM_SIZE.setAccessible(true); 17 | PERM_CAPACITY.setAccessible(true); 18 | PERM_USED.setAccessible(true); 19 | if (PERM_SIZE.get(testModel) == null && PERM_CAPACITY 20 | .get(testModel) == null && PERM_USED 21 | .get(testModel) == null) { 22 | PERM_SIZE.set(testModel, monitoredVm.findByName("sun.gc.metaspace.maxCapacity")); 23 | PERM_CAPACITY.set(testModel, monitoredVm.findByName("sun.gc.metaspace.capacity")); 24 | PERM_USED.set(testModel, monitoredVm.findByName("sun.gc.metaspace.used")); 25 | return true; 26 | // this.hasMetaspace = true; 27 | } 28 | } catch (NoSuchFieldException ex) { 29 | Exceptions.printStackTrace(ex); 30 | } catch (SecurityException ex) { 31 | Exceptions.printStackTrace(ex); 32 | } catch (IllegalArgumentException ex) { 33 | Exceptions.printStackTrace(ex); 34 | } catch (IllegalAccessException ex) { 35 | Exceptions.printStackTrace(ex); 36 | } catch (MonitorException ex) { 37 | Exceptions.printStackTrace((Throwable)ex); 38 | } 39 | 40 | return false; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /visualgc_fix/src/com/sun/jvmstat/util/gc/GCCollector.java: -------------------------------------------------------------------------------- 1 | package com.sun.jvmstat.util.gc; 2 | 3 | import sun.jvmstat.monitor.LongMonitor; 4 | 5 | public class GCCollector 6 | { 7 | 8 | private String name; 9 | private int id; 10 | private LongMonitor invocations; 11 | private LongMonitor time; 12 | private LongMonitor lastEntry; 13 | private LongMonitor lastExit; 14 | private GCGeneration generations[]; 15 | private long hrtFrequency; 16 | private long reservedSize; 17 | 18 | public GCCollector(String s, int i, long l, LongMonitor longmonitor, LongMonitor longmonitor1, LongMonitor longmonitor2, 19 | LongMonitor longmonitor3, GCGeneration agcgeneration[]) 20 | { 21 | name = s; 22 | id = i; 23 | invocations = longmonitor; 24 | time = longmonitor1; 25 | lastEntry = longmonitor2; 26 | lastExit = longmonitor3; 27 | generations = agcgeneration; 28 | hrtFrequency = l; 29 | } 30 | 31 | public String getName() 32 | { 33 | return name; 34 | } 35 | 36 | public int getId() 37 | { 38 | return id; 39 | } 40 | 41 | public Number getInvocations() 42 | { 43 | return (Number)invocations.getValue(); 44 | } 45 | 46 | public Number getTime() 47 | { 48 | return (Number)time.getValue(); 49 | } 50 | 51 | public Number getLastEntry() 52 | { 53 | return (Number)lastEntry.getValue(); 54 | } 55 | 56 | public Number getLastExit() 57 | { 58 | return (Number)lastExit.getValue(); 59 | } 60 | 61 | public long getHrtFrequency() 62 | { 63 | return hrtFrequency; 64 | } 65 | 66 | private long computeReservedSize() 67 | { 68 | long l = 0L; 69 | for (int i = 0; i < generations.length; i++) 70 | l += generations[i].getSize(); 71 | 72 | return l; 73 | } 74 | 75 | public long getReservedSize() 76 | { 77 | if (reservedSize == 0L) 78 | reservedSize = computeReservedSize(); 79 | return reservedSize; 80 | } 81 | 82 | public Number getCommittedSize() 83 | { 84 | long l = 0L; 85 | for (int i = 0; i < generations.length; i++) 86 | l += generations[i].getCapacity().longValue(); 87 | 88 | return new Long(l); 89 | } 90 | 91 | public Number getUsed() 92 | { 93 | long l = 0L; 94 | for (int i = 0; i < generations.length; i++) 95 | l += generations[i].getUsed().longValue(); 96 | 97 | return new Long(l); 98 | } 99 | 100 | public int generations() 101 | { 102 | return generations.length; 103 | } 104 | 105 | public GCGeneration[] getGCGenerations() 106 | { 107 | return generations; 108 | } 109 | 110 | public GCGeneration getGCGeneration(int i) 111 | { 112 | return generations[i]; 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /visualgc_fix/src/com/sun/jvmstat/util/gc/GCGeneration.java: -------------------------------------------------------------------------------- 1 | // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov. 2 | // Jad home page: http://www.kpdus.com/jad.html 3 | // Decompiler options: packimports(3) fieldsfirst ansi space 4 | // Source File Name: GCGeneration.java 5 | 6 | package com.sun.jvmstat.util.gc; 7 | 8 | import sun.jvmstat.monitor.LongMonitor; 9 | 10 | public class GCGeneration 11 | { 12 | 13 | private String name; 14 | private int id; 15 | private long size; 16 | private long minCapacity; 17 | private LongMonitor capacity; 18 | private GCSpace gcSpaces[]; 19 | 20 | public GCGeneration(String s, int i, long l, long l1, LongMonitor longmonitor, 21 | GCSpace agcspace[]) 22 | { 23 | name = s; 24 | id = i; 25 | size = l; 26 | minCapacity = l1; 27 | capacity = longmonitor; 28 | gcSpaces = agcspace; 29 | } 30 | 31 | public String getName() 32 | { 33 | return name; 34 | } 35 | 36 | public int getId() 37 | { 38 | return id; 39 | } 40 | 41 | public long getSize() 42 | { 43 | return size; 44 | } 45 | 46 | public long getMinCapacity() 47 | { 48 | return minCapacity; 49 | } 50 | 51 | public Number getCapacity() 52 | { 53 | return (Number)capacity.getValue(); 54 | } 55 | 56 | public Number getUsed() 57 | { 58 | long l = 0L; 59 | for (int i = 0; i < gcSpaces.length; i++) 60 | l += gcSpaces[i].getUsed().longValue(); 61 | 62 | return new Long(l); 63 | } 64 | 65 | public int spaces() 66 | { 67 | return gcSpaces.length; 68 | } 69 | 70 | public GCSpace[] getGCSpaces() 71 | { 72 | return gcSpaces; 73 | } 74 | 75 | public GCSpace getGCSpace(int i) 76 | { 77 | return gcSpaces[i]; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /visualgc_fix/src/com/sun/jvmstat/util/gc/GCSpace.java: -------------------------------------------------------------------------------- 1 | package com.sun.jvmstat.util.gc; 2 | 3 | import sun.jvmstat.monitor.LongMonitor; 4 | 5 | public class GCSpace 6 | { 7 | 8 | private String name; 9 | private int id; 10 | private long size; 11 | private LongMonitor capacity; 12 | private LongMonitor used; 13 | 14 | public GCSpace(String s, int i, long l, LongMonitor longmonitor, LongMonitor longmonitor1) 15 | { 16 | name = s; 17 | id = i; 18 | size = l; 19 | capacity = longmonitor; 20 | used = longmonitor1; 21 | } 22 | 23 | public String getName() 24 | { 25 | return name; 26 | } 27 | 28 | public int getId() 29 | { 30 | return id; 31 | } 32 | 33 | public long getSize() 34 | { 35 | return size; 36 | } 37 | 38 | public Number getCapacity() 39 | { 40 | return (Number)capacity.getValue(); 41 | } 42 | 43 | public Number getUsed() 44 | { 45 | return (Number)used.getValue(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /visualgc_fix/src/version: -------------------------------------------------------------------------------- 1 | Version 3.0_b07 12/10/06 - Requires Sun Java SE 5.0 or later with the HotSpot JVM 2 | -------------------------------------------------------------------------------- /visualgc_fix/test/PID.java: -------------------------------------------------------------------------------- 1 | import java.lang.management.ManagementFactory; 2 | import java.lang.management.RuntimeMXBean; 3 | 4 | public class PID { 5 | public static void main(String[] args) throws Exception { 6 | int pid = getPid(); 7 | System.out.println("pid: " + pid); 8 | System.in.read(); // block the program so that we can do some probing on it 9 | } 10 | 11 | private static int getPid() { 12 | RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean(); 13 | String name = runtime.getName(); // format: "pid@hostname" 14 | System.out.println("name:" + name); 15 | try { 16 | return Integer.parseInt(name.substring(0, name.indexOf('@'))); 17 | } catch (Exception e) { 18 | return -1; 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /visualgc_fix/visualgc_fix.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /visualgc_idea/.run/VisualGCPane.run.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 15 | -------------------------------------------------------------------------------- /visualgc_idea/.run/plugin ZGC.run.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | -------------------------------------------------------------------------------- /visualgc_idea/.run/plugin jdk 17.run.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | -------------------------------------------------------------------------------- /visualgc_idea/.run/plugin.run.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | -------------------------------------------------------------------------------- /visualgc_idea/CompilerArgs.md: -------------------------------------------------------------------------------- 1 | ``` 2 | java: cannot find symbol 3 | symbol: class AbstractPerfDataBuffer 4 | location: package sun.jvmstat.perfdata.monitor 5 | ``` 6 | 7 | ![img.png](compiler_error.png) -------------------------------------------------------------------------------- /visualgc_idea/JDK 17 Guide.md: -------------------------------------------------------------------------------- 1 | You can run your IDEA with JBR/OpenJDK 17 together with VisualGC. 2 | 3 | # Mac OS 4 | Edit file `idea.vmoptions` (Mac OS) under the IDEA installation home /bin folder, append following line: 5 | 6 | ```properties 7 | --add-opens=java.desktop/java.awt.event=ALL-UNNAMED 8 | --add-opens=java.desktop/sun.font=ALL-UNNAMED 9 | --add-opens=java.desktop/java.awt=ALL-UNNAMED 10 | --add-opens=java.desktop/sun.awt=ALL-UNNAMED 11 | --add-opens=java.desktop/sun.awt.image=ALL-UNNAMED 12 | --add-opens=java.base/java.lang=ALL-UNNAMED 13 | --add-opens=java.base/java.util=ALL-UNNAMED 14 | --add-opens=java.desktop/javax.swing=ALL-UNNAMED 15 | --add-opens=java.desktop/sun.swing=ALL-UNNAMED 16 | --add-opens=java.desktop/javax.swing.plaf.basic=ALL-UNNAMED 17 | --add-opens=java.desktop/java.awt.peer=ALL-UNNAMED 18 | --add-opens=java.desktop/javax.swing.text.html=ALL-UNNAMED 19 | --add-exports=java.desktop/sun.font=ALL-UNNAMED 20 | --add-exports=java.desktop/com.apple.eawt=ALL-UNNAMED 21 | --add-exports=java.desktop/com.apple.laf=ALL-UNNAMED 22 | --add-exports=java.desktop/com.apple.eawt.event=ALL-UNNAMED 23 | --add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED 24 | --add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor.event=ALL-UNNAMED 25 | --add-exports=jdk.internal.jvmstat/sun.jvmstat.perfdata.monitor=ALL-UNNAMED 26 | ``` 27 | # Windows 28 | Edit `idea64.exe.vmoptions` under the IDEA installation home /bin folder, append following line: 29 | 30 | ```properties 31 | --add-opens=java.desktop/java.awt.event=ALL-UNNAMED 32 | --add-opens=java.desktop/sun.font=ALL-UNNAMED 33 | --add-opens=java.desktop/java.awt=ALL-UNNAMED 34 | --add-opens=java.desktop/sun.awt=ALL-UNNAMED 35 | --add-opens=java.base/java.lang=ALL-UNNAMED 36 | --add-opens=java.base/java.util=ALL-UNNAMED 37 | --add-opens=java.desktop/javax.swing=ALL-UNNAMED 38 | --add-opens=java.desktop/sun.swing=ALL-UNNAMED 39 | --add-opens=java.desktop/javax.swing.plaf.basic=ALL-UNNAMED 40 | --add-opens=java.desktop/java.awt.peer=ALL-UNNAMED 41 | --add-opens=java.desktop/javax.swing.text.html=ALL-UNNAMED 42 | --add-exports=java.desktop/sun.font=ALL-UNNAMED 43 | --add-exports=java.desktop/sun.java2d=ALL-UNNAMED 44 | --add-exports=java.desktop/sun.awt.windows=ALL-UNNAMED 45 | --add-exports=java.desktop/sun.awt.image=ALL-UNNAMED 46 | --add-opens=java.desktop/sun.awt.windows=ALL-UNNAMED 47 | --add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED 48 | --add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor.event=ALL-UNNAMED 49 | ``` 50 | 51 | # Configuration required by VisualGC plugin 52 | ```properties 53 | --add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED 54 | --add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor.event=ALL-UNNAMED 55 | --add-exports=jdk.internal.jvmstat/sun.jvmstat.perfdata.monitor=ALL-UNNAMED 56 | ``` 57 | 58 | # ZGC support 59 | ```properties 60 | -XX:+UnlockExperimentalVMOptions 61 | -XX:+UseZGC 62 | ``` 63 | 64 | 65 | Under Mac, please add `-Dsun.java2d.metal=true` -------------------------------------------------------------------------------- /visualgc_idea/README.md: -------------------------------------------------------------------------------- 1 | # visualgc_idea 2 | Note: This project is only worked under IDEA, and this project should depds on the IDEA plugin SDK. 3 | 4 | 推荐安装方式: File-> Settings-> Plugins 输入 VisualGC 即可下载. 5 | 6 | IDEA插件仓库主页: https://plugins.jetbrains.com/plugin/14557-visualgc IDEA 2020+版本可打开页面后点击 Install 按钮直接安装. 7 | 8 | An IDEA plugin which displays a Visual GC tool window inside your IDE. 9 | 10 | Usage: 11 | 12 | 1. From main interface bottom tool window; 13 | 2. From menu Tools > New VisualGC Window. 14 | 15 | 在IDEA中显示 VisualGC 子窗口, 便于一边运行代码一边观察GC情况. 16 | 17 | 用法: 18 | 19 | 1. 停靠窗口下方的 VisualGC; 20 | 2. 打开新的独立运行窗口使用菜单 Tools > New VisualGC Window. 21 | 22 | 如果需要不依赖IDEA单独运行, 请移步: [VisualGC 3.0 独立运行增强版, 支持JDK 8](https://www.cnblogs.com/beansoft/p/visualgc_jdk8_standalone.html) 23 | 24 | 安装方式: 25 | 26 | ![image](https://img2020.cnblogs.com/blog/2073018/202006/2073018-20200623071037706-310287575.png) 27 | 28 | 截图: 29 | 30 | ![vgc_idea_mac_en](screenshot/vgc_idea.png) 31 | 32 | [![vgc_idea_cn](https://img2020.cnblogs.com/blog/2073018/202006/2073018-20200620133346407-155505802.png)](https://img2020.cnblogs.com/blog/2073018/202006/2073018-20200620133345259-810121084.png) 33 | 34 | ![vgc_idea_cn_ps](https://img2020.cnblogs.com/blog/2073018/202006/2073018-20200623072624739-2118859173.png) 35 | 36 | 2020-9-20 37 | IDEA 2022的JBR 中缺少 rmi 相关的 package, 导致出现 jps 192.168.3.15 直接报错 38 | `C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2022.2\jbr-\bin> .\jps 192.168.3.15 39 | Exception in thread "main" java.lang.IllegalArgumentException: Could not find MonitoredHost for scheme: rmi 40 | at jdk.internal.jvmstat/sun.jvmstat.monitor.MonitoredHost.getMonitoredHost(MonitoredHost.java:177) 41 | at jdk.jcmd/sun.tools.jps.Jps.main(Jps.java:59)` 42 | 43 | 如果改 jdk.jstatd 中的包名, 又会无法通过RMI校验: 44 | class com.sun.proxy.jdk.proxy1.$Proxy0 cannot be cast to class beansoft.jvmstat.monitor.remote.RemoteHost (com.sun.proxy.jdk.proxy1.$Proxy0 is in module jdk.proxy1 of loader 'app'; beansoft.jvmstat.monitor.remote.RemoteHost is in unnamed module of loader 'app') 45 | 46 | 太难了... 自己定制一个 jstatd for JBR?? 47 | 48 | 如果改用 JBR SDK, 那么JCEF又没有, Markdown无法工作... 怎么办!!?? 49 | 50 | 修复问题: 51 | `access denied ("java.util.PropertyPermission" "sun.jvmstat.monitor.local" "read")` 52 | 53 | ```text 54 | grant { 55 | permission java.security.AllPermission; 56 | }; 57 | ``` -------------------------------------------------------------------------------- /visualgc_idea/bugreport.txt: -------------------------------------------------------------------------------- 1 | 2021-11-27 fixed 2 | 3 | java.lang.NullPointerException 4 | at github.beansoftapp.visualgc.JpsHelper.getVmStringValue(JpsHelper.java:225) 5 | at github.beansoftapp.visualgc.JpsHelper.getCommandLine(JpsHelper.java:197) 6 | at github.beansoftapp.visualgc.JpsHelper.getFirstArgument(JpsHelper.java:247) 7 | at github.beansoftapp.visualgc.JpsHelper.getMainClass(JpsHelper.java:160) 8 | at github.beansoftapp.visualgc.JpsHelper.getJvmPSList(JpsHelper.java:79) 9 | at com.sun.jvmstat.tools.visualgc.VisualGCPane$PsListModel.actionPerformed(VisualGCPane.java:588) -------------------------------------------------------------------------------- /visualgc_idea/compiler_error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beansoft/visualgc_java8/aba0de83482f48aa1e861ccaea0c0031f0f1b852/visualgc_idea/compiler_error.png -------------------------------------------------------------------------------- /visualgc_idea/lib/tools.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beansoft/visualgc_java8/aba0de83482f48aa1e861ccaea0c0031f0f1b852/visualgc_idea/lib/tools.jar -------------------------------------------------------------------------------- /visualgc_idea/resources/META-INF/pluginIcon.svg: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /visualgc_idea/resources/META-INF/withJava.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /visualgc_idea/resources/closePanel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beansoft/visualgc_java8/aba0de83482f48aa1e861ccaea0c0031f0f1b852/visualgc_idea/resources/closePanel.png -------------------------------------------------------------------------------- /visualgc_idea/resources/images/CustomGdbRunConfiguration.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /visualgc_idea/resources/images/MemoryView(RiderDark).svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /visualgc_idea/resources/images/MemoryView(RiderLight).svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /visualgc_idea/resources/images/debugWithVisualGC.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /visualgc_idea/resources/images/debugWithVisualGC_13.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /visualgc_idea/resources/images/debugWithVisualGC_13_dark.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /visualgc_idea/resources/images/debugWithVisualGC_dark.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /visualgc_idea/resources/images/donate.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beansoft/visualgc_java8/aba0de83482f48aa1e861ccaea0c0031f0f1b852/visualgc_idea/resources/images/donate.gif -------------------------------------------------------------------------------- /visualgc_idea/resources/images/donate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beansoft/visualgc_java8/aba0de83482f48aa1e861ccaea0c0031f0f1b852/visualgc_idea/resources/images/donate.png -------------------------------------------------------------------------------- /visualgc_idea/resources/images/mug.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beansoft/visualgc_java8/aba0de83482f48aa1e861ccaea0c0031f0f1b852/visualgc_idea/resources/images/mug.png -------------------------------------------------------------------------------- /visualgc_idea/resources/images/mug@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beansoft/visualgc_java8/aba0de83482f48aa1e861ccaea0c0031f0f1b852/visualgc_idea/resources/images/mug@2x.png -------------------------------------------------------------------------------- /visualgc_idea/resources/images/runWithVisualGC.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /visualgc_idea/resources/images/runWithVisualGC_13.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /visualgc_idea/resources/images/runWithVisualGC_13_dark.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /visualgc_idea/resources/images/runWithVisualGC_dark.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /visualgc_idea/resources/images/runnableMark.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /visualgc_idea/resources/visualgc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beansoft/visualgc_java8/aba0de83482f48aa1e861ccaea0c0031f0f1b852/visualgc_idea/resources/visualgc.png -------------------------------------------------------------------------------- /visualgc_idea/resources/visualgc.svg: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /visualgc_idea/resources/visualgc_dark.svg: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /visualgc_idea/resources/visualgc_zh_CN.properties: -------------------------------------------------------------------------------- 1 | 0.last.cause.1={0} 最近原因: {1} 2 | class.loader.time.0.loaded.1.unloaded.2=类加载器时间: {0} 已加载, {1} 已卸载 - {2} 3 | compile.time.0.compiles.1=编译时间: {0} 次编译 - {1} 4 | eden.space=Eden Space 5 | finalizer.queue.length.maximum.0.current.1.local.maximum.2=Finalizer Queue Length: Maximum {0} Current {1} Local Maximum {2} 6 | finalizer.time.0.objects.1=Finalizer Time: {0} objects - {1} 7 | gc.time.0.collections.1=GC时间: {0} 次收集, {1} 8 | graph=图表 9 | metaspace=Metaspace 10 | not.supported.for.this.jvm=不被当前Java虚拟机配置支持. 11 | old.gen=Old Gen 年老代 12 | perm.gen=Perm Gen 持久代 13 | survivor.0=Survivor 0 存活区0 14 | survivor.1=Survivor 1 存活区1 15 | survivor.age.histogram=Survivor Age Histogram 存活区年龄直方图 16 | collections= 次收集, 17 | old=年老 18 | perm=持久 19 | eden=Eden 20 | application.information=应用程序信息 21 | alive=运行 22 | elapsed.time=已运行时间: 23 | java.command.line.0=Java命令行: {0}\n\n 24 | java.vm.arguments.0=Java VM 参数: {0}\n\n 25 | java.vm.flags.0=Java VM 标志: {0}\n\n 26 | dead=停止 27 | s0=S0 28 | s1=S1 29 | refresh.rate=刷新速度 30 | msec=毫秒. 31 | auto=自动 32 | spaces=空间 33 | graphs=图表 34 | histogram=Histogram 存活直方图 35 | gc.collectors.n.time={0} GC 时间:{1}, {2} 次收集, {3} 36 | tenuring.threshold=对象晋升阈值: 37 | max.tenuring.threshold=最大对象晋升阈值: 38 | desired.survivor.size=期望存活区大小: 39 | current.survivor.size=当前存活区大小: 40 | parameters=参数 41 | visualgc.3.0.loading.jvm.process.list=VisualGC 3.0, 正在读取 JVM 进程列表 ... 42 | please.choose.a.process=请选择进程 43 | a.visual.garbage.collection.monitoring.tool=可视化垃圾回收监控工具 44 | info=提示 45 | this.tool.created.by=本工具由 github.com/beansoft/visualgc_java8 提供 46 | gc.policy.is.0=GC 策略是 {0} 47 | double.click.a.jvm.process.to.start=双击 JVM 进程开始查看 48 | jvm.browser=JVM 浏览器 49 | stop.monitor=停止监控 50 | show.reserved.space=显示已预留空间 51 | action.VisualGC.text=新建 VisualGC 窗口 52 | action.VisualGC.description=在新窗口中运行 VisualGC 53 | action.visualgc.MakeCoffeeAction.text=打赏 VisualGC 54 | action.visualgc.MakeCoffeeAction.description=打赏支持 VisualGC 的未来研发, 本插件主要功能将保持免费使用 55 | connect.remote.jvm=连接远程Java虚拟机 56 | remote.more.info=更多信息请阅读此指南: 如何可视化监视远程JVM 57 | remote.jvm.help.title=点击此按钮连接到远程助记并监控JVM 58 | remote.jvm.help.description=必须首先在远程服务器上运行jstatd 59 | connect.remote.jvm.message=请输入远程服务器地址(示例输入 192.168.3.15 或 192.168.3.15:1099), 输入空值将会连接到本地的 Java 进程 60 | link.label.error.fetch.jvm.list.please.add.following.lines.to.opened.editor=无法读取Java进程列表: 请向打开的编辑器中添加下列代码! 61 | dialog.title.please.edit.file.restart.ide=请修改打开的文件并重启开发工具 62 | link.label.more.info=更多信息 63 | tooltip.title.unable.to.access.jdk.jvmstat.classes=无法访问 JDK jvmstat 类 64 | status.text.loading.jvm.process.list=载入 JVM 进程列表中... 65 | unlock.hint.msg=很抱歉, 由于您未注册插件, ZG算法和远程Java进程监视功能已被锁定. 不过本插件的大部分功能都可以免费使用.\n您是否希望注册插件解锁这些功能或者开始30天免费试用? 66 | unreg.msg=很抱歉, 您未获取解锁权限. \n 然而本插件的大部分功能仍可以免费使用. 67 | malformed.vm.identifier.0=无效的 VM 连接地址: {0} 68 | registed.thanks.message=您已注册 VisualGC.\n感谢您使它变得更好! -------------------------------------------------------------------------------- /visualgc_idea/screenshot/vgc_idea.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beansoft/visualgc_java8/aba0de83482f48aa1e861ccaea0c0031f0f1b852/visualgc_idea/screenshot/vgc_idea.png -------------------------------------------------------------------------------- /visualgc_idea/screenshot/vgc_idea_cn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beansoft/visualgc_java8/aba0de83482f48aa1e861ccaea0c0031f0f1b852/visualgc_idea/screenshot/vgc_idea_cn.png -------------------------------------------------------------------------------- /visualgc_idea/screenshot/vgc_idea_cn_ps.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beansoft/visualgc_java8/aba0de83482f48aa1e861ccaea0c0031f0f1b852/visualgc_idea/screenshot/vgc_idea_cn_ps.png -------------------------------------------------------------------------------- /visualgc_idea/screenshot/vgc_idea_mac_en.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beansoft/visualgc_java8/aba0de83482f48aa1e861ccaea0c0031f0f1b852/visualgc_idea/screenshot/vgc_idea_mac_en.png -------------------------------------------------------------------------------- /visualgc_idea/screenshot/visualgc_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beansoft/visualgc_java8/aba0de83482f48aa1e861ccaea0c0031f0f1b852/visualgc_idea/screenshot/visualgc_dark.png -------------------------------------------------------------------------------- /visualgc_idea/screenshot/visualgc_idea_spring_boot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beansoft/visualgc_java8/aba0de83482f48aa1e861ccaea0c0031f0f1b852/visualgc_idea/screenshot/visualgc_idea_spring_boot.png -------------------------------------------------------------------------------- /visualgc_idea/screenshot/visualgc_idea_tomcat_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beansoft/visualgc_java8/aba0de83482f48aa1e861ccaea0c0031f0f1b852/visualgc_idea/screenshot/visualgc_idea_tomcat_dark.png -------------------------------------------------------------------------------- /visualgc_idea/screenshot/zgc_en.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beansoft/visualgc_java8/aba0de83482f48aa1e861ccaea0c0031f0f1b852/visualgc_idea/screenshot/zgc_en.png -------------------------------------------------------------------------------- /visualgc_idea/src/TextPaneTest.java: -------------------------------------------------------------------------------- 1 | import java.awt.*; 2 | 3 | import java.awt.event.*; 4 | 5 | import javax.swing.*; 6 | 7 | import javax.swing.border.*; 8 | 9 | import javax.swing.text.AttributeSet; 10 | import javax.swing.text.SimpleAttributeSet; 11 | import javax.swing.text.StyleConstants; 12 | import javax.swing.text.StyleContext; 13 | 14 | public class TextPaneTest extends JFrame 15 | { 16 | private JPanel topPanel; 17 | private JTextPane tPane; 18 | 19 | public TextPaneTest() 20 | { 21 | topPanel = new JPanel(); 22 | 23 | setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 24 | setLocationRelativeTo(null); 25 | 26 | EmptyBorder eb = new EmptyBorder(new Insets(10, 10, 10, 10)); 27 | 28 | tPane = new JTextPane(); 29 | tPane.setBorder(eb); 30 | //tPane.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY)); 31 | tPane.setMargin(new Insets(5, 5, 5, 5)); 32 | 33 | topPanel.add(tPane); 34 | 35 | appendToPane(tPane, "My Name is Too Good.\n", Color.RED); 36 | appendToPane(tPane, "I wish I could be ONE of THE BEST on ", Color.BLUE); 37 | appendToPane(tPane, "Stack", Color.DARK_GRAY); 38 | appendToPane(tPane, "Over", Color.MAGENTA); 39 | appendToPane(tPane, "flow", Color.ORANGE); 40 | 41 | getContentPane().add(topPanel); 42 | 43 | pack(); 44 | setVisible(true); 45 | } 46 | 47 | private void appendToPane(JTextPane tp, String msg, Color c) 48 | { 49 | StyleContext sc = StyleContext.getDefaultStyleContext(); 50 | AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground, c); 51 | 52 | aset = sc.addAttribute(aset, StyleConstants.FontFamily, "Lucida Console"); 53 | aset = sc.addAttribute(aset, StyleConstants.Alignment, StyleConstants.ALIGN_JUSTIFIED); 54 | 55 | int len = tp.getDocument().getLength(); 56 | tp.setCaretPosition(len); 57 | tp.setCharacterAttributes(aset, false); 58 | tp.replaceSelection(msg); 59 | } 60 | 61 | public static void main(String... args) 62 | { 63 | SwingUtilities.invokeLater(new Runnable() 64 | { 65 | public void run() 66 | { 67 | new TextPaneTest(); 68 | } 69 | }); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /visualgc_idea/src/beansoft/swing/OptionPane.java: -------------------------------------------------------------------------------- 1 | /* 2 | * @(#)OptionPane.java 1.01 2008-10-5 3 | * 4 | * Copyright 2005-2008 BeanSoft@126.com. All rights reserved. 5 | * PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 6 | */ 7 | package beansoft.swing; 8 | 9 | import javax.swing.*; 10 | import java.awt.*; 11 | 12 | /** 13 | * OptionPane, some useful method from javax.swing.JOptionPane with customized icon. 14 | * @author beansoft 15 | * @version 1.01 2008-10-5 16 | */ 17 | public class OptionPane { 18 | // Enable sounds 19 | static { 20 | UIManager.put("AuditoryCues.playList", 21 | UIManager.get("AuditoryCues.allAuditoryCues")); 22 | } 23 | 24 | /** 25 | * Display a warning message dialog. 26 | * @param parentComponent - 父组件 27 | * @param message - 消息内容 28 | * @param title - 消息标题 29 | */ 30 | public static void showWarningMessageDialog(Component parentComponent, Object message, String title) { 31 | javax.swing.JOptionPane.showMessageDialog(parentComponent, message, title, 32 | JOptionPane.WARNING_MESSAGE); 33 | } 34 | 35 | /** 36 | * Display a error message dialog. 37 | * @param parentComponent - 父组件 38 | * @param message - 消息内容 39 | * @param title - 消息标题 40 | */ 41 | public static void showErrorMessageDialog(Component parentComponent, Object message, String title) { 42 | javax.swing.JOptionPane.showMessageDialog(parentComponent, message, title, 43 | JOptionPane.ERROR_MESSAGE); 44 | } 45 | 46 | /** 47 | * Display a info message dialog. 48 | * @param parentComponent - 父组件 49 | * @param message - 消息内容 50 | * @param title - 消息标题 51 | */ 52 | public static void showInfoMessageDialog(Component parentComponent, Object message, String title) { 53 | javax.swing.JOptionPane.showMessageDialog(parentComponent, message, title, 54 | JOptionPane.INFORMATION_MESSAGE); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /visualgc_idea/src/com/github/beansoft/jvm/ApplicationSettingsService.java: -------------------------------------------------------------------------------- 1 | package com.github.beansoft.jvm; 2 | 3 | import com.intellij.openapi.application.Application; 4 | import com.intellij.openapi.application.ApplicationManager; 5 | import com.intellij.openapi.components.PersistentStateComponent; 6 | import com.intellij.openapi.components.ServiceManager; 7 | import com.intellij.openapi.components.State; 8 | import com.intellij.openapi.components.Storage; 9 | import com.intellij.openapi.diagnostic.Logger; 10 | import org.jetbrains.annotations.NotNull; 11 | 12 | @State(name = "VisualGCIDEA", storages = {@Storage("VisualGCIDEA.xml")}) 13 | public class ApplicationSettingsService implements PersistentStateComponent { 14 | private static final Logger log = Logger.getInstance(ApplicationSettingsService.class.getName()); 15 | 16 | private PluginSettings settings = new PluginSettings(); 17 | 18 | public static ApplicationSettingsService getInstance() { 19 | return ApplicationManager.getApplication().getService(ApplicationSettingsService.class); 20 | } 21 | 22 | @NotNull 23 | public String getComponentName() { 24 | return "VisualGC"; 25 | } 26 | 27 | 28 | @NotNull 29 | @Override 30 | public PluginSettings getState() { 31 | if (settings == null) { 32 | settings = new PluginSettings(); 33 | } 34 | return settings; 35 | } 36 | 37 | @Override 38 | public void loadState(PluginSettings state) { 39 | this.settings = state; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /visualgc_idea/src/com/github/beansoft/jvm/Donate.java: -------------------------------------------------------------------------------- 1 | package com.github.beansoft.jvm; 2 | 3 | import com.intellij.ide.BrowserUtil; 4 | import com.intellij.openapi.diagnostic.Logger; 5 | import com.intellij.openapi.util.IconLoader; 6 | import icons.PluginIcons; 7 | 8 | import javax.swing.*; 9 | import java.awt.event.ActionEvent; 10 | import java.awt.event.ActionListener; 11 | 12 | public class Donate { 13 | private static final Logger LOG = Logger.getInstance(Donate.class); 14 | 15 | public static JComponent newDonateButton(JPanel donatePanel) { 16 | JButton donate = new JButton(); 17 | donate.setBorder(null); 18 | donate.setIcon(PluginIcons.Donate); 19 | donate.setContentAreaFilled(true); 20 | donate.addActionListener(new ActionListener() { 21 | @Override 22 | public void actionPerformed(ActionEvent e) { 23 | BrowserUtil.browse("https://plugins.jetbrains.com/plugin/14557-visualgc/pricing"); 24 | } 25 | }); 26 | donate.putClientProperty("JButton.backgroundColor", donatePanel.getBackground()); 27 | return donate; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /visualgc_idea/src/com/github/beansoft/jvm/Hacks.java: -------------------------------------------------------------------------------- 1 | package com.github.beansoft.jvm; 2 | 3 | /** 4 | * @author Vojtech Krasa 5 | */ 6 | public class Hacks { 7 | public static final String BUNDLED_SERVERS_RUN_PROFILE_STATE = "PatchedLocalState"; 8 | public static final String BUNDLED_SERVERS_RUN_PROFILE = "com.intellij.javaee"; 9 | } 10 | -------------------------------------------------------------------------------- /visualgc_idea/src/com/github/beansoft/jvm/LogHelper.java: -------------------------------------------------------------------------------- 1 | package com.github.beansoft.jvm; 2 | 3 | import com.intellij.openapi.diagnostic.Logger; 4 | 5 | public class LogHelper { 6 | private static final Logger log = Logger.getInstance(LogHelper.class.getName()); 7 | 8 | public static void print(String x, Object thisInstance) { 9 | if (log.isDebugEnabled()) { 10 | String simpleName = "LogHelper : "; 11 | if (thisInstance != null) { 12 | simpleName = thisInstance.getClass().getSimpleName() + ": "; 13 | } 14 | log.debug(simpleName + x); 15 | } 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /visualgc_idea/src/com/github/beansoft/jvm/MyConfigurable.java: -------------------------------------------------------------------------------- 1 | package com.github.beansoft.jvm; 2 | 3 | import com.intellij.openapi.options.Configurable; 4 | import com.intellij.openapi.options.ConfigurationException; 5 | import com.intellij.openapi.options.ShowSettingsUtil; 6 | import com.intellij.openapi.project.Project; 7 | import org.jetbrains.annotations.Nls; 8 | import org.jetbrains.annotations.NonNls; 9 | import org.jetbrains.annotations.Nullable; 10 | 11 | import javax.swing.*; 12 | 13 | public class MyConfigurable implements Configurable { 14 | private SettingsDialog form; 15 | 16 | public static boolean openSettingsIfNotConfigured(Project project) { 17 | ApplicationSettingsService instance = ApplicationSettingsService.getInstance(); 18 | PluginSettings state = instance.getState(); 19 | boolean ok = true; 20 | if (!PluginSettings.isValid(state)) { 21 | ok = ShowSettingsUtil.getInstance().editConfigurable(project, new MyConfigurable()); 22 | } 23 | return ok; 24 | } 25 | 26 | @Nls 27 | public String getDisplayName() { 28 | return "VisualGC"; 29 | } 30 | 31 | @Nullable 32 | public Icon getIcon() { 33 | return null; 34 | } 35 | 36 | @Nullable 37 | @NonNls 38 | public String getHelpTopic() { 39 | return null; 40 | } 41 | 42 | public JComponent createComponent() { 43 | if (form == null) { 44 | form = new SettingsDialog(); 45 | } 46 | return form.getRootComponent(); 47 | } 48 | 49 | public boolean isModified() { 50 | return form.isModified(ApplicationSettingsService.getInstance().getState()); 51 | } 52 | 53 | public void apply() throws ConfigurationException { 54 | PluginSettings settings = ApplicationSettingsService.getInstance().getState(); 55 | if (form != null) { 56 | form.getData(settings); 57 | } 58 | } 59 | 60 | public void reset() { 61 | PluginSettings settings = ApplicationSettingsService.getInstance().getState(); 62 | if (form != null) { 63 | form.setDataCustom(settings); 64 | } 65 | } 66 | 67 | public void disposeUIResources() { 68 | form = null; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /visualgc_idea/src/com/github/beansoft/jvm/PluginSettings.java: -------------------------------------------------------------------------------- 1 | package com.github.beansoft.jvm; 2 | 3 | 4 | import com.github.beansoft.jvm.integration.VisualGCHelper; 5 | 6 | public class PluginSettings { 7 | 8 | private String visualVmExecutable; 9 | private String durationToSetContextToButton = "10000"; 10 | private String delayForVisualVMStart = "10000"; 11 | /** Remote JVM host address */ 12 | private String remoteJvmURL; 13 | 14 | 15 | public String getVisualVmExecutable() { 16 | return visualVmExecutable; 17 | } 18 | 19 | public void setVisualVmExecutable(final String visualVmExecutable) { 20 | this.visualVmExecutable = visualVmExecutable; 21 | } 22 | 23 | 24 | public static boolean isValid(PluginSettings state) { 25 | return state != null && VisualGCHelper.isValidPath(state.getVisualVmExecutable()); 26 | } 27 | 28 | public String getDurationToSetContextToButton() { 29 | return durationToSetContextToButton; 30 | } 31 | 32 | public void setDurationToSetContextToButton(final String durationToSetContextToButton) { 33 | this.durationToSetContextToButton = durationToSetContextToButton; 34 | } 35 | 36 | public String getDelayForVisualVMStart() { 37 | return delayForVisualVMStart; 38 | } 39 | 40 | public void setDelayForVisualVMStart(String delayForVisualVMStart) { 41 | this.delayForVisualVMStart = delayForVisualVMStart; 42 | } 43 | 44 | public long getDurationToSetContextToButtonAsLong() { 45 | return Long.parseLong(durationToSetContextToButton); 46 | } 47 | 48 | public long getDelayForVisualVMStartAsLong() { 49 | return Long.parseLong(delayForVisualVMStart); 50 | } 51 | 52 | 53 | public String getRemoteJvmURL() { 54 | return remoteJvmURL; 55 | } 56 | 57 | public void setRemoteJvmURL(String remoteJvmURL) { 58 | this.remoteJvmURL = remoteJvmURL; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /visualgc_idea/src/com/github/beansoft/jvm/action/SettingsAction.java: -------------------------------------------------------------------------------- 1 | package com.github.beansoft.jvm.action; 2 | 3 | import com.github.beansoft.idea.BaseTooltipAction; 4 | import com.github.beansoft.jvm.MyConfigurable; 5 | import com.intellij.icons.AllIcons; 6 | import com.intellij.ide.actions.RevealFileAction; 7 | import com.intellij.openapi.actionSystem.AnActionEvent; 8 | import com.intellij.openapi.options.ShowSettingsUtil; 9 | import com.intellij.openapi.util.text.StringUtil; 10 | import org.jetbrains.annotations.NotNull; 11 | 12 | import java.io.File; 13 | 14 | public class SettingsAction extends BaseTooltipAction { 15 | public SettingsAction() { 16 | super("Open VisualGC Setting", "Modify VisualGC to monitor server integration options.", AllIcons.General.Settings); 17 | } 18 | 19 | /** 20 | * Implement this method to provide your action handler. 21 | * 22 | * @param e Carries information on the invocation place 23 | */ 24 | @Override 25 | public void actionPerformed(@NotNull AnActionEvent e) { 26 | ShowSettingsUtil.getInstance().editConfigurable(e.getProject(), new MyConfigurable()); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /visualgc_idea/src/com/github/beansoft/jvm/executor/DebugVisualGCExecutor.java: -------------------------------------------------------------------------------- 1 | package com.github.beansoft.jvm.executor; 2 | 3 | import com.intellij.execution.executors.DefaultRunExecutor; 4 | import icons.PluginIcons; 5 | import org.jetbrains.annotations.NonNls; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import javax.swing.*; 9 | 10 | public class DebugVisualGCExecutor extends DefaultRunExecutor { 11 | @NonNls 12 | public static final String EXECUTOR_ID = "Debug VisualGC with"; 13 | public static final String DEBUG_WITH_VISUAL_VM = "Debug VisualGC"; 14 | 15 | @NotNull 16 | public String getToolWindowId() { 17 | return getId(); 18 | } 19 | 20 | public Icon getToolWindowIcon() { 21 | return PluginIcons.DebugVisualGC_13; 22 | } 23 | 24 | @NotNull 25 | public Icon getIcon() { 26 | return PluginIcons.DebugVisualGC; 27 | } 28 | 29 | public Icon getDisabledIcon() { 30 | return null; 31 | } 32 | 33 | public String getDescription() { 34 | return EXECUTOR_ID; 35 | } 36 | 37 | @NotNull 38 | public String getActionName() { 39 | return DEBUG_WITH_VISUAL_VM; 40 | } 41 | 42 | @NotNull 43 | public String getId() { 44 | return EXECUTOR_ID; 45 | } 46 | 47 | @NotNull 48 | public String getStartActionText() { 49 | return EXECUTOR_ID; 50 | } 51 | 52 | public String getContextActionId() { 53 | // HACK: ExecutorRegistryImpl expects this to be non-null, but we don't want any context actions for every file 54 | return getId() + " context-action-does-not-exist"; 55 | } 56 | 57 | public String getHelpId() { 58 | return null; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /visualgc_idea/src/com/github/beansoft/jvm/executor/RunVisualGCExecutor.java: -------------------------------------------------------------------------------- 1 | package com.github.beansoft.jvm.executor; 2 | 3 | import javax.swing.*; 4 | 5 | 6 | import icons.PluginIcons; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | import com.intellij.execution.executors.DefaultRunExecutor; 10 | 11 | public class RunVisualGCExecutor extends DefaultRunExecutor { 12 | 13 | public static final String RUN_WITH_VISUAL_VM = "Run VisualGC with"; 14 | public static final String RUN_WITH_VISUAL_VM1 = "Run VisualGC"; 15 | 16 | @NotNull 17 | public String getToolWindowId() { 18 | return getId(); 19 | } 20 | 21 | public Icon getToolWindowIcon() { 22 | return PluginIcons.RunVisualGC_13; 23 | } 24 | 25 | @NotNull 26 | public Icon getIcon() { 27 | return PluginIcons.RunVisualGC; 28 | } 29 | 30 | public Icon getDisabledIcon() { 31 | return null; 32 | } 33 | 34 | public String getDescription() { 35 | return RUN_WITH_VISUAL_VM; 36 | } 37 | 38 | @NotNull 39 | public String getActionName() { 40 | return RUN_WITH_VISUAL_VM1; 41 | } 42 | 43 | @NotNull 44 | public String getId() { 45 | return RUN_WITH_VISUAL_VM; 46 | } 47 | 48 | @NotNull 49 | public String getStartActionText() { 50 | return RUN_WITH_VISUAL_VM; 51 | } 52 | 53 | public String getContextActionId() { 54 | // HACK: ExecutorRegistryImpl expects this to be non-null, but we don't want any context actions for every file 55 | return getId() + " context-action-does-not-exist"; 56 | } 57 | 58 | public String getHelpId() { 59 | return null; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /visualgc_idea/src/com/github/beansoft/jvm/integration/VisualGCConsoleActionsPostProcessor.java: -------------------------------------------------------------------------------- 1 | package com.github.beansoft.jvm.integration; 2 | 3 | import com.github.beansoft.jvm.action.StartVisualGCConsoleAction; 4 | import com.intellij.execution.actions.ConsoleActionsPostProcessor; 5 | import com.intellij.execution.ui.ConsoleView; 6 | import com.intellij.openapi.actionSystem.AnAction; 7 | import com.intellij.openapi.diagnostic.Logger; 8 | import org.jetbrains.annotations.NotNull; 9 | 10 | import java.util.ArrayList; 11 | import java.util.Arrays; 12 | 13 | public class VisualGCConsoleActionsPostProcessor extends ConsoleActionsPostProcessor { 14 | private static final Logger log = Logger.getInstance(VisualGCConsoleActionsPostProcessor.class.getName()); 15 | 16 | @NotNull 17 | @Override 18 | public AnAction[] postProcess(@NotNull ConsoleView console, @NotNull AnAction[] actions) { 19 | VisualGCContext context = VisualGCContext.load(); 20 | ArrayList anActions = new ArrayList(); 21 | anActions.add(new StartVisualGCConsoleAction(context)); 22 | anActions.addAll(Arrays.asList(actions)); 23 | return anActions.toArray(new AnAction[anActions.size()]); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /visualgc_idea/src/com/github/beansoft/jvm/integration/VisualGCContext.java: -------------------------------------------------------------------------------- 1 | package com.github.beansoft.jvm.integration; 2 | 3 | import com.intellij.openapi.diagnostic.Logger; 4 | 5 | /*dirty, but works*/ 6 | public class VisualGCContext { 7 | private static final Logger log = Logger.getInstance(VisualGCContext.class.getName()); 8 | private static volatile VisualGCContext currentlyExecuted; 9 | 10 | /** Process Id */ 11 | protected int processId; 12 | 13 | /** App id used to identify a remote Java program such as Tomcat */ 14 | protected Long appId; 15 | 16 | /** The run item's name */ 17 | protected String name; 18 | 19 | public VisualGCContext(Long appId) { 20 | this.appId = appId; 21 | } 22 | 23 | public String getName() { 24 | return name; 25 | } 26 | 27 | public void setName(String name) { 28 | this.name = name; 29 | } 30 | 31 | public int getProcessId() { 32 | return processId; 33 | } 34 | 35 | public void setProcessId(int processId) { 36 | this.processId = processId; 37 | } 38 | 39 | public Long getAppId() { 40 | return appId; 41 | } 42 | 43 | public void save() { 44 | if (log.isDebugEnabled()) { 45 | log.debug("saving context: " + this.toString()); 46 | } 47 | VisualGCContext.currentlyExecuted = this; 48 | } 49 | 50 | public static VisualGCContext load() { 51 | return currentlyExecuted; 52 | } 53 | 54 | public static boolean isValidProcessId(VisualGCContext visualGCContext) { 55 | return visualGCContext != null && visualGCContext.getProcessId() > 0; 56 | } 57 | 58 | public static boolean isValid(VisualGCContext visualGCContext) { 59 | return visualGCContext != null && visualGCContext.getAppId() != null; 60 | } 61 | 62 | @Override 63 | public String toString() { 64 | final StringBuilder sb = new StringBuilder(); 65 | sb.append("VisualVMContext"); 66 | sb.append("{appId=").append(appId); 67 | sb.append("{processId=").append(processId); 68 | // sb.append(", jdkPath='").append(jdkPath).append('\''); 69 | sb.append('}'); 70 | return sb.toString(); 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /visualgc_idea/src/com/github/beansoft/jvm/integration/VisualGCHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.github.beansoft.jvm.integration; 26 | 27 | import com.intellij.openapi.diagnostic.Logger; 28 | import org.apache.commons.lang.StringUtils; 29 | 30 | import java.io.File; 31 | 32 | public final class VisualGCHelper { 33 | private static final Logger log = Logger.getInstance(VisualGCHelper.class.getName()); 34 | 35 | public static long getNextID() { 36 | return System.nanoTime(); 37 | } 38 | 39 | public static boolean isValidPath(String visualVmPath) { 40 | return !StringUtils.isBlank(visualVmPath) && new File(visualVmPath).exists(); 41 | } 42 | 43 | } -------------------------------------------------------------------------------- /visualgc_idea/src/com/github/beansoft/jvm/runner/AdditionalTabBase.java: -------------------------------------------------------------------------------- 1 | package com.github.beansoft.jvm.runner; 2 | 3 | import com.intellij.diagnostic.logging.AdditionalTabComponent; 4 | import com.intellij.openapi.actionSystem.ActionGroup; 5 | 6 | import javax.swing.*; 7 | 8 | public class AdditionalTabBase extends AdditionalTabComponent { 9 | public void dispose() { 10 | } 11 | 12 | public String getTabTitle() { 13 | return "JProfiler"; 14 | } 15 | 16 | public JComponent getSearchComponent() { 17 | return null; 18 | } 19 | 20 | public String getToolbarPlace() { 21 | return null; 22 | } 23 | 24 | public JComponent getToolbarContextComponent() { 25 | return null; 26 | } 27 | 28 | public boolean isContentBuiltIn() { 29 | return false; 30 | } 31 | 32 | public ActionGroup getToolbarActions() { 33 | return null; 34 | } 35 | 36 | public JComponent getPreferredFocusableComponent() { 37 | return null; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /visualgc_idea/src/com/github/beansoft/jvm/runner/JProfilerTab.java: -------------------------------------------------------------------------------- 1 | package com.github.beansoft.jvm.runner; 2 | 3 | import com.github.beansoft.jvm.runner.AdditionalTabBase; 4 | import kotlin.jvm.internal.Intrinsics; 5 | 6 | import javax.swing.*; 7 | import java.awt.*; 8 | 9 | public final class JProfilerTab extends AdditionalTabBase { 10 | 11 | /* renamed from: a */ 12 | private final Component content; 13 | 14 | public JProfilerTab(Component content) { 15 | this.content = content; 16 | setLayout((LayoutManager) new BorderLayout()); 17 | add((Component) this.content, "Center"); 18 | } 19 | 20 | public String getTabTitle() { 21 | return "VisualGC"; 22 | } 23 | 24 | 25 | // /* renamed from: a */ 26 | // public final FrontendPanel m139a() { 27 | // return this.f501a; 28 | // } 29 | 30 | @Override // com.jprofiler.integrations.idea.runner.RunnerSession.AdditionalTabBase 31 | public void dispose() { 32 | // this.f501a.dispose(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /visualgc_idea/src/com/github/beansoft/jvm/runner/MyAdditionalTabComponentManager.java: -------------------------------------------------------------------------------- 1 | package com.github.beansoft.jvm.runner; 2 | 3 | import com.intellij.diagnostic.logging.AdditionalTabComponent; 4 | import com.intellij.execution.configurations.AdditionalTabComponentManager; 5 | import org.jetbrains.annotations.NotNull; 6 | 7 | import javax.swing.*; 8 | 9 | public class MyAdditionalTabComponentManager extends JPanel implements AdditionalTabComponentManager { 10 | 11 | public MyAdditionalTabComponentManager() { 12 | add(new JButton("test")); 13 | } 14 | 15 | @Override 16 | public void addAdditionalTabComponent(@NotNull AdditionalTabComponent component, @NotNull String id) { 17 | 18 | } 19 | 20 | @Override 21 | public void removeAdditionalTabComponent(@NotNull AdditionalTabComponent component) { 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /visualgc_idea/src/com/github/beansoft/visualgc/idea/MakeCoffeeAction.java: -------------------------------------------------------------------------------- 1 | package com.github.beansoft.visualgc.idea; 2 | 3 | import com.beansoft.lic.CheckLicense; 4 | import com.intellij.CommonBundle; 5 | import com.intellij.openapi.actionSystem.AnAction; 6 | import com.intellij.openapi.actionSystem.AnActionEvent; 7 | import com.intellij.openapi.ui.Messages; 8 | import com.sun.jvmstat.tools.visualgc.resource.Res; 9 | import org.jetbrains.annotations.NotNull; 10 | 11 | import javax.swing.*; 12 | 13 | public class MakeCoffeeAction extends AnAction { 14 | public static final String TITLE = "VisualGC"; 15 | 16 | public MakeCoffeeAction() { 17 | super(); 18 | } 19 | 20 | public void actionPerformed(@NotNull AnActionEvent e) { 21 | final Boolean isLicensed = CheckLicense.isLicensed(); 22 | if (Boolean.TRUE.equals(isLicensed)) { 23 | final String message = Res.getString("registed.thanks.message"); 24 | JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), message, TITLE, JOptionPane.INFORMATION_MESSAGE); 25 | } else { 26 | final String message = "Unfortunately, you have not obtain the license yet. However you can still use this plugin for free with most functions.\n" + 27 | "Would you like to register the plugin to make a donation?"; 28 | // JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), message, TITLE, JOptionPane.INFORMATION_MESSAGE); 29 | boolean sureReg = Messages.showYesNoDialog(e.getProject(), message, TITLE, CommonBundle.getContinueButtonText(), CommonBundle.getCancelButtonText(), 30 | Messages.getQuestionIcon()) == 31 | Messages.YES; 32 | if (sureReg) { 33 | CheckLicense.requestLicense("Please consider register our plugin to make a donation!"); 34 | } else { 35 | Messages.showInfoMessage("Unfortunately, you have not obtain the license yet. \n However you can still use this plugin for free with most functions.", TITLE); 36 | } 37 | } 38 | } 39 | 40 | // Always available and enabled 41 | @Override 42 | public boolean isDumbAware() { 43 | return true; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /visualgc_idea/src/com/github/beansoft/visualgc/idea/VisualGCAction.java: -------------------------------------------------------------------------------- 1 | package com.github.beansoft.visualgc.idea; 2 | 3 | import com.intellij.openapi.actionSystem.AnAction; 4 | import com.intellij.openapi.actionSystem.AnActionEvent; 5 | import com.sun.jvmstat.tools.visualgc.VisualGCPane; 6 | 7 | import javax.swing.*; 8 | import java.awt.*; 9 | 10 | public class VisualGCAction extends AnAction { 11 | 12 | @Override 13 | public void actionPerformed(AnActionEvent e) { 14 | JFrame frame = new JFrame(); 15 | frame.setIconImage(new ImageIcon(VisualGCPane.class.getResource("/visualgc.png")).getImage()); 16 | frame.setTitle("VisualGC 3.0"); 17 | VisualGCPaneIdea gcPane = new VisualGCPaneIdea(); 18 | frame.getContentPane().add(gcPane.createComponent(frame.getContentPane()), BorderLayout.CENTER); 19 | frame.setSize(1024, 768); 20 | frame.setVisible(true); 21 | } 22 | 23 | // Always available and enabled 24 | @Override 25 | public boolean isDumbAware() { 26 | return true; 27 | } 28 | } -------------------------------------------------------------------------------- /visualgc_idea/src/com/github/beansoft/visualgc/idea/VisualGCPaneIdea.java: -------------------------------------------------------------------------------- 1 | package com.github.beansoft.visualgc.idea; 2 | 3 | import com.sun.jvmstat.tools.visualgc.VisualGCPane; 4 | import org.graalvm.visualvm.core.ui.components.DataViewComponent; 5 | 6 | import java.awt.*; 7 | 8 | public class VisualGCPaneIdea extends VisualGCPane { 9 | static { 10 | VisualGCPane.customizeColors(); 11 | } 12 | 13 | /** 14 | * Change visibility to public. 15 | * @param container 16 | * @return 17 | */ 18 | public DataViewComponent createComponent(final Container container) { 19 | return super.createComponent(container); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /visualgc_idea/src/com/github/beansoft/visualgc/idea/VisualGCToolWindowFactory.java: -------------------------------------------------------------------------------- 1 | package com.github.beansoft.visualgc.idea; 2 | 3 | import com.github.beansoft.jvm.action.SettingsAction; 4 | import com.intellij.openapi.Disposable; 5 | import com.intellij.openapi.actionSystem.ActionManager; 6 | import com.intellij.openapi.project.DumbAware; 7 | import com.intellij.openapi.project.Project; 8 | import com.intellij.openapi.wm.ToolWindow; 9 | import com.intellij.openapi.wm.ToolWindowFactory; 10 | import com.intellij.openapi.wm.ex.ToolWindowEx; 11 | import com.intellij.ui.content.Content; 12 | import com.intellij.ui.content.ContentFactory; 13 | import org.jetbrains.annotations.NotNull; 14 | 15 | import javax.swing.*; 16 | import java.awt.*; 17 | 18 | /** 19 | * Open the tool window. 20 | * @author beansoft@126.com 21 | */ 22 | public class VisualGCToolWindowFactory implements ToolWindowFactory, DumbAware { 23 | 24 | // Create the tool window content. 25 | public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) { 26 | ContentFactory contentFactory = ContentFactory.SERVICE.getInstance(); 27 | 28 | VisualGCPaneIdea gcPane = new VisualGCPaneIdea(); 29 | JPanel rootPane = new JPanel(); 30 | rootPane.setLayout(new BorderLayout()); 31 | rootPane.add(gcPane.createComponent(rootPane), BorderLayout.CENTER); 32 | 33 | Content content = contentFactory.createContent(rootPane, "", false); 34 | // content.setIcon(new ImageIcon(VisualGCPane.class.getResource("/visualgc.png"))); 35 | content.setDisposer(new Disposable() { 36 | @Override 37 | public void dispose() { 38 | System.out.println("VisualGC disposed"); 39 | gcPane.dispose(); 40 | } 41 | }); 42 | toolWindow.getContentManager().addContent(content); 43 | 44 | ToolWindowEx ex = (ToolWindowEx) toolWindow; 45 | ActionManager actionManager = ActionManager.getInstance(); 46 | // Actions at toolbar left 47 | ex.setTabActions( 48 | actionManager.getAction("VisualGCNewWindow"), 49 | actionManager.getAction("visualgc.MakeCoffeeAction"), 50 | new SettingsAction()); 51 | } 52 | 53 | // Always could be opened, avoid index waiting 54 | public boolean isApplicable(@NotNull Project project) { 55 | return true; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /visualgc_idea/src/com/sun/jvmstat/graph/GridDrawer.java: -------------------------------------------------------------------------------- 1 | package com.sun.jvmstat.graph; 2 | 3 | import java.awt.*; 4 | 5 | public class GridDrawer { 6 | private static Color defaultColor = new Color(0, 130, 66); 7 | private Color color; 8 | private Color secondaryColor; 9 | private double splitLevel; 10 | private int xIncrement; 11 | private int yIncrement; 12 | 13 | public GridDrawer(int xIncrement, int yIncrement, Color color) { 14 | this.xIncrement = xIncrement; 15 | this.yIncrement = yIncrement; 16 | this.color = color; 17 | } 18 | 19 | public GridDrawer(int xIncrement, int yIncrement) { 20 | this(xIncrement, yIncrement, defaultColor); 21 | } 22 | 23 | public GridDrawer() { 24 | this(10, 10); 25 | } 26 | 27 | public Color getPrimaryColor() { 28 | return this.color; 29 | } 30 | 31 | public void setPrimaryColor(Color color) { 32 | this.color = color; 33 | } 34 | 35 | public Color getSecondaryColor() { 36 | return this.secondaryColor; 37 | } 38 | 39 | public void setSecondaryColor(Color secondaryColor) { 40 | this.secondaryColor = secondaryColor; 41 | } 42 | 43 | public void splitRange(double splitLevel, Color secondaryColor) { 44 | this.secondaryColor = secondaryColor; 45 | this.splitRange(splitLevel); 46 | } 47 | 48 | public void splitRange(double splitLevel) { 49 | this.splitLevel = splitLevel; 50 | } 51 | 52 | protected void draw(Graphics g, int width, int height) { 53 | int splitArea = (int)((double)(width * height) * this.splitLevel); 54 | int splitHeight = splitArea / width; 55 | if (splitHeight > height) { 56 | splitHeight = height; 57 | } 58 | 59 | if (this.splitLevel != 0.0D && splitHeight == 0) { 60 | splitHeight = 1; 61 | } 62 | 63 | int i; 64 | if (splitHeight != 0) { 65 | g.setColor(this.secondaryColor); 66 | 67 | for(i = 0; i < width; i += this.xIncrement) { 68 | g.drawLine(i, 0, i, splitHeight - 1); 69 | } 70 | 71 | g.drawLine(width - 1, 0, width - 1, splitHeight - 1); 72 | 73 | for(i = 0; i <= splitHeight - 1; i += this.yIncrement) { 74 | g.drawLine(0, i, width - 1, i); 75 | } 76 | } 77 | 78 | g.setColor(this.color); 79 | 80 | for(i = 0; i < width; i += this.xIncrement) { 81 | g.drawLine(i, splitHeight, i, height - 1); 82 | } 83 | 84 | g.drawLine(width - 1, splitHeight, width - 1, height - 1); 85 | if (this.splitLevel == 0.0D || splitHeight % this.yIncrement == 0) { 86 | g.drawLine(0, splitHeight, width - 1, splitHeight); 87 | } 88 | 89 | splitHeight = (splitHeight + this.yIncrement) / this.yIncrement * this.yIncrement; 90 | 91 | for(i = splitHeight; i < height; i += this.yIncrement) { 92 | g.drawLine(0, i, width - 1, i); 93 | } 94 | 95 | g.drawLine(0, height - 1, width, height - 1); 96 | } 97 | 98 | } 99 | -------------------------------------------------------------------------------- /visualgc_idea/src/com/sun/jvmstat/graph/Level.java: -------------------------------------------------------------------------------- 1 | package com.sun.jvmstat.graph; 2 | 3 | import com.yworks.util.annotation.Obfuscation; 4 | 5 | import javax.swing.*; 6 | import java.awt.*; 7 | 8 | // 空间和存活直方图空间中的图表 9 | public class Level extends JComponent { 10 | private Color color; 11 | private double level; 12 | @Obfuscation 13 | private GridDrawer gridDrawer; 14 | 15 | public Level(Color color) { 16 | this.color = color; 17 | this.gridDrawer = new GridDrawer(10, 10); 18 | } 19 | 20 | public Level() { 21 | this(Color.WHITE); 22 | } 23 | 24 | public void draw() { 25 | this.repaint(); 26 | } 27 | 28 | public void update(Graphics g) { 29 | this.paint(g); 30 | } 31 | 32 | public void updateLevel(double ratio) { 33 | this.level = ratio; 34 | } 35 | 36 | public void updateGrayLevel(double ratio) { 37 | this.gridDrawer.splitRange(ratio, Color.DARK_GRAY); 38 | } 39 | 40 | 41 | public void drawLevel(Graphics g) { 42 | int height = getHeight(); 43 | int width = getWidth(); 44 | int area = (int)((width * height) * this.level); 45 | int levelHeight = area / width; 46 | if (levelHeight > height) 47 | levelHeight = height; 48 | if (this.level != 0.0D && levelHeight == 0) 49 | levelHeight = 1; 50 | g.setColor(this.color); 51 | g.fill3DRect(0, height - levelHeight, width, height, true); 52 | } 53 | 54 | public Color getColor() { 55 | return this.color; 56 | } 57 | 58 | public void paint(Graphics g) { 59 | this.gridDrawer.draw(g, this.getWidth(), this.getHeight()); 60 | this.drawLevel(g); 61 | super.paint(g); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /visualgc_idea/src/com/sun/jvmstat/monitor/AbstractHolderMonitor.java: -------------------------------------------------------------------------------- 1 | package com.sun.jvmstat.monitor; 2 | 3 | import sun.jvmstat.monitor.Monitor; 4 | import sun.jvmstat.monitor.Units; 5 | import sun.jvmstat.monitor.Variability; 6 | 7 | public class AbstractHolderMonitor implements Monitor { 8 | protected String name; 9 | 10 | public AbstractHolderMonitor(String name) { 11 | this.name = name; 12 | } 13 | 14 | /** 15 | * Returns the name of this instrumentation object. 16 | * 17 | * @return String - the name assigned to this instrumentation monitoring 18 | * object 19 | */ 20 | @Override 21 | public String getName() { 22 | return name; 23 | } 24 | 25 | /** 26 | * Returns the base name of this instrumentation object. 27 | * The base name is the component of the name following the last 28 | * "." character in the name. 29 | * 30 | * @return String - the base name of the name assigned to this 31 | * instrumentation monitoring object. 32 | */ 33 | @Override 34 | public String getBaseName() { 35 | int baseIndex = name.lastIndexOf(".")+1; 36 | return name.substring(baseIndex); 37 | } 38 | 39 | @Override 40 | public Units getUnits() { 41 | return null; 42 | } 43 | 44 | @Override 45 | public Variability getVariability() { 46 | return null; 47 | } 48 | 49 | @Override 50 | public boolean isVector() { 51 | return false; 52 | } 53 | 54 | @Override 55 | public int getVectorLength() { 56 | return 0; 57 | } 58 | 59 | @Override 60 | public boolean isSupported() { 61 | return true; 62 | } 63 | 64 | @Override 65 | public Object getValue() { 66 | return null; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /visualgc_idea/src/com/sun/jvmstat/monitor/HolderLongMonitor.java: -------------------------------------------------------------------------------- 1 | package com.sun.jvmstat.monitor; 2 | 3 | import sun.jvmstat.monitor.LongMonitor; 4 | import sun.jvmstat.monitor.StringMonitor; 5 | 6 | public class HolderLongMonitor extends AbstractHolderMonitor implements LongMonitor { 7 | private long value; 8 | 9 | public HolderLongMonitor(String name, long value) { 10 | super(name); 11 | this.value = value; 12 | } 13 | 14 | /** 15 | * {@inheritDoc} 16 | * The object returned contains a Long object containing the 17 | * current value of the LongInstrument. 18 | * 19 | * @return Object - the current value of the the LongInstrument. The 20 | * return type is guaranteed to be of type Long. 21 | */ 22 | public Object getValue() { 23 | return longValue(); 24 | } 25 | 26 | /** 27 | * Return the current value of the LongInstrument as an long. 28 | * 29 | * @return long - the current value of the LongInstrument 30 | */ 31 | @Override 32 | public long longValue() { 33 | return value; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /visualgc_idea/src/com/sun/jvmstat/monitor/HolderStringMonitor.java: -------------------------------------------------------------------------------- 1 | package com.sun.jvmstat.monitor; 2 | 3 | import sun.jvmstat.monitor.StringMonitor; 4 | 5 | public class HolderStringMonitor extends AbstractHolderMonitor implements StringMonitor { 6 | private String value; 7 | 8 | public HolderStringMonitor(String name, String value) { 9 | super(name); 10 | this.value = value; 11 | } 12 | 13 | @Override 14 | public String stringValue() { 15 | return value; 16 | } 17 | 18 | /** 19 | * {@inheritDoc} 20 | * The object returned contains a String with a copy of the current 21 | * value of the StringInstrument. 22 | * 23 | * @return Object - a copy of the current value of the StringInstrument. 24 | * The return value is guaranteed to be of type String. 25 | */ 26 | public Object getValue() { 27 | return stringValue(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /visualgc_idea/src/com/sun/jvmstat/tools/visualgc/Model.java: -------------------------------------------------------------------------------- 1 | package com.sun.jvmstat.tools.visualgc; 2 | 3 | interface Model { 4 | long getNewGenMinSize(); 5 | 6 | long getNewGenMaxSize(); 7 | 8 | long getNewGenCurSize(); 9 | 10 | long getEdenUsed(); 11 | 12 | long getSurvivor0Used(); 13 | 14 | long getSurvivor1Used(); 15 | 16 | long getTenuredUsed(); 17 | 18 | long getPermUsed(); 19 | 20 | long getEdenSize(); 21 | 22 | long getSurvivor0Size(); 23 | 24 | long getSurvivor1Size(); 25 | 26 | long getTenuredSize(); 27 | 28 | long getPermSize(); 29 | 30 | long getEdenCapacity(); 31 | 32 | long getSurvivor0Capacity(); 33 | 34 | long getSurvivor1Capacity(); 35 | 36 | long getTenuredCapacity(); 37 | 38 | long getPermCapacity(); 39 | 40 | long getEdenGCEvents(); 41 | 42 | long getTenuredGCEvents(); 43 | 44 | long getEdenGCTime(); 45 | 46 | long getTenuredGCTime(); 47 | 48 | long getTenuringThreshold(); 49 | 50 | long getMaxTenuringThreshold(); 51 | 52 | long getDesiredSurvivorSize(); 53 | 54 | long getAgeTableSize(); 55 | 56 | String getLastGCCause(); 57 | 58 | String getCurrentGCCause(); 59 | 60 | long[] getAgeTableSizes(); 61 | 62 | void getAgeTableSizes(long[] var1); 63 | 64 | long getClassLoadTime(); 65 | 66 | long getClassesLoaded(); 67 | 68 | long getClassesUnloaded(); 69 | 70 | long getClassBytesLoaded(); 71 | 72 | long getClassBytesUnloaded(); 73 | 74 | long getTotalCompileTime(); 75 | 76 | long getTotalCompile(); 77 | 78 | void initializeFinalizer(); 79 | 80 | boolean isFinalizerInitialized(); 81 | 82 | long getFinalizerTime(); 83 | 84 | long getFinalizerCount(); 85 | 86 | long getFinalizerQLength(); 87 | 88 | long getFinalizerQMaxLength(); 89 | 90 | long getOsElapsedTime(); 91 | 92 | long getOsFrequency(); 93 | 94 | String getJavaCommand(); 95 | 96 | String getJavaHome(); 97 | 98 | String getVmArgs(); 99 | 100 | String getVmFlags(); 101 | 102 | String getClassPath(); 103 | 104 | String getEndorsedDirs(); 105 | 106 | String getExtDirs(); 107 | 108 | String getLibraryPath(); 109 | 110 | String getBootClassPath(); 111 | 112 | String getBootLibraryPath(); 113 | 114 | String getVmInfo(); 115 | 116 | String getVmName(); 117 | 118 | String getVmVersion(); 119 | 120 | String getVmVendor(); 121 | 122 | String getVmSpecName(); 123 | 124 | String getVmSpecVersion(); 125 | 126 | String getVmSpecVendor(); 127 | 128 | long getLastModificationTime(); 129 | 130 | String getCollector0name(); 131 | String getCollector1name(); 132 | String getCollector2name(); 133 | String getGcPolicyName(); 134 | 135 | long getCollector2GCTime(); 136 | long getCollector2Events(); 137 | 138 | /** 139 | * mark is ZGC 140 | * @since 2022-3-7 141 | */ 142 | boolean isZgc(); 143 | } 144 | -------------------------------------------------------------------------------- /visualgc_idea/src/com/sun/jvmstat/tools/visualgc/ModelFixer.java: -------------------------------------------------------------------------------- 1 | package com.sun.jvmstat.tools.visualgc; 2 | 3 | import github.beansoftapp.visualgc.Exceptions; 4 | import sun.jvmstat.monitor.MonitorException; 5 | import sun.jvmstat.monitor.MonitoredVm; 6 | 7 | import java.lang.reflect.Field; 8 | 9 | public class ModelFixer { 10 | public static boolean fixMetaspace(MonitoredVmModel testModel, MonitoredVm monitoredVm) { 11 | try { 12 | Field PERM_SIZE = MonitoredVmModel.class.getDeclaredField("permSize"); 13 | Field PERM_CAPACITY = MonitoredVmModel.class.getDeclaredField("permCapacity"); 14 | Field PERM_USED = MonitoredVmModel.class.getDeclaredField("permUsed"); 15 | PERM_SIZE.setAccessible(true); 16 | PERM_CAPACITY.setAccessible(true); 17 | PERM_USED.setAccessible(true); 18 | if (PERM_SIZE.get(testModel) == null && PERM_CAPACITY 19 | .get(testModel) == null && PERM_USED 20 | .get(testModel) == null) { 21 | PERM_SIZE.set(testModel, monitoredVm.findByName("sun.gc.metaspace.maxCapacity")); 22 | PERM_CAPACITY.set(testModel, monitoredVm.findByName("sun.gc.metaspace.capacity")); 23 | PERM_USED.set(testModel, monitoredVm.findByName("sun.gc.metaspace.used")); 24 | return true; 25 | // this.hasMetaspace = true; 26 | } 27 | } catch (NoSuchFieldException ex) { 28 | Exceptions.printStackTrace(ex); 29 | } catch (SecurityException ex) { 30 | Exceptions.printStackTrace(ex); 31 | } catch (IllegalArgumentException ex) { 32 | Exceptions.printStackTrace(ex); 33 | } catch (IllegalAccessException ex) { 34 | Exceptions.printStackTrace(ex); 35 | } catch (MonitorException ex) { 36 | Exceptions.printStackTrace((Throwable)ex); 37 | } 38 | 39 | return false; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /visualgc_idea/src/com/sun/jvmstat/tools/visualgc/resource/Res.java: -------------------------------------------------------------------------------- 1 | package com.sun.jvmstat.tools.visualgc.resource; 2 | 3 | import java.text.MessageFormat; 4 | import java.util.PropertyResourceBundle; 5 | import java.util.ResourceBundle; 6 | 7 | /** 8 | * Use for Spark Internationalization. 9 | * 10 | * @author Derek DeMoro 11 | */ 12 | public class Res { 13 | private static PropertyResourceBundle prb; 14 | 15 | private Res() { 16 | 17 | } 18 | 19 | static ClassLoader cl = Res.class.getClassLoader(); 20 | 21 | static { 22 | prb = (PropertyResourceBundle)ResourceBundle.getBundle("visualgc"); 23 | } 24 | 25 | public static String getString(String propertyName) { 26 | try { 27 | return prb.getString(propertyName); 28 | } 29 | catch (Exception e) { 30 | e.printStackTrace(); 31 | return propertyName; 32 | } 33 | 34 | } 35 | 36 | public static String getString(String propertyName, Object... obj) { 37 | String str = prb.getString(propertyName); 38 | if (str == null) { 39 | return propertyName; 40 | } 41 | 42 | 43 | return MessageFormat.format(str, obj); 44 | } 45 | 46 | public static PropertyResourceBundle getBundle() { 47 | return prb; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /visualgc_idea/src/com/yworks/util/annotation/Obfuscation.java: -------------------------------------------------------------------------------- 1 | package com.yworks.util.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Target; 5 | 6 | @Target(value = {ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.ANNOTATION_TYPE}) 7 | public @interface Obfuscation { 8 | 9 | boolean applyToMembers() default true; 10 | boolean exclude() default true; 11 | } -------------------------------------------------------------------------------- /visualgc_idea/src/github/beansoftapp/visualgc/GetProcessID.java: -------------------------------------------------------------------------------- 1 | package github.beansoftapp.visualgc; 2 | 3 | import java.lang.management.ManagementFactory; 4 | import java.lang.management.RuntimeMXBean; 5 | 6 | /** 7 | * http://rednaxelafx.iteye.com/blog/716918 8 | * Note: this class only works at Sun JDK and JRockit. 9 | * see:jrcmd.exe jrockit.tools.jrcmd.JrCmd in tools.jar 10 | * see:jps.exe 11 | * @author beansoft 12 | * 2012-01-31 13 | */ 14 | public class GetProcessID { 15 | 16 | public static int getPid() { 17 | RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean(); 18 | String name = runtime.getName(); // format: "pid@hostname" 19 | // System.out.println("name:" + name); 20 | try { 21 | return Integer.parseInt(name.substring(0, name.indexOf('@'))); 22 | } catch (Exception e) { 23 | return -1; 24 | } 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /visualgc_idea/src/icons/PluginIcons.java: -------------------------------------------------------------------------------- 1 | package icons; 2 | 3 | 4 | import com.intellij.icons.AllIcons; 5 | import com.intellij.openapi.util.IconLoader; 6 | import com.intellij.ui.LayeredIcon; 7 | import com.intellij.ui.ScreenUtil; 8 | import com.intellij.util.IconUtil; 9 | import org.jetbrains.annotations.NotNull; 10 | 11 | import javax.swing.*; 12 | 13 | public class PluginIcons { 14 | public static final Icon visualgcToolWindow = load("/visualgc.svg"); 15 | 16 | 17 | public static Icon RunVisualGC = load("/images/runWithVisualGC.svg"); 18 | public static Icon RunVisualGC_13 = load("/images/runWithVisualGC_13.svg"); 19 | public static Icon DebugVisualGC = load("/images/debugWithVisualGC.svg"); 20 | public static Icon DebugVisualGC_13 = load("/images/debugWithVisualGC_13.svg"); 21 | 22 | public static Icon Donate = load("/images/donate.png"); 23 | 24 | private static Icon load(String path) { 25 | try { 26 | return IconLoader.getIcon(path, PluginIcons.class); 27 | } catch (IllegalStateException e) { 28 | return null; 29 | } 30 | } 31 | 32 | public static @NotNull 33 | Icon scaleIconToSize(Icon icon, int size) { 34 | int width = icon.getIconWidth(); 35 | if (width == size) return icon; 36 | 37 | float scale = size / (float)width; 38 | icon = IconUtil.scale(icon, null, scale); 39 | return icon; 40 | } 41 | 42 | // private static Icon androidLoad(String path) { 43 | // return load(path, AndroidIcons.class); 44 | // } 45 | 46 | // private static Icon load(String path) { 47 | // return load(path, AllIcons.class); 48 | // } 49 | 50 | /** 51 | * see https://github.com/flutter/flutter-intellij/issues/4937 52 | * I've found the reason, the Jetbrains' developer had removed this method overlayIcons(javax.swing.Icon[]) from latest IJ CE code in ElementBase.java, but the LayeredIcon.java stays untouched. 53 | * The git log said: 54 | * platform.core.impl — remove dependency on intellij.platform.util.ui and intellij.platform.core.ui 55 | * java.psi.iml — remove dependency on intellij.platform.core.ui 56 | * @param icons 57 | * @return 58 | */ 59 | @NotNull 60 | public static Icon overlayIcons(@NotNull Icon ... icons) { 61 | final LayeredIcon icon = new LayeredIcon(icons.length); 62 | int i = 0; 63 | for (Icon ic : icons) { 64 | icon.setIcon(ic, i++); 65 | } 66 | return icon; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /visualgc_idea/src/org/graalvm/visualvm/core/datasupport/ClassNameComparator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | package org.graalvm.visualvm.core.datasupport; 27 | 28 | import java.util.Comparator; 29 | 30 | /** 31 | * Comparator based on class names. 32 | * 33 | * @author Jiri Sedlacek 34 | */ 35 | public final class ClassNameComparator implements Comparator { 36 | 37 | /** 38 | * Shared instance of ClassNameComparator. 39 | */ 40 | public static final ClassNameComparator INSTANCE = new ClassNameComparator(); 41 | 42 | public int compare(Object o1, Object o2) { 43 | return o1.getClass().getName().compareTo(o2.getClass().getName()); 44 | } 45 | 46 | private ClassNameComparator() {} 47 | 48 | } 49 | -------------------------------------------------------------------------------- /visualgc_idea/src/sun/jvmstat/perfdata/monitor/protocol/rmi/MonitoredHostRmiService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | package sun.jvmstat.perfdata.monitor.protocol.rmi; 27 | 28 | import sun.jvmstat.monitor.HostIdentifier; 29 | import sun.jvmstat.monitor.MonitorException; 30 | import sun.jvmstat.monitor.MonitoredHost; 31 | import sun.jvmstat.monitor.MonitoredHostService; 32 | 33 | public final class MonitoredHostRmiService implements MonitoredHostService { 34 | 35 | @Override 36 | public MonitoredHost getMonitoredHost(HostIdentifier hostId) throws MonitorException { 37 | return new MonitoredHostProvider(hostId); 38 | } 39 | 40 | @Override 41 | public String getScheme() { 42 | return "rmi"; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /visualgc_idea/src/sun/tools/jstatd/RemoteVmImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | package sun.tools.jstatd; 27 | 28 | import sun.jvmstat.monitor.BufferedMonitoredVm; 29 | import sun.jvmstat.monitor.remote.RemoteVm; 30 | 31 | /** 32 | * Concrete implementation of the RemoteVm interface for the HotSpot PerfData 33 | * shared memory implementation of the jvmstat monitoring APIs. This class 34 | * providing remote access to the instrumentation exported by a local HotSpot 35 | * Java Virtual Machine. The instrumentation buffer is shipped in whole to 36 | * the remote machine, which is responsible for parsing and provide access 37 | * to the contained data. 38 | * 39 | * @author Brian Doherty 40 | * @since 1.5 41 | */ 42 | public class RemoteVmImpl implements RemoteVm { 43 | 44 | private BufferedMonitoredVm mvm; 45 | 46 | RemoteVmImpl(BufferedMonitoredVm mvm) { 47 | this.mvm = mvm; 48 | } 49 | 50 | public byte[] getBytes() { 51 | return mvm.getBytes(); 52 | } 53 | 54 | public int getCapacity() { 55 | return mvm.getCapacity(); 56 | } 57 | 58 | public void detach() { 59 | mvm.detach(); 60 | } 61 | 62 | public int getLocalVmId() { 63 | return mvm.getVmIdentifier().getLocalVmId(); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /visualgc_idea/visualgc_idea.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /visualgc_idea/visualgc_idea.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beansoft/visualgc_java8/aba0de83482f48aa1e861ccaea0c0031f0f1b852/visualgc_idea/visualgc_idea.jar -------------------------------------------------------------------------------- /visualgc_idea/visualgc_remote.md: -------------------------------------------------------------------------------- 1 | 2 | * [Visualizing operations of a remote JVM](#visualizing-operations-of-a-remote-jvm) 3 | 4 | ## Visualizing operations of a remote JVM 5 | VisualGC IDEA now supports remote JVM's GC activity in realtime, however, this function must be used in Development servers only as it has a security risk that any hacker might get and kill your JVM process. 6 | 7 | In the remote machine, create a file called `jstatd.all.policy`, create it using any text editor you like, eg: 8 | ```sh 9 | vim /Users/beansoft/jstatd.all.policy 10 | 11 | grant codebase "file:${java.home}/../lib/tools.jar" { 12 | permission java.security.AllPermission; 13 | }; 14 | 15 | ``` 16 | then start the jstatd tool(which is inside the $JAVA_HOME/bin): 17 | ```sh 18 | jstatd -J-Djava.security.policy=/Users/beansoft/jstatd.all.policy -J-Djava.rmi.server.hostname= 19 | ``` 20 | the IP must be accessed outside that machine, eg value is: `192.168.3.15` 21 | 22 | To check if it is accessed from your local machine which running the VisualGC IDEA plugin, try: 23 | ```sh 24 | jps 192.168.3.15 25 | ``` 26 | then something which contails JVM process list will output like this: 27 | ```sh 28 | 625 29 | 1145 Jstatd 30 | 1509 Bootstrap 31 | 1422 32 | ``` 33 | 34 | Now you can view the gc log using terminal: 35 | ```sh 36 | jstat -gc 1509@192.168.3.15 1000 20 37 | ``` 38 | If everything works fine, and you can see some outputs like this: 39 | ```text 40 | S0C S1C S0U S1U EC EU OC OU MC MU CCSC CCSU YGC YGCT FGC FGCT CGC CGCT GCT 41 | 4352.0 4352.0 0.0 4352.0 34944.0 21631.1 179596.0 114517.7 54940.0 53168.6 6700.0 6017.4 13 0.262 0 0.000 6 0.055 0.318 42 | ``` 43 | , now the VisualGC IDEA plugin is ready to connect the remote JVM machine. 44 | Activate the VisualGC tool window in your IDE, 45 | then click the button `Connect to Remote JVM...`, 46 | input remote hostname (sample input 192.168.3.15 or 192.168.3.15:1099) or input empty value to connect local JVM, 47 | finally click the `OK` button to save the hostname. Now you can see a remote -------------------------------------------------------------------------------- /visualgc_java8.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /visualgc_java8/README.md: -------------------------------------------------------------------------------- 1 | # visualgc_jdk8 2 | Visual Garbage Collection Monitoring Tool - a graphical tool for monitoring the HotSpot Garbage Collector, Compiler, and class loader. It can monitor both local and remote JVMs. 3 | 4 | 原版 VisualGC 3.0 Java 8增强补丁独立运行版, 修复空指针异常, 增强了部分功能, Java 5 到 5 | Java 14 下测试通过. 6 | 7 | 1. Support choose JVM process upon start; 8 | 2. Added support for detailed collectors GC time; 9 | 3. Display detailed values(time:value) on chart mouse hover; 10 | 4. Run under Hotspot JDK 8+, supports monitor Hotspot JDK 1.5 ~ 14, tested for CMS, G1; 11 | 5. Supports Chinese and English language. 12 | 13 | This tool is distributed in the hope that it will be useful, but WITHOUT 14 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | 16 | ------ 17 | 18 | 1. 支持启动时选择 JVM 进程列表; 19 | 2. 支持观测详细的收集器GC暂停时间; 20 | 3. 图表支持鼠标移动详细信息显示(时间和值); 21 | 4. 支持 Hotspot JDK 8+版本下运行, 可检测 Hotspot JDK 1.5 ~ 14, 在 CMS, G1等收集器下检测通过; 22 | 5. 中英双语显示. 23 | 6. 支持浅色模式显示图表和界面 24 | 支持检测IDEA进程显示 25 | 标题栏显示当前进程ID和主类 26 | Mac,Win10测试通过 27 | 28 | 此工具仅希望能有所帮助, 但不提供任何担保. 29 | 30 | ![visualgc_ps_en](screenshot/vgc_cn.png) 31 | 32 | ![visualgc_ps_en](screenshot/visualgc_ps_en.png) 33 | 34 | ![visualgc_en](screenshot/visualgc_en.png) 35 | 36 | ![visualgc_cn](screenshot/visualgc_cn.png) 37 | 38 | -------------------------------------------------------------------------------- /visualgc_java8/bug.txt: -------------------------------------------------------------------------------- 1 | java.lang.NullPointerException 2 | at github.beansoftapp.visualgc.JpsHelper.getVmStringValue(JpsHelper.java:225) 3 | at github.beansoftapp.visualgc.JpsHelper.getCommandLine(JpsHelper.java:197) 4 | at github.beansoftapp.visualgc.JpsHelper.getFirstArgument(JpsHelper.java:247) 5 | at github.beansoftapp.visualgc.JpsHelper.getMainClass(JpsHelper.java:160) 6 | at github.beansoftapp.visualgc.JpsHelper.getJvmPSList(JpsHelper.java:79) 7 | at com.sun.jvmstat.tools.visualgc.VisualGCPane$PsListModel.actionPerformed(VisualGCPane.java:575) 8 | -------------------------------------------------------------------------------- /visualgc_java8/lib/tools.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beansoft/visualgc_java8/aba0de83482f48aa1e861ccaea0c0031f0f1b852/visualgc_java8/lib/tools.jar -------------------------------------------------------------------------------- /visualgc_java8/resources/closePanel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beansoft/visualgc_java8/aba0de83482f48aa1e861ccaea0c0031f0f1b852/visualgc_java8/resources/closePanel.png -------------------------------------------------------------------------------- /visualgc_java8/resources/visualgc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beansoft/visualgc_java8/aba0de83482f48aa1e861ccaea0c0031f0f1b852/visualgc_java8/resources/visualgc.png -------------------------------------------------------------------------------- /visualgc_java8/resources/visualgc.properties: -------------------------------------------------------------------------------- 1 | 0.last.cause.1={0} Last Cause: {1} 2 | class.loader.time.0.loaded.1.unloaded.2=Class Loader Time: {0} loaded, {1} unloaded - {2} 3 | compile.time.0.compiles.1=Compile Time: {0} compiles - {1} 4 | eden.space=Eden Space 5 | finalizer.queue.length.maximum.0.current.1.local.maximum.2=Finalizer Queue Length: Maximum {0} Current {1} Local Maximum {2} 6 | finalizer.time.0.objects.1=Finalizer Time: {0} objects - {1} 7 | gc.time.0.collections.1=GC Time: {0} collections, {1} 8 | graph=Graph 9 | metaspace=Metaspace 10 | not.supported.for.this.jvm=Not supported for this JVM. 11 | old.gen=Old Gen 12 | perm.gen=Perm Gen 13 | survivor.0=Survivor 0 14 | survivor.1=Survivor 1 15 | survivor.age.histogram=Survivor Age Histogram 16 | collections= collections, 17 | old=Old 18 | perm=Perm 19 | eden=Eden 20 | application.information=Application Information 21 | alive=Alive 22 | elapsed.time=Elapsed Time: 23 | java.command.line.0=Java Command Line: {0}\n\n 24 | java.vm.arguments.0=Java VM Arguments: {0}\n\n 25 | java.vm.flags.0=Java VM Flags: {0}\n\n 26 | dead=Dead 27 | s0=S0 28 | s1=S1 29 | refresh.rate=Refresh rate 30 | msec=msec. 31 | auto=Auto 32 | spaces=Spaces 33 | graphs=Graphs 34 | histogram=Histogram 35 | gc.collectors.n.time={0} GC Time:{1}, {2} collections, {3} 36 | tenuring.threshold=Tenuring Threshold: 37 | max.tenuring.threshold=Max Tenuring Threshold: 38 | desired.survivor.size=Desired Survivor Size: 39 | current.survivor.size=Current Survivor Size: 40 | parameters=Parameters 41 | visualgc.3.0.loading.jvm.process.list=VisualGC 3.0, Loading JVM process list... 42 | please.choose.a.process=Please choose a process 43 | a.visual.garbage.collection.monitoring.tool=a Visual Garbage Collection Monitoring Tool 44 | info=Info 45 | this.tool.created.by=Created by github.com/beansoft/visualgc_java8 46 | gc.policy.is.0=GC Policy is {0} 47 | double.click.a.jvm.process.to.start=Double click a JVM process to monitor 48 | jvm.browser=JVM Browser 49 | -------------------------------------------------------------------------------- /visualgc_java8/resources/visualgc_zh_CN.properties: -------------------------------------------------------------------------------- 1 | 0.last.cause.1={0} \u6700\u8fd1\u539f\u56e0: {1} 2 | class.loader.time.0.loaded.1.unloaded.2=\u7c7b\u52a0\u8f7d\u5668\u65f6\u95f4: {0} \u5df2\u52a0\u8f7d, {1} \u5df2\u5378\u8f7d - {2} 3 | compile.time.0.compiles.1=\u7f16\u8bd1\u65f6\u95f4: {0} \u6b21\u7f16\u8bd1 - {1} 4 | eden.space=Eden Space 5 | finalizer.queue.length.maximum.0.current.1.local.maximum.2=Finalizer Queue Length: Maximum {0} Current {1} Local Maximum {2} 6 | finalizer.time.0.objects.1=Finalizer Time: {0} objects - {1} 7 | gc.time.0.collections.1=GC\u65f6\u95f4: {0} \u6b21\u6536\u96c6, {1} 8 | graph=\u56fe\u8868 9 | metaspace=\u5143\u7a7a\u95f4 10 | not.supported.for.this.jvm=\u4e0d\u88ab\u5f53\u524dJava\u865a\u62df\u673a\u914d\u7f6e\u652f\u6301. 11 | old.gen=\u5e74\u8001\u4ee3 12 | perm.gen=\u6301\u4e45\u4ee3 13 | survivor.0=\u5b58\u6d3b\u533a0 14 | survivor.1=\u5b58\u6d3b\u533a1 15 | survivor.age.histogram=\u5b58\u6d3b\u533a\u5e74\u9f84\u76f4\u65b9\u56fe 16 | collections= \u6b21\u6536\u96c6, 17 | old=\u5e74\u8001 18 | perm=\u6301\u4e45 19 | eden=Eden 20 | application.information=\u5e94\u7528\u7a0b\u5e8f\u4fe1\u606f 21 | alive=\u8fd0\u884c 22 | elapsed.time=\u5df2\u8fd0\u884c\u65f6\u95f4: 23 | java.command.line.0=Java\u547d\u4ee4\u884c: {0}\n\n 24 | java.vm.arguments.0=Java VM \u53c2\u6570: {0}\n\n 25 | java.vm.flags.0=Java VM \u6807\u5fd7: {0}\n\n 26 | dead=\u505c\u6b62 27 | s0=S0 28 | s1=S1 29 | refresh.rate=\u5237\u65b0\u901f\u5ea6 30 | msec=\u6beb\u79d2. 31 | auto=\u81ea\u52a8 32 | spaces=\u7a7a\u95f4 33 | graphs=\u56fe\u8868 34 | histogram=\u5b58\u6d3b\u76f4\u65b9\u56fe 35 | gc.collectors.n.time={0} GC \u65f6\u95f4:{1}, {2} \u6b21\u6536\u96c6, {3} 36 | tenuring.threshold=\u5bf9\u8c61\u664b\u5347\u9608\u503c: 37 | max.tenuring.threshold=\u6700\u5927\u5bf9\u8c61\u664b\u5347\u9608\u503c: 38 | desired.survivor.size=\u671f\u671b\u5b58\u6d3b\u533a\u5927\u5c0f: 39 | current.survivor.size=\u5f53\u524d\u5b58\u6d3b\u533a\u5927\u5c0f: 40 | parameters=\u53c2\u6570 41 | visualgc.3.0.loading.jvm.process.list=VisualGC 3.0, \u6b63\u5728\u8bfb\u53d6 JVM \u8fdb\u7a0b\u5217\u8868 ... 42 | please.choose.a.process=\u8bf7\u9009\u62e9\u8fdb\u7a0b 43 | a.visual.garbage.collection.monitoring.tool=\u53ef\u89c6\u5316\u5783\u573e\u56de\u6536\u76d1\u63a7\u5de5\u5177 44 | info=\u63d0\u793a 45 | this.tool.created.by=\u672c\u5de5\u5177\u7531 github.com/beansoft/visualgc_java8 \u63d0\u4f9b 46 | gc.policy.is.0=GC \u7b56\u7565\u662f {0} 47 | double.click.a.jvm.process.to.start=\u53cc\u51fb JVM \u8fdb\u7a0b\u5f00\u59cb\u67e5\u770b 48 | jvm.browser=JVM \u6d4f\u89c8\u5668 49 | -------------------------------------------------------------------------------- /visualgc_java8/screenshot/vgc_cn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beansoft/visualgc_java8/aba0de83482f48aa1e861ccaea0c0031f0f1b852/visualgc_java8/screenshot/vgc_cn.png -------------------------------------------------------------------------------- /visualgc_java8/screenshot/visualgc_cn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beansoft/visualgc_java8/aba0de83482f48aa1e861ccaea0c0031f0f1b852/visualgc_java8/screenshot/visualgc_cn.png -------------------------------------------------------------------------------- /visualgc_java8/screenshot/visualgc_en.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beansoft/visualgc_java8/aba0de83482f48aa1e861ccaea0c0031f0f1b852/visualgc_java8/screenshot/visualgc_en.png -------------------------------------------------------------------------------- /visualgc_java8/screenshot/visualgc_ps_en.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beansoft/visualgc_java8/aba0de83482f48aa1e861ccaea0c0031f0f1b852/visualgc_java8/screenshot/visualgc_ps_en.png -------------------------------------------------------------------------------- /visualgc_java8/src/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Main-Class: com.sun.jvmstat.tools.visualgc.VisualGCPane 3 | 4 | -------------------------------------------------------------------------------- /visualgc_java8/src/beansoft/swing/OptionPane.java: -------------------------------------------------------------------------------- 1 | /* 2 | * @(#)OptionPane.java 1.01 2008-10-5 3 | * 4 | * Copyright 2005-2008 BeanSoft@126.com. All rights reserved. 5 | * PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 6 | */ 7 | package beansoft.swing; 8 | 9 | import javax.swing.*; 10 | import java.awt.*; 11 | 12 | /** 13 | * OptionPane, some useful method from javax.swing.JOptionPane with customized icon. 14 | * @author beansoft 15 | * @version 1.01 2008-10-5 16 | */ 17 | public class OptionPane { 18 | // Enable sounds 19 | static { 20 | UIManager.put("AuditoryCues.playList", 21 | UIManager.get("AuditoryCues.allAuditoryCues")); 22 | } 23 | 24 | /** 25 | * Display a warning message dialog. 26 | * @param parentComponent - 父组件 27 | * @param message - 消息内容 28 | * @param title - 消息标题 29 | */ 30 | public static void showWarningMessageDialog(Component parentComponent, Object message, String title) { 31 | javax.swing.JOptionPane.showMessageDialog(parentComponent, message, title, 32 | JOptionPane.WARNING_MESSAGE); 33 | } 34 | 35 | /** 36 | * Display a error message dialog. 37 | * @param parentComponent - 父组件 38 | * @param message - 消息内容 39 | * @param title - 消息标题 40 | */ 41 | public static void showErrorMessageDialog(Component parentComponent, Object message, String title) { 42 | javax.swing.JOptionPane.showMessageDialog(parentComponent, message, title, 43 | JOptionPane.ERROR_MESSAGE); 44 | } 45 | 46 | /** 47 | * Display a info message dialog. 48 | * @param parentComponent - 父组件 49 | * @param message - 消息内容 50 | * @param title - 消息标题 51 | */ 52 | public static void showInfoMessageDialog(Component parentComponent, Object message, String title) { 53 | javax.swing.JOptionPane.showMessageDialog(parentComponent, message, title, 54 | JOptionPane.INFORMATION_MESSAGE); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /visualgc_java8/src/com/sun/jvmstat/graph/GridDrawer.java: -------------------------------------------------------------------------------- 1 | package com.sun.jvmstat.graph; 2 | 3 | import java.awt.Color; 4 | import java.awt.Graphics; 5 | 6 | public class GridDrawer { 7 | private static Color defaultColor = new Color(0, 130, 66); 8 | private Color color; 9 | private Color secondaryColor; 10 | private double splitLevel; 11 | private int xIncrement; 12 | private int yIncrement; 13 | 14 | public GridDrawer(int xIncrement, int yIncrement, Color color) { 15 | this.xIncrement = xIncrement; 16 | this.yIncrement = yIncrement; 17 | this.color = color; 18 | } 19 | 20 | public GridDrawer(int xIncrement, int yIncrement) { 21 | this(xIncrement, yIncrement, defaultColor); 22 | } 23 | 24 | public GridDrawer() { 25 | this(10, 10); 26 | } 27 | 28 | public Color getPrimaryColor() { 29 | return this.color; 30 | } 31 | 32 | public void setPrimaryColor(Color color) { 33 | this.color = color; 34 | } 35 | 36 | public Color getSecondaryColor() { 37 | return this.secondaryColor; 38 | } 39 | 40 | public void setSecondaryColor(Color secondaryColor) { 41 | this.secondaryColor = secondaryColor; 42 | } 43 | 44 | public void splitRange(double splitLevel, Color secondaryColor) { 45 | this.secondaryColor = secondaryColor; 46 | this.splitRange(splitLevel); 47 | } 48 | 49 | public void splitRange(double splitLevel) { 50 | this.splitLevel = splitLevel; 51 | } 52 | 53 | protected void draw(Graphics g, int width, int height) { 54 | int splitArea = (int)((double)(width * height) * this.splitLevel); 55 | int splitHeight = splitArea / width; 56 | if (splitHeight > height) { 57 | splitHeight = height; 58 | } 59 | 60 | if (this.splitLevel != 0.0D && splitHeight == 0) { 61 | splitHeight = 1; 62 | } 63 | 64 | int i; 65 | if (splitHeight != 0) { 66 | g.setColor(this.secondaryColor); 67 | 68 | for(i = 0; i < width; i += this.xIncrement) { 69 | g.drawLine(i, 0, i, splitHeight - 1); 70 | } 71 | 72 | g.drawLine(width - 1, 0, width - 1, splitHeight - 1); 73 | 74 | for(i = 0; i <= splitHeight - 1; i += this.yIncrement) { 75 | g.drawLine(0, i, width - 1, i); 76 | } 77 | } 78 | 79 | g.setColor(this.color); 80 | 81 | for(i = 0; i < width; i += this.xIncrement) { 82 | g.drawLine(i, splitHeight, i, height - 1); 83 | } 84 | 85 | g.drawLine(width - 1, splitHeight, width - 1, height - 1); 86 | if (this.splitLevel == 0.0D || splitHeight % this.yIncrement == 0) { 87 | g.drawLine(0, splitHeight, width - 1, splitHeight); 88 | } 89 | 90 | splitHeight = (splitHeight + this.yIncrement) / this.yIncrement * this.yIncrement; 91 | 92 | for(i = splitHeight; i < height; i += this.yIncrement) { 93 | g.drawLine(0, i, width - 1, i); 94 | } 95 | 96 | g.drawLine(0, height - 1, width, height - 1); 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /visualgc_java8/src/com/sun/jvmstat/graph/Level.java: -------------------------------------------------------------------------------- 1 | package com.sun.jvmstat.graph; 2 | 3 | import com.yworks.util.annotation.Obfuscation; 4 | 5 | import java.awt.Color; 6 | import java.awt.Graphics; 7 | import javax.swing.JComponent; 8 | 9 | public class Level extends JComponent { 10 | private Color color; 11 | private double level; 12 | @Obfuscation 13 | private GridDrawer gridDrawer; 14 | 15 | public Level(Color color) { 16 | this.color = color; 17 | this.gridDrawer = new GridDrawer(10, 10); 18 | } 19 | 20 | public Level() { 21 | this(Color.WHITE); 22 | } 23 | 24 | public void draw() { 25 | this.repaint(); 26 | } 27 | 28 | public void update(Graphics g) { 29 | this.paint(g); 30 | } 31 | 32 | public void updateLevel(double ratio) { 33 | this.level = ratio; 34 | } 35 | 36 | public void updateGrayLevel(double ratio) { 37 | this.gridDrawer.splitRange(ratio, Color.DARK_GRAY); 38 | } 39 | 40 | 41 | public void drawLevel(Graphics g) { 42 | int height = getHeight(); 43 | int width = getWidth(); 44 | int area = (int)((width * height) * this.level); 45 | int levelHeight = area / width; 46 | if (levelHeight > height) 47 | levelHeight = height; 48 | if (this.level != 0.0D && levelHeight == 0) 49 | levelHeight = 1; 50 | g.setColor(this.color); 51 | g.fill3DRect(0, height - levelHeight, width, height, true); 52 | } 53 | 54 | public Color getColor() { 55 | return this.color; 56 | } 57 | 58 | public void paint(Graphics g) { 59 | this.gridDrawer.draw(g, this.getWidth(), this.getHeight()); 60 | this.drawLevel(g); 61 | super.paint(g); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /visualgc_java8/src/com/sun/jvmstat/tools/visualgc/Model.java: -------------------------------------------------------------------------------- 1 | package com.sun.jvmstat.tools.visualgc; 2 | 3 | interface Model { 4 | long getNewGenMinSize(); 5 | 6 | long getNewGenMaxSize(); 7 | 8 | long getNewGenCurSize(); 9 | 10 | long getEdenUsed(); 11 | 12 | long getSurvivor0Used(); 13 | 14 | long getSurvivor1Used(); 15 | 16 | long getTenuredUsed(); 17 | 18 | long getPermUsed(); 19 | 20 | long getEdenSize(); 21 | 22 | long getSurvivor0Size(); 23 | 24 | long getSurvivor1Size(); 25 | 26 | long getTenuredSize(); 27 | 28 | long getPermSize(); 29 | 30 | long getEdenCapacity(); 31 | 32 | long getSurvivor0Capacity(); 33 | 34 | long getSurvivor1Capacity(); 35 | 36 | long getTenuredCapacity(); 37 | 38 | long getPermCapacity(); 39 | 40 | long getEdenGCEvents(); 41 | 42 | long getTenuredGCEvents(); 43 | 44 | long getEdenGCTime(); 45 | 46 | long getTenuredGCTime(); 47 | 48 | long getTenuringThreshold(); 49 | 50 | long getMaxTenuringThreshold(); 51 | 52 | long getDesiredSurvivorSize(); 53 | 54 | long getAgeTableSize(); 55 | 56 | String getLastGCCause(); 57 | 58 | String getCurrentGCCause(); 59 | 60 | long[] getAgeTableSizes(); 61 | 62 | void getAgeTableSizes(long[] var1); 63 | 64 | long getClassLoadTime(); 65 | 66 | long getClassesLoaded(); 67 | 68 | long getClassesUnloaded(); 69 | 70 | long getClassBytesLoaded(); 71 | 72 | long getClassBytesUnloaded(); 73 | 74 | long getTotalCompileTime(); 75 | 76 | long getTotalCompile(); 77 | 78 | void initializeFinalizer(); 79 | 80 | boolean isFinalizerInitialized(); 81 | 82 | long getFinalizerTime(); 83 | 84 | long getFinalizerCount(); 85 | 86 | long getFinalizerQLength(); 87 | 88 | long getFinalizerQMaxLength(); 89 | 90 | long getOsElapsedTime(); 91 | 92 | long getOsFrequency(); 93 | 94 | String getJavaCommand(); 95 | 96 | String getJavaHome(); 97 | 98 | String getVmArgs(); 99 | 100 | String getVmFlags(); 101 | 102 | String getClassPath(); 103 | 104 | String getEndorsedDirs(); 105 | 106 | String getExtDirs(); 107 | 108 | String getLibraryPath(); 109 | 110 | String getBootClassPath(); 111 | 112 | String getBootLibraryPath(); 113 | 114 | String getVmInfo(); 115 | 116 | String getVmName(); 117 | 118 | String getVmVersion(); 119 | 120 | String getVmVendor(); 121 | 122 | String getVmSpecName(); 123 | 124 | String getVmSpecVersion(); 125 | 126 | String getVmSpecVendor(); 127 | 128 | long getLastModificationTime(); 129 | 130 | String getCollector0name(); 131 | String getCollector1name(); 132 | String getCollector2name(); 133 | String getGcPolicyName(); 134 | 135 | long getCollector2GCTime(); 136 | long getCollector2Events(); 137 | } 138 | -------------------------------------------------------------------------------- /visualgc_java8/src/com/sun/jvmstat/tools/visualgc/ModelFixer.java: -------------------------------------------------------------------------------- 1 | package com.sun.jvmstat.tools.visualgc; 2 | 3 | import github.beansoftapp.visualgc.Exceptions; 4 | import sun.jvmstat.monitor.MonitorException; 5 | import sun.jvmstat.monitor.MonitoredVm; 6 | 7 | import java.lang.reflect.Field; 8 | 9 | public class ModelFixer { 10 | public static boolean fixMetaspace(MonitoredVmModel testModel, MonitoredVm monitoredVm) { 11 | try { 12 | Field PERM_SIZE = MonitoredVmModel.class.getDeclaredField("permSize"); 13 | Field PERM_CAPACITY = MonitoredVmModel.class.getDeclaredField("permCapacity"); 14 | Field PERM_USED = MonitoredVmModel.class.getDeclaredField("permUsed"); 15 | PERM_SIZE.setAccessible(true); 16 | PERM_CAPACITY.setAccessible(true); 17 | PERM_USED.setAccessible(true); 18 | if (PERM_SIZE.get(testModel) == null && PERM_CAPACITY 19 | .get(testModel) == null && PERM_USED 20 | .get(testModel) == null) { 21 | PERM_SIZE.set(testModel, monitoredVm.findByName("sun.gc.metaspace.maxCapacity")); 22 | PERM_CAPACITY.set(testModel, monitoredVm.findByName("sun.gc.metaspace.capacity")); 23 | PERM_USED.set(testModel, monitoredVm.findByName("sun.gc.metaspace.used")); 24 | return true; 25 | // this.hasMetaspace = true; 26 | } 27 | } catch (NoSuchFieldException ex) { 28 | Exceptions.printStackTrace(ex); 29 | } catch (SecurityException ex) { 30 | Exceptions.printStackTrace(ex); 31 | } catch (IllegalArgumentException ex) { 32 | Exceptions.printStackTrace(ex); 33 | } catch (IllegalAccessException ex) { 34 | Exceptions.printStackTrace(ex); 35 | } catch (MonitorException ex) { 36 | Exceptions.printStackTrace((Throwable)ex); 37 | } 38 | 39 | return false; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /visualgc_java8/src/com/sun/jvmstat/tools/visualgc/resource/Res.java: -------------------------------------------------------------------------------- 1 | package com.sun.jvmstat.tools.visualgc.resource; 2 | 3 | import java.text.MessageFormat; 4 | import java.util.PropertyResourceBundle; 5 | import java.util.ResourceBundle; 6 | 7 | /** 8 | * Use for Spark Internationalization. 9 | * 10 | * @author Derek DeMoro 11 | */ 12 | public class Res { 13 | private static PropertyResourceBundle prb; 14 | 15 | private Res() { 16 | 17 | } 18 | 19 | static ClassLoader cl = Res.class.getClassLoader(); 20 | 21 | static { 22 | prb = (PropertyResourceBundle)ResourceBundle.getBundle("visualgc"); 23 | } 24 | 25 | public static String getString(String propertyName) { 26 | try { 27 | return prb.getString(propertyName); 28 | } 29 | catch (Exception e) { 30 | e.printStackTrace(); 31 | return propertyName; 32 | } 33 | 34 | } 35 | 36 | public static String getString(String propertyName, Object... obj) { 37 | String str = prb.getString(propertyName); 38 | if (str == null) { 39 | return propertyName; 40 | } 41 | 42 | 43 | return MessageFormat.format(str, obj); 44 | } 45 | 46 | public static PropertyResourceBundle getBundle() { 47 | return prb; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /visualgc_java8/src/com/yworks/util/annotation/Obfuscation.java: -------------------------------------------------------------------------------- 1 | package com.yworks.util.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Target; 5 | 6 | @Target(value = {ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.ANNOTATION_TYPE}) 7 | public @interface Obfuscation { 8 | 9 | boolean applyToMembers() default true; 10 | boolean exclude() default true; 11 | } -------------------------------------------------------------------------------- /visualgc_java8/src/github/beansoftapp/visualgc/GetProcessID.java: -------------------------------------------------------------------------------- 1 | package github.beansoftapp.visualgc; 2 | 3 | import java.lang.management.ManagementFactory; 4 | import java.lang.management.RuntimeMXBean; 5 | 6 | /** 7 | * http://rednaxelafx.iteye.com/blog/716918 8 | * Note: this class only works at Sun JDK and JRockit. 9 | * see:jrcmd.exe jrockit.tools.jrcmd.JrCmd in tools.jar 10 | * see:jps.exe 11 | * @author beansoft 12 | * 2012-01-31 13 | */ 14 | public class GetProcessID { 15 | 16 | public static int getPid() { 17 | RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean(); 18 | String name = runtime.getName(); // format: "pid@hostname" 19 | // System.out.println("name:" + name); 20 | try { 21 | return Integer.parseInt(name.substring(0, name.indexOf('@'))); 22 | } catch (Exception e) { 23 | return -1; 24 | } 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /visualgc_java8/src/github/beansoftapp/visualgc/IdeaParser.java: -------------------------------------------------------------------------------- 1 | package github.beansoftapp.visualgc; 2 | 3 | import sun.jvmstat.monitor.MonitoredVm; 4 | 5 | import java.util.Scanner; 6 | 7 | public class IdeaParser { 8 | 9 | private static final String MAIN_CLASS = "com.intellij.idea.Main"; // NOI18N 10 | private static final String PLATFORM_ID = "-Didea.paths.selector="; // NOI18N 11 | private static final String PLATFORM_PREFIX = "-Didea.platform.prefix="; // NOI18N 12 | private static final String IDEA_ID = "Idea"; // NOI18N 13 | private static final String IDEA_NAME = "IntelliJ IDEA"; // NOI18N 14 | private static final String PLATFORM_NAME = "IntelliJ Platform"; // NOI18N 15 | 16 | /** 17 | * Detects IntelliJ Plaform application. It returns 18 | * {@link IntellijApplicationType} for IntelliJ Platform application. 19 | * 20 | * @return {@link ApplicationType} subclass or null if 21 | * this application is not IntelliJ Platform application 22 | */ 23 | public String getName(MonitoredVm vm, String mainClass) { 24 | if (MAIN_CLASS.equals(mainClass)) { 25 | return getName(vm); 26 | } 27 | if (mainClass == null || mainClass.length() == 0) { // there is no main class - detect native Windows launcher 28 | String args = JpsHelper.getJvmArgs(vm); 29 | if (args != null && args.contains(PLATFORM_ID)) { 30 | return getName(vm); 31 | } 32 | } 33 | return mainClass; 34 | } 35 | 36 | private String getName(MonitoredVm vm) { 37 | String jvmArgs = JpsHelper.getJvmArgs(vm); 38 | String name = getValue(jvmArgs, PLATFORM_PREFIX); 39 | String selector = getValue(jvmArgs, PLATFORM_ID); 40 | if (selector != null) { // && selector.startsWith(IDEA_ID)) { 41 | return selector; //IDEA_NAME; 42 | } 43 | 44 | 45 | if (name != null) { 46 | return name; 47 | } 48 | 49 | return PLATFORM_NAME; 50 | } 51 | 52 | private String getValue(String args, String key) { 53 | if (args == null) return null; 54 | int index = args.indexOf(key); 55 | 56 | if (index >= 0) { 57 | Scanner sc = new Scanner(args.substring(index+key.length())); 58 | if (sc.hasNext()) { 59 | return sc.next(); 60 | } 61 | } 62 | return null; 63 | } 64 | 65 | 66 | } 67 | -------------------------------------------------------------------------------- /visualgc_java8/src/org/graalvm/visualvm/core/datasupport/ClassNameComparator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | package org.graalvm.visualvm.core.datasupport; 27 | 28 | import java.util.Comparator; 29 | 30 | /** 31 | * Comparator based on class names. 32 | * 33 | * @author Jiri Sedlacek 34 | */ 35 | public final class ClassNameComparator implements Comparator { 36 | 37 | /** 38 | * Shared instance of ClassNameComparator. 39 | */ 40 | public static final ClassNameComparator INSTANCE = new ClassNameComparator(); 41 | 42 | public int compare(Object o1, Object o2) { 43 | return o1.getClass().getName().compareTo(o2.getClass().getName()); 44 | } 45 | 46 | private ClassNameComparator() {} 47 | 48 | } 49 | -------------------------------------------------------------------------------- /visualgc_java8/visualgc.cmd: -------------------------------------------------------------------------------- 1 | cd "%cd%" 2 | set JAVA_HOME=C:\Java\jdk1.8.0_252 3 | "%JAVA_HOME%\bin\java" -cp "%JAVA_HOME%\lib\tools.jar";.\build\visualgc_java8.jar com.sun.jvmstat.tools.visualgc.VisualGCPane 4 | pause -------------------------------------------------------------------------------- /visualgc_java8/visualgc.sh: -------------------------------------------------------------------------------- 1 | cd `dirname "$0"` 2 | #JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_212.jdk/Contents/Home 3 | #/Library/Java/JavaVirtualMachines/jdk-14.0.1.jdk/Contents/Home/bin/java 4 | $JAVA_HOME/bin/java -cp $JAVA_HOME/lib/tools.jar:./build/visualgc_java8.jar com.sun.jvmstat.tools.visualgc.VisualGCPane 5 | -------------------------------------------------------------------------------- /visualgc_java8/visualgc_java8.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | --------------------------------------------------------------------------------