INSIDE JAVA2 SDK SOURCE INTERNAL in-depth Java2 SDK Original Code (1) Java2 SDK Original Code Overview

zhaozj2021-02-17  41

INSIDE JAVA2 SDK SOURCE INTERNAL in-depth Java2 SDK Original Code (1) Java2 SDK Original Code Overview

Wang Sen Taiwan Jiaotong University Science and Technology Management Institute moli.mt88g@nctu.edu.tw█ preface

So far, only the original code of the Java2 SDK 1.3 Win32 version is released on the SUN Microsystems website, while the original code of the Java2 SDK Solaris / Linux version is only 1.2.2. Therefore, the content of this article applies only to Win32 version of Java2 SDK 1.3. All operations are tested on the Windows 2000 Professional operating system. If you verify this content on a different platform, or use the original Solaris version released in the future, the original code of the Linux version. We cannot guarantee that there will be the same results.

█ introduction

It is said that the evolution of the information society has a lifecycle. From the early men's desk, only one terminal is slowly improved to the PC era, and then we find that the trend will go back to NC (Network Computer), and manufacturers advocate Thin Client. The era. The same is true for the original code, from early vendors to the machine's original code for customers, then gradually program code to become unique and unwilling to open assets, and finally evolve into everyone The era of Open Source, Free Software. No matter whether the Poemns is really interested in TRACE is attached to the original code in your computer, but I think this is the most valuable place to open the original law - everyone has the opportunity to be able to control the internal behavior of the system, the information on the computer Safety and the mode of operation of the program will never control in the hands of a particular manufacturer. With the original code, we don't have to suspect whether a vendor's operating system or application will sneak over the back of your information. Go to their company's servers. With the trend of this open original code, the original code of Java2 SDK has actually released for a long time, but the license used for Sun Community Source Code License (SCSL), which will generally discuss the Open Source The General Public License (GPL) is different. I believe that recently everyone will find that in the related article, it has also begun to mention the topics released by the Java SDK to the General Public License. In October SuN, SUNs were released by General Public License, and everyone expected that Sun was released by the original code of Java SDK in General Public License. If this is true, then Java is in the future. The development will not be what we can predict. If successful, Java will fly like Linux, if there is no success, it will like a small rain point like Mozilla. One of the aunts and no matter which license is more than Open, which compare free, the author has written only one, which is to excavate the operation mechanism existing in Java2 SDK. Since the author's educational work has been taken for a while, the more students teach, the more you deeply understand your understanding of Java, and we often use the executive file (EXE, such as Javaac.exe, Java.exe, etc.) Several important dynamic connecting group libraries (DLL, such as JVM.DLL, Java.dll, etc.), and other kits written in Java programming (Package, such as Java.io, Java.util, etc.), these I want to understand the topics I want to understand, so I have the birth of this series. Of course, the procedure of TRACE is a bit like a procedure black hand, but the author thinks that Taiwan's software industry should still take a long time. From a big point of view, system analysis, system design, system testing, how to properly allocate limited human resources, at least we have no way to do it very well, from these works, from Java2 SDK's original code structure In the middle, we can see the development of the team organization architecture used in the development of SDK (Software Development Kit). How is the location of the original code? How do the programs written out? How to integrate together? How to make the file automation? I think we must get some answers from the original code of Java2 SDK.

From a small point of view, how to make good use of Design Pattern? How to write an efficient program code? How to make the program code written by the program designer? We all know that the King's inner kits in Java use Design Pattern, we also Know that Java is very efficient because of the relationship between the virtual machine, the program code must be very efficient, and I believe that these issues can also get answers from the original code of Java2 SDK. Vigorously promoting the development of Open Source is also very clear. Open raw code will be a new national shortcut to developed the country's software industry. Looking forward to personal efforts can be an indispensable short screw in this big revolution. In the first one of this series, the author will introduce the Overview of the original code of Java2 SDK, first allow the reader to get the original code of Java2 SDK and can successfully compile these raw codes. Not much nonsense, let us start! ■ How to get Java2 SDK original code

To get the original code of the Java2 SDK, you must first go to the Java Developer Connection (JDC), so please come to http://developer.java.sun.com/developer/ website to register, get the user ID and password. As shown below:

