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.
|
||||
*
|
||||
* 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() {
|
||||
ArrayList<ReferenceType> definedClasses = new ArrayList<>();
|
||||
for (ReferenceType type : vm.allClasses()) {
|
||||
vm.forEachClass(type -> {
|
||||
if (type.isPrepared() &&
|
||||
equals(type.classLoader())) {
|
||||
equals(type.classLoader())) {
|
||||
definedClasses.add(type);
|
||||
}
|
||||
}
|
||||
});
|
||||
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.
|
||||
*
|
||||
* 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() {
|
||||
List<ClassType> subs = new ArrayList<>();
|
||||
for (ReferenceType refType : vm.allClasses()) {
|
||||
vm.forEachClass(refType -> {
|
||||
if (refType instanceof ClassType) {
|
||||
ClassType clazz = (ClassType)refType;
|
||||
ClassType superclass = clazz.superclass();
|
||||
if ((superclass != null) && superclass.equals(this)) {
|
||||
subs.add((ClassType)refType);
|
||||
subs.add(clazz);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
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.
|
||||
*
|
||||
* 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() {
|
||||
List<InterfaceType> subs = new ArrayList<InterfaceType>();
|
||||
for (ReferenceType refType : vm.allClasses()) {
|
||||
vm.forEachClass(refType -> {
|
||||
if (refType instanceof InterfaceType) {
|
||||
InterfaceType interfaze = (InterfaceType)refType;
|
||||
if (interfaze.isPrepared() && interfaze.superinterfaces().contains(this)) {
|
||||
subs.add(interfaze);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return subs;
|
||||
}
|
||||
|
||||
public List<ClassType> implementors() {
|
||||
List<ClassType> implementors = new ArrayList<ClassType>();
|
||||
for (ReferenceType refType : vm.allClasses()) {
|
||||
vm.forEachClass(refType -> {
|
||||
if (refType instanceof ClassType) {
|
||||
ClassType clazz = (ClassType)refType;
|
||||
if (clazz.isPrepared() && clazz.interfaces().contains(this)) {
|
||||
implementors.add(clazz);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
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.
|
||||
*
|
||||
* 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() {
|
||||
List<ReferenceType> all = vm.allClasses();
|
||||
List<ReferenceType> nested = new ArrayList<ReferenceType>();
|
||||
String outername = name();
|
||||
int outerlen = outername.length();
|
||||
Iterator<ReferenceType> iter = all.iterator();
|
||||
while (iter.hasNext()) {
|
||||
ReferenceType refType = iter.next();
|
||||
vm.forEachClass(refType -> {
|
||||
String name = refType.name();
|
||||
int len = name.length();
|
||||
/* The separator is historically '$' but could also be '#' */
|
||||
if ( len > outerlen && name.startsWith(outername) ) {
|
||||
char c = name.charAt(outerlen);
|
||||
if ( c =='$' || c== '#' ) {
|
||||
if ( c == '$' || c == '#' ) {
|
||||
nested.add(refType);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
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.
|
||||
*
|
||||
* 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.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.sun.jdi.BooleanType;
|
||||
import com.sun.jdi.BooleanValue;
|
||||
@ -57,6 +58,7 @@ import com.sun.jdi.InternalException;
|
||||
import com.sun.jdi.LongType;
|
||||
import com.sun.jdi.LongValue;
|
||||
import com.sun.jdi.ModuleReference;
|
||||
import com.sun.jdi.ObjectCollectedException;
|
||||
import com.sun.jdi.PathSearchingVirtualMachine;
|
||||
import com.sun.jdi.PrimitiveType;
|
||||
import com.sun.jdi.ReferenceType;
|
||||
@ -338,6 +340,27 @@ class VirtualMachineImpl extends MirrorImpl
|
||||
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
|
||||
redefineClasses(Map<? extends ReferenceType, byte[]> classToBytes)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user