In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
How to use the code to judge whether the current system supports a certain version of feature, I believe that many inexperienced people do not know what to do about it. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
JDK9 has been out for some time, so many popular Java applications have added support for JDK9 and even JDK10, such as Tomcat.
We download the latest Tomcat source package from this link, with a total of 7MB:
Https://tomcat.apache.org/download-90.cgi
After unzipping, find the file JreMemoryLeakPreventionListener.java in the folder apache-tomcat-9.0.10-srcjavaorgapachecatalinacore:
You can see a large number of calls to the utility class JreCompat to see if JRE9 is available:
JreCompat.isJre9Available ()
View the specific implementation of isJre9Available:
Public static boolean isJre9Available () {return jre9Available;}
Controlled by a boolean: jre9Available.
The boolean of jre9Available is controlled by Jre9Compat.isSupported (): static {/ / This is Tomcat 9 with a minimum Java version of Java 8. / / Look for the highest supported JVM first if (Jre9Compat.isSupported ()) {instance = new Jre9Compat (); jre9Available = true;} else {instance = new JreCompat (); jre9Available = false;}}
Then look at the code of Jre9Compat.isSupported ():
Static boolean isSupported () {return inaccessibleObjectExceptionClazz! = null;}
Once inaccessibleObjectExceptionClazz is not null, JRE9 is available.
InaccessibleObjectExceptionClazz is from Class.forName ("java.lang.reflect.InaccessibleObjectException")
The class java.lang.reflect.InaccessibleObjectException was just introduced by Java 9. So if you can't load this class with Class loader, it must indicate that the current running environment is below Java 9.
The detection of the Java runtime environment in this way is more accurate than System.getProperty, because the information obtained by the latter may theoretically be overwritten by others with setProperty.
ABAP
View the version information of Software component through the table CVERS:
After reading the above, do you know how to use code to determine whether the current system supports a certain version of feature? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
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.