use of com.sun.jdi.ArrayReference in project jdk8u_jdk by JetBrains.
the class OomDebugTest method test2.
/*
* Test case: Array reference as method parameter.
*/
// called via reflection
@SuppressWarnings("unused")
private void test2() throws Exception {
System.out.println("DEBUG: ------------> Running test2");
try {
Field field = targetClass.fieldByName("byteArray");
ArrayType arrType = (ArrayType) field.type();
for (int i = 0; i < 15; i++) {
ArrayReference byteArrayVal = arrType.newInstance(3000000);
if (byteArrayVal.isCollected()) {
System.out.println("DEBUG: Object got GC'ed before we can use it. NO-OP.");
continue;
}
invoke("testPrimitive", "([B)V", byteArrayVal);
}
} catch (VMOutOfMemoryException e) {
defaultHandleOOMFailure(e);
}
}
use of com.sun.jdi.ArrayReference in project intellij-community by JetBrains.
the class ArrayRenderer method buildChildren.
public void buildChildren(Value value, ChildrenBuilder builder, EvaluationContext evaluationContext) {
DebuggerManagerThreadImpl.assertIsManagerThread();
List<DebuggerTreeNode> children = new ArrayList<>();
NodeManagerImpl nodeManager = (NodeManagerImpl) builder.getNodeManager();
NodeDescriptorFactory descriptorFactory = builder.getDescriptorManager();
if (!myForced) {
builder.initChildrenArrayRenderer(this);
}
ArrayReference array = (ArrayReference) value;
if (array.length() > 0) {
int added = 0;
if (ENTRIES_LIMIT > END_INDEX - START_INDEX + 1) {
ENTRIES_LIMIT = END_INDEX - START_INDEX;
}
if (ENTRIES_LIMIT <= 0) {
ENTRIES_LIMIT = 1;
}
if (array.length() - 1 >= START_INDEX) {
int start = START_INDEX;
int end = array.length() - 1 < END_INDEX ? array.length() - 1 : END_INDEX;
int idx;
for (idx = start; idx <= end; idx++) {
if (ViewsGeneralSettings.getInstance().HIDE_NULL_ARRAY_ELEMENTS && elementIsNull(array, idx))
continue;
DebuggerTreeNode arrayItemNode = nodeManager.createNode(descriptorFactory.getArrayItemDescriptor(builder.getParentDescriptor(), array, idx), evaluationContext);
if (arrayItemNode == null)
continue;
//if(added >= (ENTRIES_LIMIT + 1)/ 2) break;
children.add(arrayItemNode);
added++;
}
start = idx;
//List<DebuggerTreeNode> childrenTail = new ArrayList<DebuggerTreeNode>();
//for (idx = end; idx >= start; idx--) {
// DebuggerTreeNode arrayItemNode = nodeManager.createNode(descriptorFactory.getArrayItemDescriptor(builder.getParentDescriptor(), array, idx), evaluationContext);
//
// if (arrayItemNode == null) continue;
// if (ViewsGeneralSettings.getInstance().HIDE_NULL_ARRAY_ELEMENTS && ((ValueDescriptorImpl)arrayItemNode.getDescriptor()).isNull()) continue;
// if(added >= ENTRIES_LIMIT) break;
// childrenTail.add(arrayItemNode);
// added++;
//}
//array is printed in the following way
// ...
// items1...itemENTRIES_LIMIT/2
// ...
// itemENTRIES_LIMIT/2+1...itemENTRIES_LIMIT
// ...
//when itemENTRIES_LIMIT/2+1...itemENTRIES_LIMIT set is empty, we should not add middle "..." node
//if(idx >= start && !(ENTRIES_LIMIT == 1 && END_INDEX < array.length())) {
// children.add(nodeManager.createMessageNode(new MessageDescriptor(MORE_ELEMENTS, MessageDescriptor.SPECIAL)));
//}
//for (ListIterator<DebuggerTreeNode> iterator = childrenTail.listIterator(childrenTail.size()); iterator.hasPrevious();) {
// DebuggerTreeNode debuggerTreeNode = iterator.previous();
// children.add(debuggerTreeNode);
//}
}
if (added == 0) {
if (START_INDEX == 0 && array.length() - 1 <= END_INDEX) {
children.add(nodeManager.createMessageNode(MessageDescriptor.ALL_ELEMENTS_IN_RANGE_ARE_NULL));
} else {
children.add(nodeManager.createMessageNode(DebuggerBundle.message("message.node.all.array.elements.null", START_INDEX, END_INDEX)));
}
} else {
if (!myForced && END_INDEX < array.length() - 1) {
//children.add(nodeManager.createMessageNode(new MessageDescriptor(MORE_ELEMENTS, MessageDescriptor.SPECIAL)));
builder.setRemaining(array.length() - 1 - END_INDEX);
}
}
}
builder.setChildren(children);
}
use of com.sun.jdi.ArrayReference in project che by eclipse.
the class JdiValueImpl method getVariables.
@Override
public JdiVariable[] getVariables() {
if (variables == null) {
if (isPrimitive()) {
variables = new JdiVariable[0];
} else {
if (isArray()) {
ArrayReference array = (ArrayReference) value;
int length = array.length();
variables = new JdiVariable[length];
for (int i = 0; i < length; i++) {
variables[i] = new JdiArrayElementImpl(i, array.getValue(i));
}
} else {
ObjectReference object = (ObjectReference) value;
ReferenceType type = object.referenceType();
List<Field> fields = type.allFields();
variables = new JdiVariable[fields.size()];
int i = 0;
for (Field f : fields) {
variables[i++] = new JdiFieldImpl(f, object);
}
// See JdiFieldImpl#compareTo(JdiFieldImpl).
Arrays.sort(variables);
}
}
}
return variables;
}
Aggregations