The problem is that whenever methods() in com.sun.tools.jdi.ReferenceTypeImpl
is called, it adds another UnmodifiableList around the list of methods it
already has. If the method is called many times, as is often is by the JDI
implementation, the underlying list will have thousands of wrappers around
This will eventually cause a StackOverflowError when the code gets an
iterator for the list, as each UnmodifiableList wrapper causes two methods on
the stack. It also uses memory for no reason, as each wrapper accomplishes
The fix should be simple - only wrap the underlying method list the first
time, and if it's already been cached, it doesn't need to be re-wrapped.
This causes regression test
to fail on linux-ia64 and other platforms.
See bug 4947842 which is closed as a dup of this bug.