1 11 package org.eclipse.jdt.internal.debug.core.model; 12 13 14 import com.ibm.icu.text.MessageFormat; 15 16 import org.eclipse.debug.core.DebugException; 17 import org.eclipse.jdt.debug.core.IJavaArray; 18 import org.eclipse.jdt.debug.core.IJavaArrayType; 19 import org.eclipse.jdt.debug.core.IJavaType; 20 21 import com.sun.jdi.ArrayReference; 22 import com.sun.jdi.ArrayType; 23 import com.sun.jdi.ClassNotLoadedException; 24 import com.sun.jdi.Type; 25 26 29 public class JDIArrayType extends JDIReferenceType implements IJavaArrayType { 30 31 35 public JDIArrayType(JDIDebugTarget target, ArrayType type) { 36 super(target, type); 37 } 38 41 public IJavaArray newInstance(int size) throws DebugException { 42 try { 43 ArrayReference ar = ((ArrayType)getUnderlyingType()).newInstance(size); 44 return (IJavaArray)JDIValue.createValue(getJavaDebugTarget(), ar); 45 } catch (RuntimeException e) { 46 targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIArrayType_exception_while_creating_new_instance_of_array, new String [] {e.toString()}), e); 47 } 48 return null; 51 } 52 53 56 public IJavaType getComponentType() throws DebugException { 57 try { 58 Type type = ((ArrayType)getUnderlyingType()).componentType(); 59 return JDIType.createType(getJavaDebugTarget(), type); 60 } catch (ClassNotLoadedException e) { 61 targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIArrayType_exception_while_retrieving_component_type_of_array, new String [] {e.toString()}), e); 62 } catch (RuntimeException e) { 63 targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIArrayType_exception_while_retrieving_component_type_of_array, new String [] {e.toString()}), e); 64 } 65 return null; 68 } 69 70 } 71 72 | Popular Tags |