8328611: Thread safety issue in com.sun.tools.jdi.ReferenceTypeImpl::classObject
Reviewed-by: amenkov, sspitsyn
This commit is contained in:
parent
1d889e54fc
commit
922e312b0a
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2024, 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
|
||||
@ -182,8 +182,7 @@ public abstract class ReferenceTypeImpl extends TypeImpl implements ReferenceTyp
|
||||
|
||||
public String signature() {
|
||||
if (signature == null) {
|
||||
// Does not need synchronization, since worst-case
|
||||
// static info is fetched twice
|
||||
// Does not need synchronization. Worst case is static info is fetched twice.
|
||||
if (vm.canGet1_5LanguageFeatures()) {
|
||||
/*
|
||||
* we might as well get both the signature and the
|
||||
@ -205,8 +204,7 @@ public abstract class ReferenceTypeImpl extends TypeImpl implements ReferenceTyp
|
||||
public String genericSignature() {
|
||||
// This gets both the signature and the generic signature
|
||||
if (vm.canGet1_5LanguageFeatures() && !genericSignatureGotten) {
|
||||
// Does not need synchronization, since worst-case
|
||||
// static info is fetched twice
|
||||
// Does not need synchronization. Worst case is static info is fetched twice.
|
||||
JDWP.ReferenceType.SignatureWithGeneric result;
|
||||
try {
|
||||
result = JDWP.ReferenceType.SignatureWithGeneric.
|
||||
@ -222,8 +220,7 @@ public abstract class ReferenceTypeImpl extends TypeImpl implements ReferenceTyp
|
||||
|
||||
public ClassLoaderReference classLoader() {
|
||||
if (!isClassLoaderCached) {
|
||||
// Does not need synchronization, since worst-case
|
||||
// static info is fetched twice
|
||||
// Does not need synchronization. Worst case is static info is fetched twice.
|
||||
try {
|
||||
classLoader = JDWP.ReferenceType.ClassLoader.
|
||||
process(vm, this).classLoader;
|
||||
@ -239,9 +236,8 @@ public abstract class ReferenceTypeImpl extends TypeImpl implements ReferenceTyp
|
||||
if (module != null) {
|
||||
return module;
|
||||
}
|
||||
// Does not need synchronization, since worst-case
|
||||
// static info is fetched twice
|
||||
try {
|
||||
// Does not need synchronization. Worst case is static info is fetched twice.
|
||||
ModuleReferenceImpl m = JDWP.ReferenceType.Module.
|
||||
process(vm, this).module;
|
||||
module = vm.getModule(m.ref());
|
||||
@ -694,17 +690,12 @@ public abstract class ReferenceTypeImpl extends TypeImpl implements ReferenceTyp
|
||||
|
||||
public ClassObjectReference classObject() {
|
||||
if (classObject == null) {
|
||||
// Are classObjects unique for an Object, or
|
||||
// created each time? Is this spec'ed?
|
||||
synchronized(this) {
|
||||
if (classObject == null) {
|
||||
try {
|
||||
classObject = JDWP.ReferenceType.ClassObject.
|
||||
process(vm, this).classObject;
|
||||
} catch (JDWPException exc) {
|
||||
throw exc.toJDIException();
|
||||
}
|
||||
}
|
||||
// Does not need synchronization. Worst case is static info is fetched twice.
|
||||
try {
|
||||
classObject = JDWP.ReferenceType.ClassObject.
|
||||
process(vm, this).classObject;
|
||||
} catch (JDWPException exc) {
|
||||
throw exc.toJDIException();
|
||||
}
|
||||
}
|
||||
return classObject;
|
||||
@ -747,8 +738,7 @@ public abstract class ReferenceTypeImpl extends TypeImpl implements ReferenceTyp
|
||||
String baseSourceName() throws AbsentInformationException {
|
||||
String bsn = baseSourceName;
|
||||
if (bsn == null) {
|
||||
// Does not need synchronization, since worst-case
|
||||
// static info is fetched twice
|
||||
// Does not need synchronization. Worst case is static info is fetched twice.
|
||||
try {
|
||||
bsn = JDWP.ReferenceType.SourceFile.
|
||||
process(vm, this).sourceFile;
|
||||
@ -1065,13 +1055,12 @@ public abstract class ReferenceTypeImpl extends TypeImpl implements ReferenceTyp
|
||||
}
|
||||
}
|
||||
|
||||
// Does not need synchronization, since worst-case
|
||||
// static info is fetched twice
|
||||
void getModifiers() {
|
||||
if (modifiers != -1) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
// Does not need synchronization. Worst case is static info is fetched twice.
|
||||
modifiers = JDWP.ReferenceType.Modifiers.
|
||||
process(vm, this).modBits;
|
||||
} catch (JDWPException exc) {
|
||||
|
Loading…
Reference in New Issue
Block a user