agent/src/share/classes/sun/jvm/hotspot/jdi/ClassTypeImpl.java
Print this page
rev 5684 : 4990369: visibleMethods() and methodsByName() return wrong visible methods
Reviewed-by:
*** 22,37 ****
*
*/
package sun.jvm.hotspot.jdi;
! import com.sun.jdi.*;
! import sun.jvm.hotspot.oops.Klass;
import sun.jvm.hotspot.oops.InstanceKlass;
! import java.util.*;
! import java.lang.ref.SoftReference;
public class ClassTypeImpl extends ReferenceTypeImpl
implements ClassType
{
private SoftReference interfacesCache = null;
--- 22,55 ----
*
*/
package sun.jvm.hotspot.jdi;
! 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 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
{
private SoftReference interfacesCache = null;
*** 193,218 ****
InvocationException {
vm.throwNotReadOnlyException("ClassType.newInstance(...)");
return null;
}
! void addVisibleMethods(Map methodMap) {
/*
* Add methods from
* parent types first, so that the methods in this class will
* overwrite them in the hash table
*/
! Iterator iter = interfaces().iterator();
while (iter.hasNext()) {
InterfaceTypeImpl interfaze = (InterfaceTypeImpl)iter.next();
! interfaze.addVisibleMethods(methodMap);
}
ClassTypeImpl clazz = (ClassTypeImpl)superclass();
if (clazz != null) {
! clazz.addVisibleMethods(methodMap);
}
addToMethodMap(methodMap, methods());
}
--- 211,240 ----
InvocationException {
vm.throwNotReadOnlyException("ClassType.newInstance(...)");
return null;
}
! @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<InterfaceType> iter = interfaces().iterator();
while (iter.hasNext()) {
InterfaceTypeImpl interfaze = (InterfaceTypeImpl)iter.next();
! if (!seenInterfaces.contains(interfaze)) {
! interfaze.addVisibleMethods(methodMap, seenInterfaces);
! seenInterfaces.add(interfaze);
! }
}
ClassTypeImpl clazz = (ClassTypeImpl)superclass();
if (clazz != null) {
! clazz.addVisibleMethods(methodMap, seenInterfaces);
}
addToMethodMap(methodMap, methods());
}