提交 b7c0645f 编写于 作者: V valeriep

7001933: Deadlock in java.lang.classloader.getPackage()

Summary: Modified to not holding the "packages" lock when calling parent CL.
Reviewed-by: dholmes, alanb
上级 efcd30d7
/* /*
* Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -1626,20 +1626,28 @@ public abstract class ClassLoader { ...@@ -1626,20 +1626,28 @@ public abstract class ClassLoader {
* @since 1.2 * @since 1.2
*/ */
protected Package getPackage(String name) { protected Package getPackage(String name) {
Package pkg;
synchronized (packages) { synchronized (packages) {
Package pkg = packages.get(name); pkg = packages.get(name);
if (pkg == null) { }
if (parent != null) { if (pkg == null) {
pkg = parent.getPackage(name); if (parent != null) {
} else { pkg = parent.getPackage(name);
pkg = Package.getSystemPackage(name); } else {
} pkg = Package.getSystemPackage(name);
if (pkg != null) { }
packages.put(name, pkg); if (pkg != null) {
synchronized (packages) {
Package pkg2 = packages.get(name);
if (pkg2 == null) {
packages.put(name, pkg);
} else {
pkg = pkg2;
}
} }
} }
return pkg;
} }
return pkg;
} }
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册