4990369: visibleMethods() and methodsByName() return wrong visible methods
Reviewed-by: sspitsyn, coleenp
This commit is contained in:
parent
6794647135
commit
3c425d407f
@ -24,19 +24,29 @@
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import sun.jvm.hotspot.oops.ArrayKlass;
|
||||
import sun.jvm.hotspot.oops.InstanceKlass;
|
||||
import sun.jvm.hotspot.oops.ObjArrayKlass;
|
||||
import sun.jvm.hotspot.oops.TypeArrayKlass;
|
||||
import sun.jvm.hotspot.oops.Klass;
|
||||
import sun.jvm.hotspot.oops.Instance;
|
||||
import sun.jvm.hotspot.oops.InstanceKlass;
|
||||
import sun.jvm.hotspot.oops.Klass;
|
||||
import sun.jvm.hotspot.oops.ObjArrayKlass;
|
||||
import sun.jvm.hotspot.oops.Symbol;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import sun.jvm.hotspot.oops.TypeArrayKlass;
|
||||
|
||||
import com.sun.jdi.ArrayReference;
|
||||
import com.sun.jdi.ArrayType;
|
||||
import com.sun.jdi.ClassLoaderReference;
|
||||
import com.sun.jdi.ClassNotLoadedException;
|
||||
import com.sun.jdi.InterfaceType;
|
||||
import com.sun.jdi.Method;
|
||||
import com.sun.jdi.PrimitiveType;
|
||||
import com.sun.jdi.ReferenceType;
|
||||
import com.sun.jdi.Type;
|
||||
import com.sun.jdi.VirtualMachine;
|
||||
|
||||
public class ArrayTypeImpl extends ReferenceTypeImpl implements ArrayType {
|
||||
protected ArrayTypeImpl(VirtualMachine aVm, ArrayKlass aRef) {
|
||||
@ -75,7 +85,8 @@ public class ArrayTypeImpl extends ReferenceTypeImpl implements ArrayType {
|
||||
}
|
||||
}
|
||||
|
||||
void addVisibleMethods(Map methodMap) {
|
||||
@Override
|
||||
void addVisibleMethods(Map<String, Method> methodMap, Set<InterfaceType> handledInterfaces) {
|
||||
// arrays don't have methods
|
||||
}
|
||||
|
||||
|
@ -24,12 +24,30 @@
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
import sun.jvm.hotspot.oops.Klass;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import sun.jvm.hotspot.oops.InstanceKlass;
|
||||
|
||||
import java.util.*;
|
||||
import java.lang.ref.SoftReference;
|
||||
import com.sun.jdi.ClassNotLoadedException;
|
||||
import com.sun.jdi.ClassType;
|
||||
import com.sun.jdi.Field;
|
||||
import com.sun.jdi.IncompatibleThreadStateException;
|
||||
import com.sun.jdi.InterfaceType;
|
||||
import com.sun.jdi.InvalidTypeException;
|
||||
import com.sun.jdi.InvocationException;
|
||||
import com.sun.jdi.Method;
|
||||
import com.sun.jdi.ObjectReference;
|
||||
import com.sun.jdi.ReferenceType;
|
||||
import com.sun.jdi.ThreadReference;
|
||||
import com.sun.jdi.Value;
|
||||
import com.sun.jdi.VirtualMachine;
|
||||
|
||||
public class ClassTypeImpl extends ReferenceTypeImpl
|
||||
implements ClassType
|
||||
@ -195,22 +213,26 @@ public class ClassTypeImpl extends ReferenceTypeImpl
|
||||
return null;
|
||||
}
|
||||
|
||||
void addVisibleMethods(Map methodMap) {
|
||||
@Override
|
||||
void addVisibleMethods(Map<String, Method> methodMap, Set<InterfaceType> seenInterfaces) {
|
||||
/*
|
||||
* Add methods from
|
||||
* parent types first, so that the methods in this class will
|
||||
* overwrite them in the hash table
|
||||
*/
|
||||
|
||||
Iterator iter = interfaces().iterator();
|
||||
Iterator<InterfaceType> iter = interfaces().iterator();
|
||||
while (iter.hasNext()) {
|
||||
InterfaceTypeImpl interfaze = (InterfaceTypeImpl)iter.next();
|
||||
interfaze.addVisibleMethods(methodMap);
|
||||
if (!seenInterfaces.contains(interfaze)) {
|
||||
interfaze.addVisibleMethods(methodMap, seenInterfaces);
|
||||
seenInterfaces.add(interfaze);
|
||||
}
|
||||
}
|
||||
|
||||
ClassTypeImpl clazz = (ClassTypeImpl)superclass();
|
||||
if (clazz != null) {
|
||||
clazz.addVisibleMethods(methodMap);
|
||||
clazz.addVisibleMethods(methodMap, seenInterfaces);
|
||||
}
|
||||
|
||||
addToMethodMap(methodMap, methods());
|
||||
|
@ -24,15 +24,22 @@
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import sun.jvm.hotspot.oops.InstanceKlass;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
import java.util.Iterator;
|
||||
import java.util.Collections;
|
||||
import java.lang.ref.SoftReference;
|
||||
import com.sun.jdi.ClassNotPreparedException;
|
||||
import com.sun.jdi.ClassType;
|
||||
import com.sun.jdi.InterfaceType;
|
||||
import com.sun.jdi.Method;
|
||||
import com.sun.jdi.ReferenceType;
|
||||
import com.sun.jdi.VirtualMachine;
|
||||
|
||||
public class InterfaceTypeImpl extends ReferenceTypeImpl
|
||||
implements InterfaceType {
|
||||
@ -96,16 +103,20 @@ public class InterfaceTypeImpl extends ReferenceTypeImpl
|
||||
return implementors;
|
||||
}
|
||||
|
||||
void addVisibleMethods(Map methodMap) {
|
||||
@Override
|
||||
void addVisibleMethods(Map<String, Method> methodMap, Set<InterfaceType> seenInterfaces) {
|
||||
/*
|
||||
* Add methods from
|
||||
* parent types first, so that the methods in this class will
|
||||
* overwrite them in the hash table
|
||||
*/
|
||||
Iterator iter = superinterfaces().iterator();
|
||||
Iterator<InterfaceType> iter = superinterfaces().iterator();
|
||||
while (iter.hasNext()) {
|
||||
InterfaceTypeImpl interfaze = (InterfaceTypeImpl)iter.next();
|
||||
interfaze.addVisibleMethods(methodMap);
|
||||
if (!seenInterfaces.contains(interfaze)) {
|
||||
interfaze.addVisibleMethods(methodMap, seenInterfaces);
|
||||
seenInterfaces.add(interfaze);
|
||||
}
|
||||
}
|
||||
|
||||
addToMethodMap(methodMap, methods());
|
||||
|
@ -24,24 +24,45 @@
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import sun.jvm.hotspot.memory.SystemDictionary;
|
||||
import sun.jvm.hotspot.oops.ArrayKlass;
|
||||
import sun.jvm.hotspot.oops.DefaultHeapVisitor;
|
||||
import sun.jvm.hotspot.oops.Instance;
|
||||
import sun.jvm.hotspot.oops.InstanceKlass;
|
||||
import sun.jvm.hotspot.oops.ArrayKlass;
|
||||
import sun.jvm.hotspot.oops.JVMDIClassStatus;
|
||||
import sun.jvm.hotspot.oops.Klass;
|
||||
import sun.jvm.hotspot.oops.ObjArray;
|
||||
import sun.jvm.hotspot.oops.Oop;
|
||||
import sun.jvm.hotspot.oops.Symbol;
|
||||
import sun.jvm.hotspot.oops.DefaultHeapVisitor;
|
||||
import sun.jvm.hotspot.utilities.Assert;
|
||||
|
||||
import java.util.*;
|
||||
import java.lang.ref.SoftReference;
|
||||
import com.sun.jdi.AbsentInformationException;
|
||||
import com.sun.jdi.ArrayType;
|
||||
import com.sun.jdi.ClassLoaderReference;
|
||||
import com.sun.jdi.ClassNotLoadedException;
|
||||
import com.sun.jdi.ClassNotPreparedException;
|
||||
import com.sun.jdi.ClassObjectReference;
|
||||
import com.sun.jdi.Field;
|
||||
import com.sun.jdi.InterfaceType;
|
||||
import com.sun.jdi.Method;
|
||||
import com.sun.jdi.ObjectReference;
|
||||
import com.sun.jdi.PrimitiveType;
|
||||
import com.sun.jdi.ReferenceType;
|
||||
import com.sun.jdi.Type;
|
||||
import com.sun.jdi.Value;
|
||||
import com.sun.jdi.VirtualMachine;
|
||||
|
||||
public abstract class ReferenceTypeImpl extends TypeImpl
|
||||
implements ReferenceType {
|
||||
@ -421,7 +442,8 @@ implements ReferenceType {
|
||||
}
|
||||
}
|
||||
|
||||
abstract void addVisibleMethods(Map methodMap);
|
||||
abstract void addVisibleMethods(Map<String, Method> methodMap, Set<InterfaceType> seenInterfaces);
|
||||
|
||||
public final List visibleMethods() throws ClassNotPreparedException {
|
||||
checkPrepared();
|
||||
/*
|
||||
@ -430,8 +452,8 @@ implements ReferenceType {
|
||||
* concatenation of name and signature.
|
||||
*/
|
||||
//System.out.println("jj: RTI: Calling addVisibleMethods for:" + this);
|
||||
Map map = new HashMap();
|
||||
addVisibleMethods(map);
|
||||
Map<String, Method> map = new HashMap<String, Method>();
|
||||
addVisibleMethods(map, new HashSet<InterfaceType>());
|
||||
|
||||
/*
|
||||
* ... but the hash map destroys order. Methods should be
|
||||
@ -441,7 +463,7 @@ implements ReferenceType {
|
||||
*/
|
||||
//System.out.println("jj: RTI: Calling allMethods for:" + this);
|
||||
|
||||
List list = new ArrayList(allMethods());
|
||||
List<Method> list = new ArrayList<Method>(allMethods());
|
||||
//System.out.println("jj: allMethods = " + jjstr(list));
|
||||
//System.out.println("jj: map = " + map.toString());
|
||||
//System.out.println("jj: map = " + jjstr(map.values()));
|
||||
|
Loading…
Reference in New Issue
Block a user