When you successfully become a member of Java Developer Connection (JDC), please go to http://www.sun.com/software/communitysource/java2/, you will see the option to download the original code of Java2 SDK, click After entering, enter the user ID and password of the Java Developer Connection (JDC). After confirming that you accept license, you can start downloading the original code of Java2 SDK. As shown below:

█JAVA2 SDK Original Code Architecture

When you unlock the compressive file of the Java2 SDK original code, you will see the directory structure shown below:

All Makefile files are placed in the build directory, which is the format that can be interpreted by Nmake.exe attached to Visual Studio. Usually the name of Makefile is five, named Makefile, *. Nmk, *. Jmk (specified .java file), *. Cmk (specify .c file to be compiled), *. Mk. You can find some .java files under build / share. Since we want to compile the Java SDK under the Windows operating system, the Makefile's main unit is build / win32 / makefile, the entire Java2 SDK compile process is rooted in this file, under the build / win32 / makefiles directory, you can Find a shared makefile, usually attached to .nmk. The makefile under the build / win32 directory is a program for building and Windows operating systems. In the BUILD / share directory, it is more .mk, .jmk, .cmk file, these files are usually used to build and Windows operating systems unrelated programs. Ext Directory This directory is placed with Makefile and original code that supports Java2 SDK library, which use the Java program language. In the EXT / I18N directory, there is a library related to Internationalization, which is finally placed in i18n.jar. The EXT / JPDA directory places the files related to Java Platform Debugger Architecture. SRC Directory This directory places all .C files (written in C programming language) and .java files (written in Java program language). The SRC / Win32 directory is used to build the original code related to the Windows operating system. And under the src / share directory, it is mostly the original code independent of the Windows operating system. Therefore, smart readers should be guessed that most Java standard suite is mostly placed under the src / share directory. The original code of these standard kits is finally added to Src.jar, while compiled .CLASS files are dispersed in many different JAR files. LegalReadme.html Sun Community Source Code License Copyright Anoriginalcode.txt java2 SDK list of all files in the original code. Readme.html About the original code of Java2 SDK, most of which have been integrated into this article by the author. From the architecture of Java2 SDK original code, we can find that its file is very unique, which is made of Makefile and the original code. It is different from usually what we have seen (such as Linux Kernel original code) Makefile and the original code Practice together. These two practices have their own advantages. With Linux Kernel original code, after each compilation is completed, you will see that the original code file and the intermediate file generated during the compilation process is a bit confusing. If we use the Java2 SDK original code, each compiled intermediate gear and the original code will be separated in different directories, it looks very pleasing, but the price of this is Makefile's reference to the path. It is very complicated, you will find a lot of Makefile in the original code of Java2 SDK, it seems uncomfortable, if we need to understand which files are made by this executive file It's hard. ■ How to compile Java2 SDK Original Code

When we understand the original code of the Java2 SDK, many engineers must try their own original code, then compile, I think this is a biggest pleasure as an engineer. Of course, we must also try to compile the entire original code before we have not modified, and the original code is complete, so the next preparation step and method for compiling Java 2 original code. To successfully compile the Java2 SDK original code, you must meet a few conditions: Operating system You must compile Java 2 original code smoothly on Windows NT 4.0 or Windows 2000. Once the compilation is completed, the generated execution file or the dynamic link, and the library will be able to execute on all Win32 job platforms. Among the documents included in the original code of Java2 SDK, the recommended hard device is a Pentium level processor with at least 128 MB of memory. On the author's computer, Pentium III 450 is equipped with PC 100 128 MB of memory, which has spent nearly 2.5 hours to complete all compilation actions. If you count some errors encountered during compile time, it takes more than 3 hours. Developing tools we must prepare a few tools, they are:

