JDK1.6到1.8的注意事项

来源:互联网 发布:电脑淘宝联盟新手教程 编辑:程序博客网 时间:2024/06/04 17:51

 jdk7都终止更新了,而我们还在用jdk6.。。。 ,安全层面是一个问题,同时有更多的小伙伴早就迫不及待的想使用jdk8才支持的新特性,so,升级计划提上议程,但是升级前的功课还是要做的:

 

1.sun.* 包缺失问题

 如有特殊需求,请下载sun-support-4jkd8.jar ,放到classpath目录

 sun.*包 ,已不推荐使用,oracle会逐步进行删除,建议大家不要使用。参考如下:

 http://www.oracle.com/technetwork/java/javase/8-compatibility-guide-2156366.html

 http://www.oracle.com/technetwork/java/faq-sun-packages-142232.html


2.默认安全策略修改

  升级后估计有些小伙伴在使用不安全算法时可能会发生错误,so,支持不安全算法还是有必要的

  找到$JAVA_HOME下 jre/lib/security/java.security

  将禁用的算法设置为空:jdk.certpath.disabledAlgorithms=


3.第三方jar包无法使用

   

1)查找组件用到了mvel,mvel为了提高效率进行了字节码优化,正好碰上jdk8死穴,所以需要升级。

<dependency>

 <groupId>org.mvel</groupId>

 <artifactId>mvel2</artifactId>

   <version>2.2.7.Final</version>

 </dependency>

 

2)javassist与jdk8 兼容性问题,需要升级到最新版本

<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.18.1-GA</version>
</dependency>

--#注意部署工具,不会删除旧版本,所以需要手动删除之前的版本。

4.JVM参数调整

在jdk8中,PermSize相关的参数已经不被使用:

-XX:MaxPermSize=size

Sets the maximum permanent generation space size (in bytes). This option was deprecated in JDK 8, and superseded by the -XX:MaxMetaspaceSize option.

-XX:PermSize=size

Sets the space (in bytes) allocated to the permanent generation that triggers a garbage collection if it is exceeded. This option was deprecated un JDK 8, and superseded by the -XX:MetaspaceSize option.

    

Java 8中再也没有PermGen了。其中的某些部分,如被intern的字符串,在Java 7中已经移到了普通堆里。其余结构在Java 8中会被移到称作“Metaspace”的本机内存区中,该区域在默认情况下会自动生长,也会被垃圾回收。它有两个标记:MetaspaceSize和MaxMetaspaceSize。

-XX:MetaspaceSize=size

Sets the size of the allocated class metadata space that will trigger a garbage collection the first time it is exceeded. This threshold for a garbage collection is increased or decreased depending on the amount of metadata used. The default size depends on the platform.

 

-XX:MaxMetaspaceSize=size

Sets the maximum amount of native memory that can be allocated for class metadata. By default, the size is not limited. The amount of metadata for an application depends on the application itself, other running applications, and the amount of memory available on the system.

The following example shows how to set the maximum class metadata size to 256 MB:-XX:MaxMetaspaceSize=256m

0 0