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