操屁眼的视频在线免费看,日本在线综合一区二区,久久在线观看免费视频,欧美日韩精品久久综

新聞資訊

    openJdk1.8中的makefile,記錄下java的執(zhí)行文件編譯過程及jvm編譯過程。

    目錄說明

    openjdk源碼中有很多目錄,根據(jù)功能做了模塊化劃分,每個(gè)目錄實(shí)現(xiàn)其相應(yīng)的功能。每個(gè)目錄下的結(jié)構(gòu)都差不多,分為src(源碼)、make(makefile)、test(或沒有)、其他特殊目錄。

    openjdk
    
    common 一些公共文件,比如下載源碼的shell腳本、生成make的autoconf等文件
    
    corba 分布式通訊接口
    
    hotspot 虛擬機(jī)實(shí)現(xiàn)
    
    jaxp xml處理代碼
    
    jaxws ws實(shí)現(xiàn)
    
    apijdk jdk源碼
    
    langtools java語言工具實(shí)現(xiàn),比如javac、javap等
    
    make make文件
    
    nashorn java中js的運(yùn)行時(shí)實(shí)現(xiàn)
    
    test 測(cè)試文件


    • Jdk目錄
    src 源碼目錄
    bsd bsd實(shí)現(xiàn)
    linux linux實(shí)現(xiàn)
    macosx macos實(shí)現(xiàn)
    share 公用代碼,linux平臺(tái)代碼會(huì)在這里
    solaris solaris實(shí)現(xiàn)
    windows window實(shí)現(xiàn)
    make makefile
    test 單元測(cè)試文件

    • langtools目錄

    該目錄主要實(shí)現(xiàn)了jdk提供的基于jvm的工具,比如:java, javac, javah, javap等。

    langtools
        src 源碼目錄
              share java源代碼
              bin 模板
              classes java源碼文件
                         com 存放了java提供的一些基礎(chǔ)類實(shí)現(xiàn),打包成tools.jar
                         javax
                         jdk
              sample 樣例源碼
    make makefile目錄
    test 測(cè)試用例目錄


    Makefile目標(biāo)生成

    可執(zhí)行文件編譯Makefile

    文件名為:/openjdk/jdk/make/CompileLaunchers.gmkjava中提供的bin目錄下的java、javac、javap等都不是完全通過c/c++編寫實(shí)現(xiàn)的,是通過c/c++入口,啟動(dòng)虛擬機(jī)加載class文件實(shí)現(xiàn)的相關(guān)功能。通過c/c++的main函數(shù)入口,創(chuàng)建jvm虛擬機(jī)后,通過執(zhí)行相關(guān)功能的java代碼實(shí)現(xiàn)其功能,所以java相關(guān)的功能如編譯、運(yùn)行、查看jvm信息等功能都是通過啟動(dòng)一個(gè)jvm虛擬機(jī)或者通過jvmti等實(shí)現(xiàn)的。

    在makefile文件中可以查看到該部分定義。

    ifndef BUILD_HEADLESS_ONLY
      $(eval $(call SetupLauncher,appletviewer, \
          -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.applet.Main"$(COMMA) }',, \
          $(XLIBS)))
    endif
    
    $(eval $(call SetupLauncher,extcheck, \
        -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.extcheck.Main"$(COMMA) }'))
    
    $(eval $(call SetupLauncher,idlj, \
        -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.corba.se.idl.toJavaPortable.Compile"$(COMMA) }'))
    
    $(eval $(call SetupLauncher,jar, \
        -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.tools.jar.Main"$(COMMA) }'))
    
    $(eval $(call SetupLauncher,jarsigner, \
        -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.security.tools.jarsigner.Main"$(COMMA) }'))
    
    $(eval $(call SetupLauncher,javac, \
        -DEXPAND_CLASSPATH_WILDCARDS \
        -DNEVER_ACT_AS_SERVER_CLASS_MACHINE \
        -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.javac.Main"$(COMMA) }'))
    
    ifeq ($(ENABLE_SJAVAC), yes)
      $(eval $(call SetupLauncher,sjavac, \
          -DEXPAND_CLASSPATH_WILDCARDS \
          -DNEVER_ACT_AS_SERVER_CLASS_MACHINE \
          -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.sjavac.Main"$(COMMA) }'))
    endif
    
    $(eval $(call SetupLauncher,javadoc, \
        -DEXPAND_CLASSPATH_WILDCARDS \
        -DNEVER_ACT_AS_SERVER_CLASS_MACHINE \
        -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.javadoc.Main"$(COMMA) }'))
    
    $(eval $(call SetupLauncher,javah, \
        -DEXPAND_CLASSPATH_WILDCARDS \
        -DNEVER_ACT_AS_SERVER_CLASS_MACHINE \
        -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.javah.Main"$(COMMA) }'))
    
    $(eval $(call SetupLauncher,javap, \
        -DEXPAND_CLASSPATH_WILDCARDS \
        -DNEVER_ACT_AS_SERVER_CLASS_MACHINE \
        -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.javap.Main"$(COMMA) }'))
    
    $(eval $(call SetupLauncher,jdeps, \
        -DEXPAND_CLASSPATH_WILDCARDS \
        -DNEVER_ACT_AS_SERVER_CLASS_MACHINE \
        -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.jdeps.Main"$(COMMA) }'))
    
    BUILD_LAUNCHER_jconsole_CFLAGS_windows :=-DJAVAW
    BUILD_LAUNCHER_jconsole_LDFLAGS_windows :=user32.lib
    
    $(eval $(call SetupLauncher,jconsole, \
        -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "-J-Djconsole.showOutputViewer"$(COMMA) "sun.tools.jconsole.JConsole"$(COMMA) }' \
        -DAPP_CLASSPATH='{ "/lib/jconsole.jar"$(COMMA) "/lib/tools.jar"$(COMMA) "/classes" }'))
    
    $(eval $(call SetupLauncher,jdb, \
        -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.example.debug.tty.TTY"$(COMMA) }' \
        -DAPP_CLASSPATH='{ "/lib/tools.jar"$(COMMA) "/lib/sa-jdi.jar"$(COMMA) "/classes" }'))
    
    $(eval $(call SetupLauncher,jhat, \
        -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.hat.Main"$(COMMA) }'))

    具體各個(gè)具體功能實(shí)現(xiàn)可以由makefile中找到相關(guān)的類文件查看實(shí)現(xiàn)。這些類在目錄langtools目錄中。

    在linux上編譯openjdk的時(shí)候,所有java提供的工具程序(bin目錄下的可執(zhí)行程序)入口都是jdk/src/bin/share/bin/main.c。但是具體的功能代碼實(shí)現(xiàn)其實(shí)是在langtools下通過java代碼實(shí)現(xiàn)的,到底是怎么是怎么實(shí)現(xiàn)的呢。1、在jdk/src/share/bin/defines.h中通過宏開關(guān)實(shí)現(xiàn)了jvm虛擬機(jī)執(zhí)行參數(shù)的定義,如下:

    #如果定義了JAVA_ARGS宏,則會(huì)把jvm的參數(shù)從宏定義中獲取
    # 此處參照/openjdk/jdk/make/CompileLaunchers.gmk文件在聲明javac的地方,定義了該宏內(nèi)容
    # -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.javac.Main"$(COMMA) }')),所以生成的elf文件javac中
    # 會(huì)得到該值為{ "-J-ms8m"$(COMMA) "com.sun.tools.javac.Main"$(COMMA) }
    #ifdef JAVA_ARGS
    static const char* const_progname="java";
    static const char* const_jargs[]=JAVA_ARGS;
    /*
     * ApplicationHome is prepended to each of these entries; the resulting
     * strings are concatenated (separated by PATH_SEPARATOR) and used as the
     * value of -cp option to the launcher.
     */
    #ifndef APP_CLASSPATH
    #define APP_CLASSPATH        { "/lib/tools.jar", "/classes" }
    #endif /* APP_CLASSPATH */
    static const char* const_appclasspath[]=APP_CLASSPATH;
    #else  /* !JAVA_ARGS */
    #ifdef PROGNAME
    static const char* const_progname=PROGNAME;
    #else
    static char* const_progname=NULL;
    #endif
    static const char** const_jargs=NULL;
    static const char** const_appclasspath=NULL;
    #endif /* JAVA_ARGS */
    
    #ifdef LAUNCHER_NAME
    static const char* const_launcher=LAUNCHER_NAME;
    #else  /* LAUNCHER_NAME */
    static char* const_launcher=NULL;
    #endif /* LAUNCHER_NAME */
    
    #ifdef EXPAND_CLASSPATH_WILDCARDS
    static const jboolean const_cpwildcard=JNI_TRUE;
    #else
    static const jboolean const_cpwildcard=JNI_FALSE;
    #endif /* EXPAND_CLASSPATH_WILDCARDS */
    
    #if defined(NEVER_ACT_AS_SERVER_CLASS_MACHINE)
    static const jint const_ergo_class=NEVER_SERVER_CLASS;
    #elif defined(ALWAYS_ACT_AS_SERVER_CLASS_MACHINE)
    static const jint const_ergo_class=ALWAYS_SERVER_CLASS;
    #else
    static const jint const_ergo_class=DEFAULT_POLICY;
    #endif /* NEVER_ACT_AS_SERVER_CLASS_MACHINE */

    最終生成的elf程序常量區(qū)段會(huì)有程序名稱及入口的class類名稱。

    當(dāng)使用javac編譯java文件時(shí),入口參數(shù)1為java文件路徑,然后啟動(dòng)一個(gè)java虛擬機(jī)vm,把com.sun.tools.javac.Main aaa.java傳遞給java虛擬機(jī)vm執(zhí)行,傳遞給虛擬機(jī)參數(shù)如下:

    JavaVM args:
        version 0x00010002, ignoreUnrecognized is JNI_FALSE, nOptions is 7
        option[0]='-Dsun.java.launcher.diag=true'
        option[1]='-Dapplication.home=/opt/source/jdk8u-dev/build/linux-x86_64-normal-server-slowdebug/jdk'
        option[2]='-Djava.class.path=/opt/source/jdk8u-dev/build/linux-x86_64-normal-server-slowdebug/jdk/lib/tools.jar:/opt/source/jdk8u-dev/build/linux-x86_64-normal-server-slowdebug/jdk/classes'
        option[3]='-Xms8m'
        option[4]='-Dsun.java.command=com.sun.tools.javac.Main aaa.java'
        option[5]='-Dsun.java.launcher=SUN_STANDARD'
        option[6]='-Dsun.java.launcher.pid=5997'


    • 2.1 jar包生成

    jdk編譯后會(huì)生成很多jar包,除了jvm虛擬機(jī)提供的一些平臺(tái)功能外,其他語言層面的功能都是由java開發(fā)的jar包對(duì)外提供的,所以現(xiàn)在有很多語言都基于jvm做了實(shí)現(xiàn)。
    openjdk提供了由運(yùn)行時(shí)rt.jar, 工具tools.jar,編碼charset.jar等其他功能jar。
    下面詳細(xì)介紹幾個(gè)重要的jar包是怎么生成的。

    tools.jar包

    tools.jar包在jdk的lib目錄下,主要提供jdk/bin目錄下java工具的虛擬機(jī)里面的實(shí)現(xiàn)代碼,由java開發(fā)。生成tools.jar包的makefile文件是:文件名為:/openjdk/jdk/make/CreateJars.gmk,內(nèi)容如下:

    源碼路徑:langtools目錄

    #聲明tools包含的目錄范圍
    TOOLS_JAR_INCLUDES :=\
        com/sun/codemodel \
        com/sun/istack/internal/tools \
        com/sun/jarsigner \
        com/sun/javadoc \
        com/sun/jdi \
        com/sun/source \
        com/sun/tools/attach \
        com/sun/tools/classfile \
        com/sun/tools/corba \
        com/sun/tools/doclets \
        com/sun/tools/doclint \
        com/sun/tools/example/debug/expr \
        com/sun/tools/example/debug/tty \
        com/sun/tools/extcheck \
        com/sun/tools/hat \
        com/sun/tools/internal/jxc \
        com/sun/tools/internal/jxc/ap \
        com/sun/tools/internal/ws \
        com/sun/tools/internal/ws/wscompile/plugin/at_generated \
        com/sun/tools/internal/xjc \
        com/sun/tools/javac \
        com/sun/tools/javadoc \
        com/sun/tools/javah \
        com/sun/tools/javap \
        com/sun/tools/jdeps \
        com/sun/tools/jdi \
        com/sun/tools/script/shell \
        com/sun/xml/internal/dtdparser \
        com/sun/xml/internal/rngom \
        com/sun/xml/internal/xsom \
        org/relaxng/datatype \
        sun/applet \
        sun/jvmstat \
        sun/rmi/rmic \
        sun/security/tools/jarsigner \
        sun/tools/asm \
        sun/tools/attach \
        sun/tools/jar \
        sun/tools/java \
        sun/tools/javac \
        sun/tools/jcmd \
        sun/tools/jinfo \
        sun/tools/jmap \
        sun/tools/jps \
        sun/tools/jstack \
        sun/tools/jstat \
        sun/tools/jstatd \
        sun/tools/native2ascii \
        sun/tools/serialver \
        sun/tools/tree \
        sun/tools/util
    
    # tools.jar排除sjavac工具
    # The sjavac tools is not ready for public consumption.
    TOOLS_JAR_EXCLUDES=com/sun/tools/sjavac
    
    #調(diào)用打包生成tools.jar文件
    $(eval $(call SetupArchive,BUILD_TOOLS_JAR, , \
        SRCS :=$(JDK_OUTPUTDIR)/classes, \
        SUFFIXES :=.class .prp .gif .properties .xml .css .xsd .js .html .txt .java \
            Tool aliasmap options, \
        INCLUDES :=$(TOOLS_JAR_INCLUDES), \
        EXCLUDES :=$(TOOLS_JAR_EXCLUDES), \
        EXTRA_FILES :=META-INF/services/com.sun.jdi.connect.Connector \
            META-INF/services/com.sun.jdi.connect.spi.TransportService \
            META-INF/services/com.sun.tools.attach.spi.AttachProvider \
            META-INF/services/com.sun.tools.internal.ws.wscompile.Plugin \
            META-INF/services/com.sun.tools.internal.xjc.Plugin, \
        JAR :=$(IMAGES_OUTPUTDIR)/lib/tools.jar, \
        SKIP_METAINF :=true, \
        CHECK_COMPRESS_JAR :=true))
    


    rt.jar包

    rt.jar包在jdk的lib目錄下,主要提供java語言層面的運(yùn)行時(shí)庫,由java開發(fā)。rt.jar包含的文件范圍由:/openjdk/jdk/make/profile-rtjar-includes.txt定義,內(nèi)容如下:

    #
    # Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
    # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    #
    # This code is free software; you can redistribute it and/or modify it
    # under the terms of the GNU General Public License version 2 only, as
    # published by the Free Software Foundation.  Oracle designates this
    # particular file as subject to the "Classpath" exception as provided
    # by Oracle in the LICENSE file that accompanied this code.
    #
    # This code is distributed in the hope that it will be useful, but WITHOUT
    # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    # version 2 for more details (a copy is included in the LICENSE file that
    # accompanied this code).
    #
    # You should have received a copy of the GNU General Public License version
    # 2 along with this work; if not, write to the Free Software Foundation,
    # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    #
    # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    # or visit www.oracle.com if you need additional information or have any
    # questions.
    #
    
    # Included or excluded types must take one of two forms
    # - *.class to indicate all classes; or else
    # - a full single type name e.g.
    #     com/sun/security/auth/callback/DialogCallbackHandler$$1.class
    # You can not use arbitrary wildcards like DialogCallbackHandler*.class.
    #
    # Notes:
    # - Nested types must use $$ in place of $ as $ is the make meta-character
    # - If a package is not listed in any profile's inclusion list then it will
    #   not appear in any profile. But if a package is also missing from the
    #   full JRE's inclusion list then it will still be part of the full JRE.
    #   This is because the full JRE's inclusion lists are only used to define
    #   the exclusion lists for profiles; they are not used to define the full
    #   JRE contents - that is still done with the pre-profile legacy mechanism
    #   (all packagesthat can be found, less those not intended for rt.jar).
    #   This was done to minimize the impact of profiles on the regular
    #   non-profile build.
    #
    PROFILE_1_RTJAR_INCLUDE_PACKAGES :=\
        com/sun/demo/jvmti/hprof \
        com/sun/java/util/jar/pack \
        com/sun/net/ssl \
        com/sun/nio/file \
        com/sun/security/cert/internal/x509 \
        java/io \
        java/lang \
        java/math \
        java/net \
        java/nio \
        java/security \
        java/text \
        java/time \
        java/util \
        javax/net \
        javax/script \
        javax/security \
        jdk \
        sun/invoke \
        sun/launcher \
        sun/misc \
        sun/net/ \
        sun/nio \
        sun/reflect \
        sun/security \
        sun/text \
        sun/usagetracker \
        sun/util
    
    PROFILE_1_RTJAR_INCLUDE_TYPES :=PROFILE_1_RTJAR_EXCLUDE_TYPES :=PROFILE_1_INCLUDE_METAINF_SERVICES :=PROFILE_2_RTJAR_INCLUDE_PACKAGES :=\
        com/sun/java_cup/internal/runtime \
        com/sun/net/httpserver \
        com/sun/org/apache \
        com/sun/rmi/rmid \
        com/sun/xml/internal/stream \
        java/rmi \
        java/sql \
        javax/rmi/ssl \
        javax/sql \
        javax/transaction \
        javax/xml \
        org/w3c \
        org/xml/sax \
        sun/net/httpserver \
        sun/rmi \
        sun/util/xml
    
    PROFILE_2_RTJAR_INCLUDE_TYPES :=PROFILE_2_RTJAR_EXCLUDE_TYPES :=PROFILE_2_INCLUDE_METAINF_SERVICES :=\
        META-INF/services/sun.util.spi.XmlPropertiesProvider
    
    
    PROFILE_3_RTJAR_INCLUDE_PACKAGES :=\
        com/sun/jmx \
        com/sun/jndi \
        com/sun/management \
        com/sun/naming/internal \
        com/sun/nio/sctp \
        com/sun/org/apache/xml/internal/security \
        com/sun/rowset \
        com/sun/security/auth \
        com/sun/security/jgss \
        com/sun/security/ntlm \
        com/sun/security/sasl \
        com/sun/tracing \
        java/lang/instrument \
        java/lang/management \
        java/security/acl \
        java/util/prefs \
        javax/annotation/processing \
        javax/lang/model \
        javax/management \
        javax/naming \
        javax/security/auth/kerberos \
        javax/security/sasl \
        javax/smartcardio \
        javax/sql/rowset \
        javax/tools \
        javax/xml/crypto \
        org/ietf/jgss \
        org/jcp/xml \
        sun/instrument \
        sun/management \
        sun/net/dns \
        sun/net/www/protocol/http/ntlm \
        sun/net/www/protocol/http/spnego \
        sun/nio/ch/sctp \
        sun/security/acl \
        sun/security/jgss \
        sun/security/krb5 \
        sun/security/provider/certpath/ldap \
        sun/security/smartcardio \
        sun/tracing
    
    PROFILE_3_RTJAR_INCLUDE_TYPES :=PROFILE_3_RTJAR_EXCLUDE_TYPES :=\
        com/sun/security/auth/callback/DialogCallbackHandler$$1.class \
        com/sun/security/auth/callback/DialogCallbackHandler$$2.class \
        com/sun/security/auth/callback/DialogCallbackHandler$$Action.class \
        com/sun/security/auth/callback/DialogCallbackHandler$$ConfirmationInfo.class \
        com/sun/security/auth/callback/DialogCallbackHandler.class \
        javax/management/remote/rmi/_RMIConnectionImpl_Tie.class \
        javax/management/remote/rmi/_RMIConnection_Stub.class \
        javax/management/remote/rmi/_RMIServerImpl_Tie.class \
        javax/management/remote/rmi/_RMIServer_Stub.class
    
    FULL_JRE_RTJAR_INCLUDE_PACKAGES :=\
        com/oracle \
        com/sun/accessibility/internal/resources \
        com/sun/activation/registries \
        com/sun/awt \
        com/sun/beans \
        com/sun/corba \
        com/sun/image/codec/jpeg \
        com/sun/imageio \
        com/sun/istack \
        com/sun/java/browser \
        com/sun/java/swing \
        com/sun/jmx/remote/protocol/iiop \
        com/sun/jndi/cosnaming \
        com/sun/jndi/toolkit/corba \
        com/sun/jndi/url/corbaname \
        com/sun/jndi/url/iiop \
        com/sun/jndi/url/iiopname \
        com/sun/media/sound \
        com/sun/org/glassfish \
        com/sun/org/omg \
        com/sun/swing \
        com/sun/xml/internal/bind \
        com/sun/xml/internal/fastinfoset \
        com/sun/xml/internal/messaging \
        com/sun/xml/internal/org \
        com/sun/xml/internal/stream/buffer \
        com/sun/xml/internal/txw2 \
        com/sun/xml/internal/ws \
        java/applet \
        java/awt \
        java/beans \
        javax/accessibility \
        javax/activation \
        javax/activity \
        javax/imageio \
        javax/jws \
        javax/print \
        javax/rmi/CORBA \
        javax/sound \
        javax/swing \
        javax/xml/bind \
        javax/xml/soap \
        javax/xml/ws \
        org/omg \
        sun/applet \
        sun/audio \
        sun/awt \
        sun/corba \
        sun/dc \
        sun/font \
        sun/java2d \
        sun/net/ftp \
        sun/net/smtp \
        sun/net/www/content/audio \
        sun/net/www/content/image \
        sun/net/www/content/text \
        sun/net/www/protocol/ftp \
        sun/net/www/protocol/mailto \
        sun/net/www/protocol/netdoc \
        sun/print \
        sun/security/tools/policytool \
        sun/swing \
        sun/tools/jar
    
    FULL_JRE_RTJAR_INCLUDE_TYPES :=\
        com/sun/security/auth/callback/DialogCallbackHandler$$1.class \
        com/sun/security/auth/callback/DialogCallbackHandler$$2.class \
        com/sun/security/auth/callback/DialogCallbackHandler$$Action.class \
        com/sun/security/auth/callback/DialogCallbackHandler$$ConfirmationInfo.class \
        com/sun/security/auth/callback/DialogCallbackHandler.class \
        javax/annotation/*.class \
        javax/management/remote/rmi/_RMIConnectionImpl_Tie.class \
        javax/management/remote/rmi/_RMIConnection_Stub.class \
        javax/management/remote/rmi/_RMIServerImpl_Tie.class \
        javax/management/remote/rmi/_RMIServer_Stub.class \
        javax/rmi/*.class
    
    FULL_JRE_RTJAR_EXCLUDE_TYPES :=FULL_JRE_INCLUDE_METAINF_SERVICES :=\
        META-INF/services/com.sun.tools.internal.ws.wscompile.Plugin \
        META-INF/services/com.sun.tools.internal.xjc.Plugin \
        META-INF/services/javax.print.PrintServiceLookup \
        META-INF/services/javax.print.StreamPrintServiceFactory \
        META-INF/services/javax.sound.midi.spi.MidiDeviceProvider \
        META-INF/services/javax.sound.midi.spi.MidiFileReader \
        META-INF/services/javax.sound.midi.spi.MidiFileWriter \
        META-INF/services/javax.sound.midi.spi.SoundbankReader \
        META-INF/services/javax.sound.sampled.spi.AudioFileReader \
        META-INF/services/javax.sound.sampled.spi.AudioFileWriter \
        META-INF/services/javax.sound.sampled.spi.FormatConversionProvider \
        META-INF/services/javax.sound.sampled.spi.MixerProvider \
        META-INF/services/sun.java2d.cmm.PCMM \
        META-INF/services/sun.java2d.pipe.RenderingEngine
    
    

    生成tools.jar包的makefile文件是:文件名為:/openjdk/jdk/make/CreateJars.gmk,內(nèi)容如下:

    #聲明rt排除的范圍
    # Full JRE exclude list for rt.jar and resources.jar
    # This value should exclude types destined for jars other than rt.jar and resources.jar.
    # When building a Profile this value augments the profile specific exclusions
    RT_JAR_EXCLUDES +=\
        com/sun/codemodel \
        com/sun/crypto/provider \
        com/sun/istack/internal/tools \
        com/sun/jarsigner \
        com/sun/java/accessibility \
        com/sun/javadoc \
        com/sun/jdi \
        com/sun/net/ssl/internal/ssl \
        com/sun/source \
        com/sun/tools \
        com/sun/xml/internal/dtdparser \
        com/sun/xml/internal/rngom \
        com/sun/xml/internal/xsom \
        javax/crypto \
        javax/swing/AbstractButtonBeanInfo.class \
        javax/swing/beaninfo \
        javax/swing/BoxBeanInfo.class \
        javax/swing/JAppletBeanInfo.class \
        javax/swing/JButtonBeanInfo.class \
        javax/swing/JCheckBoxBeanInfo.class \
        javax/swing/JCheckBoxMenuItemBeanInfo.class \
        javax/swing/JColorChooserBeanInfo.class \
        javax/swing/JComboBoxBeanInfo.class \
        javax/swing/JComponentBeanInfo.class \
        javax/swing/JDesktopPaneBeanInfo.class \
        javax/swing/JDialogBeanInfo.class \
        javax/swing/JEditorPaneBeanInfo.class \
        javax/swing/JFileChooserBeanInfo.class \
        javax/swing/JFormattedTextFieldBeanInfo.class \
        javax/swing/JFrameBeanInfo.class \
        javax/swing/JInternalFrameBeanInfo.class \
        javax/swing/JLabelBeanInfo.class \
        javax/swing/JLayeredPaneBeanInfo.class \
        javax/swing/JListBeanInfo.class \
        javax/swing/JMenuBarBeanInfo.class \
        javax/swing/JMenuBeanInfo.class \
        javax/swing/JMenuItemBeanInfo.class \
        javax/swing/JOptionPaneBeanInfo.class \
        javax/swing/JPanelBeanInfo.class \
        javax/swing/JPasswordFieldBeanInfo.class \
        javax/swing/JPopupMenuBeanInfo.class \
        javax/swing/JProgressBarBeanInfo.class \
        javax/swing/JRadioButtonBeanInfo.class \
        javax/swing/JRadioButtonMenuItemBeanInfo.class \
        javax/swing/JScrollBarBeanInfo.class \
        javax/swing/JScrollPaneBeanInfo.class \
        javax/swing/JSeparatorBeanInfo.class \
        javax/swing/JSliderBeanInfo.class \
        javax/swing/JSpinnerBeanInfo.class \
        javax/swing/JSplitPaneBeanInfo.class \
        javax/swing/JTabbedPaneBeanInfo.class \
        javax/swing/JTableBeanInfo.class \
        javax/swing/JTextAreaBeanInfo.class \
        javax/swing/JTextFieldBeanInfo.class \
        javax/swing/JTextPaneBeanInfo.class \
        javax/swing/JToggleButtonBeanInfo.class \
        javax/swing/JToolBarBeanInfo.class \
        javax/swing/JTreeBeanInfo.class \
        javax/swing/JWindowBeanInfo.class \
        javax/swing/SwingBeanInfoBase.class \
        javax/swing/text/JTextComponentBeanInfo.class \
        META-INF/services/com.sun.jdi.connect.Connector \
        META-INF/services/com.sun.jdi.connect.spi.TransportService \
        META-INF/services/com.sun.tools.attach.spi.AttachProvider \
        META-INF/services/com.sun.tools.xjc.Plugin \
        META-INF/services/sun.net.spi.nameservice.NameServiceDescriptor \
        org/relaxng/datatype \
        sun/awt/HKSCS.class \
        sun/awt/motif/X11GB2312.class \
        sun/awt/motif/X11GB2312\$$$$Decoder.class \
        sun/awt/motif/X11GB2312\$$$$Encoder.class \
        sun/awt/motif/X11GBK.class \
        sun/awt/motif/X11GBK\$$$$Encoder.class \
        sun/awt/motif/X11KSC5601.class \
        sun/awt/motif/X11KSC5601\$$$$Decoder.class \
        sun/awt/motif/X11KSC5601\$$$$Encoder.class \
        sun/jvmstat \
        sun/net/spi/nameservice/dns \
        sun/nio/cs/ext \
        sun/rmi/rmic \
        sun/security/ec \
        sun/security/internal \
        sun/security/mscapi \
        sun/security/pkcs11 \
        sun/security/provider/Sun.class \
        sun/security/rsa/SunRsaSign.class \
        sun/security/ssl \
        sun/security/tools/jarsigner \
        sun/swing/BeanInfoUtils.class \
        sun/text/resources/cldr \
        sun/tools/asm \
        sun/tools/attach \
        sun/tools/java \
        sun/tools/javac \
        sun/tools/jcmd \
        sun/tools/jconsole \
        sun/tools/jinfo \
        sun/tools/jmap \
        sun/tools/jps \
        sun/tools/jstack \
        sun/tools/jstat \
        sun/tools/jstatd \
        sun/tools/native2ascii \
        sun/tools/serialver \
        sun/tools/tree \
        sun/tools/util \
        sun/util/cldr/CLDRLocaleDataMetaInfo.class \
        sun/util/resources/cldr \
        $(LOCALEDATA_INCLUDES) \
        com/oracle/jrockit/jfr \
        oracle/jrockit/jfr \
        jdk/jfr
    
    # 在jdk編譯輸出classes目錄下查詢所有定義依賴的文件
    # Find all files in the classes dir to use as dependencies. This could be more fine granular.
    ALL_FILES_IN_CLASSES :=$(call not-containing, _the., $(filter-out %javac_state, \
        $(call CacheFind, $(JDK_OUTPUTDIR)/classes)))
    
    RT_JAR_MANIFEST_FILE :=$(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.rt.jar_manifest
    RESOURCE_JAR_MANIFEST_FILE :=$(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.resources.jar_manifest
    
    $(RT_JAR_MANIFEST_FILE): $(MAINMANIFEST) $(BEANMANIFEST)
    	$(MKDIR) -p $(@D)
    	$(RM) $@ $@.tmp
    	$(SED) -e "s#@@RELEASE@@#$(RELEASE)#" \
    	    -e "s#@@COMPANY_NAME@@#$(COMPANY_NAME)#" \
    	    $(MAINMANIFEST) >> $@.tmp
    	$(ECHO) >> $@.tmp
    	$(CAT) $(BEANMANIFEST) >> $@.tmp
    	$(MV) $@.tmp $@
    
    
    # This defines a target-specific variables to make the shell logic easier to see.
    # We need to find the Version.class file for the profile currently being built
    $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/rt.jar: \
        CLASS_FILE=$(if $(PROFILE), $(strip $(foreach class, $(PROFILE_VERSION_CLASS_TARGETS), $(if $(findstring $(PROFILE), $(class)), $(class)))), NO_SUCH_FILE)
    # This is the real target
    $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/rt.jar: $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.rt.jar.contents $(RT_JAR_MANIFEST_FILE) $(PROFILE_VERSION_CLASS_TARGETS) $(BEANLESS_CLASSES_TARGETS)
    	$(ECHO) Creating rt.jar $(PROFILE) Compressed=$(COMPRESS_JARS)
    	$(MKDIR) -p $(@D)
    	$(RM) $@ $@.tmp
    	$(CD) $(JDK_OUTPUTDIR)/classes && \
    	$(JAR) $(RT_JAR_CREATE_OPTIONS) $@.tmp $(RT_JAR_MANIFEST_FILE) \
    	    @$(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.rt.jar.contents && \
    	if [ -f $(CLASS_FILE) ]; then \
    	  $(ECHO) Updating rt.jar $(PROFILE) && \
    	  $(CD) $(patsubst %$(VERSION_CLASS_PATH), %, $(CLASS_FILE)) && \
    	  $(JAR) $(RT_JAR_UPDATE_OPTIONS) $@.tmp $(VERSION_CLASS_PATH); \
    	  $(CD) $(BEANLESS_CLASSES) && \
    	  $(JAR) $(RT_JAR_UPDATE_OPTIONS) $@.tmp $(CLASSES_TO_DEBEAN); \
    	fi
    	$(MV) $@.tmp $@

    jconsole.jar

    jconsole.jar包在jdk的lib目錄下,是一個(gè)Java監(jiān)視和管理控制臺(tái)的客戶端程序,由javax swing開發(fā)。jsoncole可以附加本地java進(jìn)程,通過api查詢方式或者使用jms協(xié)議查詢java虛擬機(jī)一些觀測(cè)數(shù)據(jù)。jconsole.jar主要組成由jdk/src/share/classes/sun/tools/jconsole、jdk/src/share/classes/com/sun/tools/jconsole目錄下文件組成。

    jdk本身提供了2中方式,一種是bin目錄下的jconsole程序,另外一種就是lib下的jconsole.jar包。bin下的jsoncole直接運(yùn)行,啟動(dòng)打開jconsole的main入口, lib下的jsoncole.jar需要使用java -jar jsoncole.jar運(yùn)行。

    我采用的方式是在ubuntu虛擬機(jī)中交叉編譯,生成win10下的可執(zhí)行程序grep.

    ubuntu版本22.04

    apt源為華為鏡像源

    #安裝grep的依賴包
    sudo apt install build-essential libpcre3-dev
    sudo apt update  
    #這個(gè)是linux交差編譯到win上的工具鏈
    sudo apt install mingw-w64
    sudo apt install make


    下載grep源碼包 版本3.6 Index of /gnu/grep

    tar -xvf ./grep-3.6.tar.gz
    cd grep-3.6
    mkdir compile-win
    cd compile-win
    ../configure --host=x86_64-w64-mingw32 --enable-threads=windows CC=x86_64-w64-mingw32-gcc
    make
    cd src
    ls
    dfasearch.o  egrep  fgrep  grep.exe  grep.o  kwsearch.o  kwset.o  Makefile  searchutils.o

    這個(gè)時(shí)候編譯完成 但是grep.exe 體積還很大 接下來需要瘦身

    strip --strip-all grep.exe

    接下來把grep.exe copy到win10下

    UPX: the Ultimate Packer for eXecutables - Homepage

    下載upx壓縮工具


    在cmd命令行中執(zhí)行

    upx.exe grep.exe



    可以看到大小在一個(gè)滿意的范圍

    測(cè)試一下



    完成

網(wǎng)站首頁   |    關(guān)于我們   |    公司新聞   |    產(chǎn)品方案   |    用戶案例   |    售后服務(wù)   |    合作伙伴   |    人才招聘   |   

友情鏈接: 餐飲加盟

地址:北京市海淀區(qū)    電話:010-     郵箱:@126.com

備案號(hào):冀ICP備2024067069號(hào)-3 北京科技有限公司版權(quán)所有