Reputation: 300
I have found Eclipse Collections very useful. Especially collections for primitive types (for example: IntObjectHashMap). Unfortunately there is a problem with rendering these collections in IntelliJ IDEA debugger.
Let's have a sample code:
import org.eclipse.collections.impl.map.mutable.primitive.IntObjectHashMap;
import java.util.HashMap;
public class Test {
public static void main(String[] args) {
IntObjectHashMap<String> eclipseMap = new IntObjectHashMap<>(4);
eclipseMap.put(1, "one");
eclipseMap.put(2, "two");
HashMap<Integer, String> hashMap = new HashMap<>(4);
hashMap.put(1, "one");
hashMap.put(2, "two");
System.out.println("" + eclipseMap);
System.out.println("" + hashMap);
}
}
Here we have a debugger variables view:
As we can see JDK HashMap is rendered perfectly, but IntObjectHashMap
Eclipse Collection is not.
The situation is even worse when I drop down values for Eclipse Collection:
As we can see - there is no one
element on the values list.
You can say: OK, as a workaround, you can use standard toString
renderer available in IntelliJ:
Unfortunately in my case it is not the case since my collections have tens of millions of elements.
So my question is:
Anybody know a place / a project where I can find IntelliJ Java type renderers for Eclipse Collections for primitive types?
Upvotes: 2
Views: 382
Reputation: 300
@Egor answer is almost perfect :) It works great, but for small collections only.
Let me describe the problem with @Egor solution. Let's have a look at the example:
import org.eclipse.collections.impl.map.mutable.primitive.IntObjectHashMap;
public class Test3 {
public static void main(String[] args) {
final int CAPACITY = 20_000_000;
IntObjectHashMap<String> eclipseMap = new IntObjectHashMap<>();
for (int i = 0; i < CAPACITY; i++) {
eclipseMap.put(i, Integer.toString(i));
}
System.out.println("Hello world.");
}
}
Now run it - everything is OK.
Now put the breakpoint at line System.out.println("Hello world.")
and execute this program in the debug mode.
We will be slapped by OutOfMemoryError (because IntelliJ calls toString method on this collection):
To solve this problem we need to set When rendering a node
-> Use following expression
- for example like this:
Upvotes: 3