In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article shares with you the content of the sample analysis based on the openjdk compilation of the compiled virtual machine jvm. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Java is only promoted because it is cross-platform and plays a great role because of the virtual machine.
In general, developers can develop on a daily basis without paying attention to the internal implementation of the virtual machine, but sometimes they need to understand the implementation mechanism of the virtual machine when it comes to performance.
Well, what I wrote today is more about compiling a set of my own virtual machine, paving the way for understanding the underlying principles of the virtual machine in the future.
Compiling a virtual machine can run into a lot of holes and take a lot of time. Also because of the differences in our environment, the problems we may encounter are not the same.
All I can say is to make a list of all the problems I have encountered.
1 first of all, we should download the source code of openjdk, this openjdk actually has a version history, you can learn about it.
Then most of the source code content and oracle jdk content are the same, and a few of them are different.
The openjdk source code I downloaded here is openjdk-7u75-src-b13-18_dec_2014.zip. Everyone's version may be different, but the openjdk source code is fine.
2 in addition to the above things to prepare, in fact, but also to prepare an oracle jdk, this jdk I use jdk-6u32-linux-x64.bin.
3 and then prepare all kinds of dependencies on linux. The ways to acquire these dependencies will be discussed later. In addition, I will talk about my linux system here.
It's ubuntu's 16.04LTS 64-bit, so it's best to prepare 64-bit things before.
Everything is ready, now let's do it!
1 if you set the java_home or classpath environment variable before, please comment it out first.
2 decompress openjdk-7u75-src-b13-18_dec_2014.zip to get the openjdk folder, and we put it under / usr.
3 execute jdk-6u32-linux-x64.bin to get the jdk1.6.0_32 folder, which we'll put under / usr/java.
4 enter vim / etc/profile, and add the following at the end:
Replace the installation path of export LANG=C#BootStrap-JDK with the path of your own bootstrap-JDK export ALT_BOOTDIR=/usr/java/jdk1.6.0_32# as above. I used openjdk to compile before, but when I ran hotspot, I replaced it with oracleJDK. The reader can directly replace it with OracleJDKexport ALT_JDK_IMPORT_PATH=/usr/java/jdk1.6.0_32# to specify several threads to execute the content to be compiled by the script export HOTSPOT_BUILD_JOBS=4export ALT_PARALLEL_COMPILE_JOBS=4#. Readers can choose the path where the export BUILD_LANGTOOLS=true#export BUILD_JAXWS=false#export BUILD_JAXP=false#export BUILD_CORBA=falseexport BUILD_HOTSPOT=trueexport BUILD_JDK=trueexport SKIP_COMPARE_IMAGES=trueBUILD_DEPLOY=falseBUILD_INSTALL=false# compilation results are stored according to their needs. It is recommended that you store the build folder export ALT_OUTPUTDIR=/usr/openjdk/buildexport ALLOW_DOWNLOADS=true# in the openjdk source code. These two environment variables need to be removed, otherwise there will be problems unset JAVA_HOMEunset CLASSPATHmake 2 > & 1 | tee $ALT_OUTPUTDIR/build.log
Note that source / etc/profile is required to update the configuration. But it will run as soon as it is typed, but it will not succeed now because it is not ready to rely on those. Press ctrl+c immediately to pause.
5 execute some commands on the terminal to install the necessary dependencies, as follows:
Sudo apt-get install build-essential gawk m4 libasound2-dev libcups2-dev libxrender-dev xorg-dev xutils-dev x11proto-print-dev binutils libmotif-common ant
Some places also install openjdk-6-jdk, in fact, it is better not to install this here, we use oracle's jdk to compile our openjdk source code, it is not recommended to use openjdk-6-jdk to compile openjdk source code, which is why the jdk address pointed to in my build.sh script is export ALT_BOOTDIR=/usr/java/jdk1.6.0_32.
Now let's go to the / usr/openjdk directory and execute the make sanity command to check that the configuration is all right. If there are no questions, it will be displayed.
7 everything is ready, except Dongfeng, type make, start compiling, and the compiled things will be generated in the / usr/openjdk/build directory.
This is the process, but there will be some problems during this period. According to the mistakes he reported, we have to correct some errors, and then continue the make command to compile.
Here are some of the mistakes and solutions I encountered.
1 >
Echo "* * This OS is not supported:" `uname-a`; exit 1
Openjdk/hotspot/make/linux/Makefile:240: recipe for target 'check_os_version' failed
Resolve:
Comment out the next three lines of check_os_version in / openjdk/hotspot/make/linux/Makefile
Check_os_version:
# ifeq ($(DISABLE_HOTSPOT_OS_VERSION_CHECK) $(EMPTY_IF_NOT_SUPPORTED),)
# $(QUIETLY) > & 2 echo "* This OS is not supported:" `uname-a`; exit 1
# endif
2 >
Undefined reference to `void G1SATBCardTableModRefBS::write_ref_array_pre_work (oopDesc**, int)'
Solution: change the g1SATBCardTableModRefBS.cpp in hotspot/src/share/vm/gc_implementation/g1
Template void G1SATBCardTableModRefBS::write_ref_array_pre_work (T* dst, int count) {if (! JavaThread::satb_mark_queue_set (). Is_active ()) return; T* elem_ptr = dst; for (int I = 0; I
< count; i++, elem_ptr++) { T heap_oop = oopDesc::load_heap_oop(elem_ptr); if (!oopDesc::is_null(heap_oop)) { enqueue(oopDesc::decode_heap_oop_not_null(heap_oop)); } } }内容下加上如下 //2017-10-19 Vicent_Chen added void G1SATBCardTableModRefBS::write_ref_array_pre(oop* dst, int count, bool dest_uninitialized) { if (!dest_uninitialized) { write_ref_array_pre_work(dst, count); } } void G1SATBCardTableModRefBS::write_ref_array_pre(narrowOop* dst, int count, bool dest_uninitialized) { if (!dest_uninitialized) { write_ref_array_pre_work(dst, count); } } //2017-10-19 Vicent_Chen added 将hotspot/src/share/vm/gc_implementation/g1里的g1SATBCardTableModRefBS.hpp如下部分 virtual void write_ref_array_pre(oop* dst, int count, bool dest_uninitialized) { if (!dest_uninitialized) { write_ref_array_pre_work(dst, count); } } virtual void write_ref_array_pre(narrowOop* dst, int count, bool dest_uninitialized) { if (!dest_uninitialized) { write_ref_array_pre_work(dst, count); } } 注释掉,然后在加入virtual void write_ref_array_pre(oop* dst, int count, bool dest_uninitialized); virtual void write_ref_array_pre(narrowOop* dst, int count, bool dest_unintialized); 3>Error: time is more than 10 years from present: 1136059200000
Resolve:
The following time in the openjdk/jdk/src/share/classes/java/util/CurrencyData.properties file is changed to less than 10 years
AZ=AZM;2005-12-31-20-00-00 X AZN
MZ=MZM;2006-06-30-22-00-00
RO=ROL;2005-06-30-21-00-00 X Ron
TR=TRL;2004-12-31-22-00-00 X try
VE=VEB;2008-01-01-04-00-00
4 > later, when compiling RMIServerImpl_Stub.class, I probably ran out of memory, because I observed through the system monitor that there was a surge during this period of time, and I don't know the exact reason, but I did it several times in a row when the make command came back to the last time.
It worked again. So when you encounter this kind of situation, you can do it all over again. The last time there was no surge in memory.
If the compilation is successful, it looks like this:
Then you can find your compiled jdk in the build folder.
Thank you for reading! This is the end of this article on "sample analysis of openjdk compilation based on compiling virtual machine jvm". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!
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.