通过向classes.jsa添加自己的应用程序类来加速应用程序启动 [英] Speed up application start by adding own application classes to classes.jsa

查看:761
本文介绍了通过向classes.jsa添加自己的应用程序类来加速应用程序启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了加快JVM的启动时间,Sun开发人员认为在安装JVM期间为平台预编译标准运行时类是个好主意。可以找到这些预编译的类,例如at:

To speed up the startup time of the JVM, the Sun developers decided it is a good idea to precompile the standard runtime classes for a platform during installation of the JVM. These precompiled classes can be found e.g. at:

$ JAVA_HOME\jre\bin\client\classes.jsa

$JAVA_HOME\jre\bin\client\classes.jsa

我的公司目前开发了一个Java独立应用程序,它带来了自己的JRE,因此通过在这个jsa文件中添加我们自己的应用程序类来加速我们的应用程序启动时间是一个很棒的选择。

My company currently develops a Java standalone application which brings its own JRE, so it would be a fantastic option to speed up our application start time by adding our own application classes to this jsa file, too.

我不相信JSA文件是由魔术创建的,所以:它是如何创建的?我如何欺骗JVM合并我自己的类?

I don't believe the JSA file was created by magic, so: How is it created? And how can I trick the JVM into incorporating my own classes?

编辑:我已经发现以下内容:

EDIT: I already found out the following:

classes.jsa由命令创建

The classes.jsa is created by the command

java -Xshare:dump

要包含在转储中的类列表可以在 $ JAVA_HOME / jre /中找到lib / classlist

The list of classes to incorporate in the dump can be found in $JAVA_HOME/jre/lib/classlist.

我甚至设法在这里添加我自己的类(并将它们添加到rt.jar中以便java找到它们),并在类列表文件下面生成我自己的校验和。

I even managed to add my own classes here (and to add them into the rt.jar for java to find them), and to generate my own checksum below the classlist file.

最后一个问题是:只有java,com.sun和org.w3c包中的类似乎如果我在原始包装中保留相同的类别,则不会被加载。我在整个OpenJDK源代码中搜索了这个指针,但它似乎与保护域有关。如果有人对这个主题感兴趣并且知识渊博,请为我添加一些指示以便进一步调查。

The final problem is: Only classes in the packages java, com.sun, and org.w3c seem to be recognized, if I leave the same classes in their original packages, they won't be loaded. I searched the whole OpenJDK source for pointer about this, but it seems to have something to do with protection domains. If someone is interested enough in this topic and knowledgeable enough, please add some pointers for me to investigaete further.

推荐答案

从Java开始8u40(和嵌入式Java 8u51),Java现在支持应用程序类数据共享(AppCDS)(即您在共享存档中的类)。在我们的嵌入式java上,我们发现启动改进> 40%!对于我们来说几乎没有工作非常棒......

As of Java 8u40 (and Embedded Java 8u51), Java now supports Application Class Data Sharing (AppCDS) (ie your own classes in the shared archive). On our embedded java, we've found a startup improvement of >40%! Pretty awesome for almost no work on our part...

https ://blogs.oracle.com/thejavatutorials/entry/jdk_8u40_released

这篇关于通过向classes.jsa添加自己的应用程序类来加速应用程序启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