Microsoft Visual C Version 6.0 and matches the latest service pack (or Visual Studio 97 with Service Pack 3). In the original code of Java2 SDK, there are many program code related to the Windows platform. These program code is written in C language. In order to compile these native program code, we must have a Visual C compiler to produce The execution file (.exe) and dynamic links and library (.dll) are performed on the Windows platform. At the same time, there are many makefiles in the original code of Java2 SDK, which are used to control the compilation action of all programs. We must use the Nmake.exe attached to Visual C to help us interpret these Makefile and compile the entire Java2 SDK. MKS Toolkit Version 5.2 above. MKS Toolkit is a tool that can simulate the Unix execution environment on Windows, please go to http://www.mks.com to download the 30-day trial version of this set (official version must be paid). Or if you have a subscription MDSN Professional or more, you can find Microsoft Windows Services for UNIX 2.0 Add-on Pack in the CD (under the UNIX20_INSERV / 3RDPARTY / MKS directory, execute setup.exe in the x86 subdirectory) . The 30-day trial version of the function knight and the paid version of the function, just when you compile the Java2 SDK original code, as long as you use the tool in MKS Toolkit, there will be an advertisement screen, you should not affect your Mood is just. The executable version of Java2 SDK 1.3. I believe that the readers will see this place, they will feel very confused. Weird, the original code of the Java2 SDK also needs Java2 SDK assistance? Can't help but think of the problem of chicken egg egg eggs, isn't it? In fact, Java2 SDK plays Bootstrap Compiler in the entire compilation process. The role of the compiler). The reason for the Java2 SDK is because the Javaac.exe core program used when compiling the Java program is also written in Java. Since the original code of Java2 SDK has many ways to be related to the platform, write in Java programming language The program, so in the initial stage of compilation, we must use the old version of Java2 SDK or JDK to help us generate a new version of Java2 SDK, and then use the newly generated new version of JavaC.exe to compile other .java files within the original code of Java2 SDK. When everyone will prepare all the necessary conditions, we will begin to prepare the relevant work before compiling. The content under the bottom will have the following assumptions:

tool

installation path

Windows NT / 2000 system location

C: / Winnt

Microsoft Visual C Version 6.0

D: / Microsoft Visual Studio

Microsoft Visual Studio 97

D: / Program Files / DevStudio

MKS Toolkit

C: / MSKDEMO / MKSNT

Officer of Java2 SDK 1.3

D: /jdk1.3

Java2 SDK original code

D: /jdk1.3-src

Next, we have to set the environment variable. For the sake of convenience, please add a batch file called Env.bat, so you don't have to make a lot of time when you want to modify the environment variable: If you use the C compiler for Microsoft Visual C Version 6.0, the contents of ENV.BAT are as follows: env.bat

set MSVCDir = d: / Microsoft Visual Studio / vc98set MSDevDir = d: / Microsoft Visual Studio / Common / MSDev98set WinDir = c: / winntset include =% MSVCDir% / include;% MSVCDir% / mfc / include;% MSVCDir% / atl / includeSet lib =% msvcdir% / lib;% msvcdir% / mfc / libset path = c: / mskdemo / mksnt;% msvcdir% / bin;% MSDEVDIR% / bin;% windowsdir% / system32;% PATH% SET ALT_BOOTDIR = D: /JDK1.3SET TMPDIR = D: /JDK1.3-SRC/TMP If you use the C compiler for Microsoft Visual Studio 97, the content of ENV.BAT is as follows: env.bat

set MSVCDir = d: / Program Files / DevStudio / VCset MSDevDir = d: / Program Files / DevStudio / SharedIDEset WinDir = c: / winntset include =% MSVCDir% / include;% MSVCDir% / mfc / include;% MSVCDir% / atl / includeSet lib =% msvcdir% / lib;% msvcdir% / mfc / libset path = c: / mskdemo / mksnt;% msvcdir% / bin;% MSDEVDIR% / bin;% windowsdir% / system32;% PATH% SET ALT_BOOTDIR = D: /jdk1.3set tmpdir = d: /jdk1.3-src/tmp

Any environmental variable setting is incorrect, will cause compilation errors, please be careful. There are a few things about environment variables, please readers must pay attention to:

For PATH environment variables, MKS Toolkit's path must appear before the path of Microsoft Visual C Version 6.0 (or Microsoft Visual Studio 97), otherwise it will cause compilation errors. So please do not set the PATH =% MSVCDIR% / bin;% msdevdir% / bin; c: / mskdemo / mksnt;% windowsdir% / system32;% PATH% (MKS Toolkit appears in Microsoft Visual C Version 6.0 (Or the path to Microsoft Visual Studio 97)) Please turn off the ClassPath environment variable. If you are under Windows 2000, press the right mouse button on the "My Computer" icon, select "Content", click the "Advance" page, then press the Environment Variable button. The environment variable dialog will appear, as shown below:

Please look for the user variable or any environment variable named ClassPath in the system variable. Otherwise, an error message will appear in the initial period of compiling the Java2 SDK. Environment variables Alt_Bootdir is where the Bootstrap Compiler is located, and you can set it to the Java SDK installation location.

