use of com.sun.jdi.ArrayType 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.ArrayType in project che by eclipse.
the class Evaluator method isAssignable.
private boolean isAssignable(Type from, Type to) {
if (from.equals(to)) {
return true;
}
if (from instanceof BooleanType) {
return to instanceof BooleanType;
}
if (to instanceof BooleanType) {
return false;
}
if (from instanceof PrimitiveType) {
return to instanceof PrimitiveType;
}
if (to instanceof PrimitiveType) {
return false;
}
if (from instanceof ArrayType) {
if (to instanceof ArrayType) {
Type fromArrayComponent;
Type toArrayComponent;
try {
fromArrayComponent = ((ArrayType) from).componentType();
toArrayComponent = ((ArrayType) to).componentType();
} catch (ClassNotLoadedException e) {
return false;
}
if (fromArrayComponent instanceof PrimitiveType) {
return fromArrayComponent.equals(toArrayComponent);
}
return !(toArrayComponent instanceof PrimitiveType) && isAssignable(fromArrayComponent, toArrayComponent);
}
return to.name().equals("java.lang.Object");
}
if (from instanceof ClassType) {
ClassType superClass = ((ClassType) from).superclass();
if (superClass != null && isAssignable(superClass, to)) {
return true;
}
for (InterfaceType interfaceType : ((ClassType) from).interfaces()) {
if (isAssignable(interfaceType, to)) {
return true;
}
}
}
for (InterfaceType interfaceType : ((InterfaceType) from).subinterfaces()) {
if (isAssignable(interfaceType, to)) {
return true;
}
}
return false;
}
use of com.sun.jdi.ArrayType in project intellij-community by JetBrains.
the class JumpToTypeSourceAction method getObjectType.
@Nullable
private static ReferenceType getObjectType(@NotNull ReferenceType ref) {
if (!(ref instanceof ArrayType)) {
return ref;
}
final String elementTypeName = ref.name().replace("[]", "");
final VirtualMachine vm = ref.virtualMachine();
final List<ReferenceType> referenceTypes = vm.classesByName(elementTypeName);
if (referenceTypes.size() == 1) {
return referenceTypes.get(0);
}
return null;
}
Aggregations