8222422: vmTestbase/nsk/jdi/ClassLoaderReference/definedClasses tests failed with Unexpected Exception: null
Reviewed-by: dholmes, jcbeyler, cjplummer
This commit is contained in:
parent
fa2ea6a6d8
commit
cca7246a1a
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1998, 2019, 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
|
||||||
@ -59,12 +59,12 @@ public class ClassLoaderReferenceImpl extends ObjectReferenceImpl
|
|||||||
|
|
||||||
public List<ReferenceType> definedClasses() {
|
public List<ReferenceType> definedClasses() {
|
||||||
ArrayList<ReferenceType> definedClasses = new ArrayList<>();
|
ArrayList<ReferenceType> definedClasses = new ArrayList<>();
|
||||||
for (ReferenceType type : vm.allClasses()) {
|
vm.forEachClass(type -> {
|
||||||
if (type.isPrepared() &&
|
if (type.isPrepared() &&
|
||||||
equals(type.classLoader())) {
|
equals(type.classLoader())) {
|
||||||
definedClasses.add(type);
|
definedClasses.add(type);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
return definedClasses;
|
return definedClasses;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1998, 2019, 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
|
||||||
@ -110,16 +110,15 @@ final public class ClassTypeImpl extends InvokableTypeImpl
|
|||||||
|
|
||||||
public List<ClassType> subclasses() {
|
public List<ClassType> subclasses() {
|
||||||
List<ClassType> subs = new ArrayList<>();
|
List<ClassType> subs = new ArrayList<>();
|
||||||
for (ReferenceType refType : vm.allClasses()) {
|
vm.forEachClass(refType -> {
|
||||||
if (refType instanceof ClassType) {
|
if (refType instanceof ClassType) {
|
||||||
ClassType clazz = (ClassType)refType;
|
ClassType clazz = (ClassType)refType;
|
||||||
ClassType superclass = clazz.superclass();
|
ClassType superclass = clazz.superclass();
|
||||||
if ((superclass != null) && superclass.equals(this)) {
|
if ((superclass != null) && superclass.equals(this)) {
|
||||||
subs.add((ClassType)refType);
|
subs.add(clazz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
return subs;
|
return subs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1998, 2019, 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
|
||||||
@ -77,27 +77,27 @@ final public class InterfaceTypeImpl extends InvokableTypeImpl
|
|||||||
|
|
||||||
public List<InterfaceType> subinterfaces() {
|
public List<InterfaceType> subinterfaces() {
|
||||||
List<InterfaceType> subs = new ArrayList<InterfaceType>();
|
List<InterfaceType> subs = new ArrayList<InterfaceType>();
|
||||||
for (ReferenceType refType : vm.allClasses()) {
|
vm.forEachClass(refType -> {
|
||||||
if (refType instanceof InterfaceType) {
|
if (refType instanceof InterfaceType) {
|
||||||
InterfaceType interfaze = (InterfaceType)refType;
|
InterfaceType interfaze = (InterfaceType)refType;
|
||||||
if (interfaze.isPrepared() && interfaze.superinterfaces().contains(this)) {
|
if (interfaze.isPrepared() && interfaze.superinterfaces().contains(this)) {
|
||||||
subs.add(interfaze);
|
subs.add(interfaze);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
return subs;
|
return subs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ClassType> implementors() {
|
public List<ClassType> implementors() {
|
||||||
List<ClassType> implementors = new ArrayList<ClassType>();
|
List<ClassType> implementors = new ArrayList<ClassType>();
|
||||||
for (ReferenceType refType : vm.allClasses()) {
|
vm.forEachClass(refType -> {
|
||||||
if (refType instanceof ClassType) {
|
if (refType instanceof ClassType) {
|
||||||
ClassType clazz = (ClassType)refType;
|
ClassType clazz = (ClassType)refType;
|
||||||
if (clazz.isPrepared() && clazz.interfaces().contains(this)) {
|
if (clazz.isPrepared() && clazz.interfaces().contains(this)) {
|
||||||
implementors.add(clazz);
|
implementors.add(clazz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
return implementors;
|
return implementors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1998, 2019, 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
|
||||||
@ -607,23 +607,20 @@ public abstract class ReferenceTypeImpl extends TypeImpl implements ReferenceTyp
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<ReferenceType> nestedTypes() {
|
public List<ReferenceType> nestedTypes() {
|
||||||
List<ReferenceType> all = vm.allClasses();
|
|
||||||
List<ReferenceType> nested = new ArrayList<ReferenceType>();
|
List<ReferenceType> nested = new ArrayList<ReferenceType>();
|
||||||
String outername = name();
|
String outername = name();
|
||||||
int outerlen = outername.length();
|
int outerlen = outername.length();
|
||||||
Iterator<ReferenceType> iter = all.iterator();
|
vm.forEachClass(refType -> {
|
||||||
while (iter.hasNext()) {
|
|
||||||
ReferenceType refType = iter.next();
|
|
||||||
String name = refType.name();
|
String name = refType.name();
|
||||||
int len = name.length();
|
int len = name.length();
|
||||||
/* The separator is historically '$' but could also be '#' */
|
/* The separator is historically '$' but could also be '#' */
|
||||||
if ( len > outerlen && name.startsWith(outername) ) {
|
if ( len > outerlen && name.startsWith(outername) ) {
|
||||||
char c = name.charAt(outerlen);
|
char c = name.charAt(outerlen);
|
||||||
if ( c =='$' || c== '#' ) {
|
if ( c == '$' || c == '#' ) {
|
||||||
nested.add(refType);
|
nested.add(refType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
return nested;
|
return nested;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1998, 2019, 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
|
||||||
@ -38,6 +38,7 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import com.sun.jdi.BooleanType;
|
import com.sun.jdi.BooleanType;
|
||||||
import com.sun.jdi.BooleanValue;
|
import com.sun.jdi.BooleanValue;
|
||||||
@ -57,6 +58,7 @@ import com.sun.jdi.InternalException;
|
|||||||
import com.sun.jdi.LongType;
|
import com.sun.jdi.LongType;
|
||||||
import com.sun.jdi.LongValue;
|
import com.sun.jdi.LongValue;
|
||||||
import com.sun.jdi.ModuleReference;
|
import com.sun.jdi.ModuleReference;
|
||||||
|
import com.sun.jdi.ObjectCollectedException;
|
||||||
import com.sun.jdi.PathSearchingVirtualMachine;
|
import com.sun.jdi.PathSearchingVirtualMachine;
|
||||||
import com.sun.jdi.PrimitiveType;
|
import com.sun.jdi.PrimitiveType;
|
||||||
import com.sun.jdi.ReferenceType;
|
import com.sun.jdi.ReferenceType;
|
||||||
@ -338,6 +340,27 @@ class VirtualMachineImpl extends MirrorImpl
|
|||||||
return Collections.unmodifiableList(a);
|
return Collections.unmodifiableList(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Performs an action for each loaded type.
|
||||||
|
*/
|
||||||
|
public void forEachClass(Consumer<ReferenceType> action) {
|
||||||
|
for (ReferenceType type : allClasses()) {
|
||||||
|
try {
|
||||||
|
action.accept(type);
|
||||||
|
} catch (ObjectCollectedException ex) {
|
||||||
|
// Some classes might be unloaded and garbage collected since
|
||||||
|
// we retrieved the copy of all loaded classes and started
|
||||||
|
// iterating over them. In this case calling methods on such types
|
||||||
|
// might result in com.sun.jdi.ObjectCollectedException
|
||||||
|
// being thrown. We ignore such classes and keep iterating.
|
||||||
|
if ((vm.traceFlags & VirtualMachine.TRACE_OBJREFS) != 0) {
|
||||||
|
vm.printTrace("ObjectCollectedException was thrown while " +
|
||||||
|
"accessing unloaded class " + type.name());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void
|
public void
|
||||||
redefineClasses(Map<? extends ReferenceType, byte[]> classToBytes)
|
redefineClasses(Map<? extends ReferenceType, byte[]> classToBytes)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user