When the above preparation works, turn on the "Command Tips" window (that is, the DOS window!) And switch the directory to D: /JDK1.3-SRC/BUILD/WIN32, enter NMAKE World in the list At this time, the process of compiling the Java2 SDK original code is officially launched, there is no doubt that this will be a long process. In the process of compilation, some compile errors appeared on the author's computer. By the way, it will be referred to, by the way, the author's solution is written: Can't find .properties file: often appear during compiling Java2 SDK Can't find the error message of the.properties file, if you find the reason for the end of the compilation, because you can't find a .properties file under a specific directory, please ask the reader to search for the JDK1.3-src / src directory, must Find the .properties file that the compiler is not found, please copy this .properties file to the compiler to expect this file to resolve the directory where the file is located. Can't find the .class file: In the initial period of compiling the Java2 SDK original code, the error message cannot be found. The author discovers these categories that can be placed in JDK1.3-SRC / EXT / I18N. / SRC / Share / Sun / IO / bottom, the reason why it can't find these. The Class file is because the original code in the JDK1.3-SRC / EXT directory is compiled later, and we The ClassPath environment variable is turned off, resulting in these files, which have not been compiled into a .class file from .java file, naturally the compiler cannot be compiled. To solve this problem, readers should first go to JDK1.3-SRC / EXT / I18N / SRC / Share / Sun / IO / bottom, enter Javac * .java to generate all the required .class files, then put these newly generated The .CLASS file is copied to the JDK1.3-SRC / Build / Win32 / Classes / Sun / IO this directory under this directory. In this way, I will never encounter an error message that I can't find the .class file. In the internal attachment file of Java2 SDK, we want to set the environment variable TMP, but the actual test result is found that there is no use in this path, but it is not used by the environment variable TEMP when compiling. Directory (under Windows 2000, this environment variable is set to% userprofile% / local settings / temp), do not know whether the person written in the documentation is accidentally leaking.

When the compilation work comes, you will be able to find all compiled execution files and .class files in the JDK1.3-SRC / Build / Win32 directory, there are some intermediates generated during the compilation process. Under the JDK1.3-SRC / Build / Win32 / bin directory, you will see all executables that make Java2 SDK work and dynamic links. Also, we use the Make World directive. If you observe this directory, you will find that each file has an optimization version and the defect version (EX: Java.exe with Java_G.exe, and other push). The JDK1.3-SRC / Build / Win32 / Lib directory will place a kit library that allows Java programs to perform smoothly, such as I18n.jar, etc., in the JDK1.3-SRC / Build / Win32 / LIB / EXT directory There are also some resource files that can be found in the expansion suite such as IIIMP. Jar. The JDK1.3-SRC / Build / Win32 / CLASSES directory is placed in all .class files (Category). In addition, in addition to entering the NMAKE WORLD directive, other non-World compilation options are defined, see the following table: Compile instructions

effect

NMAKE ALL

Establish a Java SDK core program to remove the wrong version and optimal version

NMAKE EXT

Establish a Java SDK expansion program to remove the wrong version and optimal version

NMAKE WORLD

(With NMAKE World-ALL)

Establish all procedures in all and ext

NMAKE RELESEDOCS

Perform javadoc.exe to generate Java SDK documentation

NMAKE Alldocs

Perform Javadoc.exe to generate all instructions for the program under the Sun. * Suite.

NMAKE World-Clobber

Delete all files and directories generated after the previous compilation

If you want to know all the options, you will open the JDK1.3-SRC / Build / Win32 / makefile or JDK1.3-SRC / Build / Win32 / makefiles / defs.nmk. . ■ Next

About the Overview of the original code of Java2 SDK is here, I believe everyone has a solid foundation. If you are already a very experienced engineer, I believe that you have been able to modify your own version of Java2 SDK! In the article, the author will continue to bring you in-depth actual program code, let everyone know how the Java programs you have written into Byte Code, then turn it into .class file; the author will take you to understand the .class file is How to load, what handling program has been handled, and finally how to be executed by the Java virtual machine. I believe that these are all very interesting issues, let's see! ■ Network resources

◎ website

name

URL

Java Developer Connection

http://developer.java.sun.com/developer/

Java2 original code download

http://www.sun.com/software/communitysource/java2/

转载请注明原文地址:https://www.9cbs.com/read-30327.html

New Post(0)