做个小调查,有多少公司已经迁移到 JDK11 了?或者使用 OpenJDK?

2020-03-05 11:15:12 +08:00
 afirefish
10617 次点击
所在节点    Java
66 条回复
pzhdfy
2020-03-07 14:03:56 +08:00
@BBCCBB
不是新方法 而是 clean 的方法变了 没有兼容的代码直接拿到 jdk11 上运行会有 bug

private static Cleaner lookupCleanerJava9(MethodHandles.Lookup lookup) throws ReflectiveOperationException
{
Class<?> cleaner = Class.forName("java.lang.ref.Cleaner");
Class<?> cleanable = Class.forName("java.lang.ref.Cleaner$Cleanable");

MethodHandle create = lookup.findStatic(cleaner, "create", MethodType.methodType(cleaner));

Object theCleaner;
try {
theCleaner = create.invoke();
}
catch (Throwable t) {
throw new RuntimeException("Unable to create cleaner", t);
}

MethodHandle register = lookup.findVirtual(
cleaner,
"register",
MethodType.methodType(cleanable, Object.class, Runnable.class)
).bindTo(theCleaner);

MethodHandle clean = lookup.findVirtual(cleanable, "clean", MethodType.methodType(void.class));

return new CleanerImpl(register, clean);
}

private static Cleaner lookupCleanerJava8(MethodHandles.Lookup lookup) throws ReflectiveOperationException
{
Class<?> cleaner = Class.forName("sun.misc.Cleaner");
MethodHandle register = lookup.findStatic(
cleaner,
"create",
MethodType.methodType(cleaner, Object.class, Runnable.class)
);

MethodHandle clean = lookup.findVirtual(cleaner, "clean", MethodType.methodType(void.class));
return new CleanerImpl(register, clean);
}
pzhdfy
2020-03-07 14:07:37 +08:00
另外个人观点 如果现状稳定 没有需求不建议老项目升级 风险较大
我们遇到的问题是我们进程的堆有 200G,是个计算和内存密集型程序,容易发生 full gc, 原来可能暂停几十秒,使用 jdk11 后并行 full gc 一般控制在 3s 内
cheng6563
2020-03-07 22:27:49 +08:00
一直用的 centos 自带的 openjdk
deef
2020-03-08 11:06:55 +08:00
一直在用 JDK8, 感觉近几年要是没什么重要的问题应该都不会升了
zzzmh
2020-03-09 11:10:14 +08:00
公司和自己都用 Openjdk8 感觉可以用到退休
sunwei0325
2020-03-29 18:48:10 +08:00
新版任你发, 我用 java8

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/650023

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX