In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "how to view the three axes of Java Class source code in operation". The content of the explanation in the article is simple and clear, and it is easy to learn and understand. below, please follow Xiaobian's train of thought to slowly deepen, to study and learn "how to view the three axes of Java Class source code in operation"!
When I ran an application online, it always felt that the running result was not what you expected, and the code seemed to be inconsistent with your local one. What can I do, grit my teeth and stamp my foot to stop the machine and go online again?
That's troublesome enough. Let's learn about several ways to view the Class source code of Java applications without downtime.
Like Cheng Yaojin's kung fu, for Class source code view, we also have three axes.
In general, we need to check the Class source code of a running program, which will go through three steps:
First, locate and find the Class
Download the remote class file to the local
Decompilation to view the source code
The process should be very clear. Let's focus on the first and second steps, how to find this class and download it locally.
For Class, if we develop our own code, rather than compile-time or run-time enhancement and generation, then directly on the remote server to search and download to the local OK.
Like those compile-time and runtime-enhanced Class, or even dynamically generated Class, such as dynamic proxies such as OpenJPA and Spring/Cglib, the above approach is powerless.
In this case, you can directly use JDK's artifact SA tool (Java virtual machine microscope Serviceability Agent), search directly in Class browser, and then select create .class file file to save to the directory where SA Jar is located by default. The downside, however, is that the SA connection suspends the application until it is disconnected.
Another way is to use various enhanced class libraries, all of which provide configuration for saving generated classes by default, and if this option is turned on, the generated, enhanced class will be written locally. For example, like Cglib, you can set it in System.property.
System.setProperty (DebuggingClassWriter.DEBUG_LOCATION_PROPERTY, ".
The Cglib runtime determines the configuration, and when opened, the class binaries of the generated classes are written locally.
If the class library is not available or you can't find this option, and you really want to view it, you can Attach a Java Agent to JVM. Hang the Jar-free package with Instrument or ByteBuddy and refer to the previous article (Agent without Jar package? A few lines of code to implement runtime enhancements)
With Agent's transformer, it's up to you to show off.
Thank you for your reading, the above is the content of "how to view the three axes of Java Class source code in operation". After the study of this article, I believe you have a deeper understanding of how to view the three axes of Java Class source code in operation, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.