Examples of IJavaObject


Examples of org.eclipse.jdt.debug.core.IJavaObject

       
        private void addVariablesFromArray(List<VariableWrapper> variables, IJavaArray array) throws Exception {
            IJavaValue[] javaVals = array.getValues();
            for ( int k = 0; k < javaVals.length; k++ ) {
                IJavaValue mapEntry = javaVals[k];
                IJavaObject key = null;
                IJavaValue value = null;

                IVariable[] vars = mapEntry.getVariables();
                for ( int j = 0; j < vars.length; j++ ) {
                    IVariable var = vars[j];
                    if ("key".equals(var.getName())) {
                        key = (IJavaObject) var.getValue();
                    } else if ("value".equals(var.getName())) {
                        value = (IJavaValue) var.getValue();
                    }
                }
                if (value instanceof IJavaArray) {
                  List<VariableWrapper> nestedVariables = new ArrayList<VariableWrapper>();
                  addVariablesFromArray(nestedVariables, (IJavaArray)value);
                  IJavaVariable[] nestedResult = nestedVariables.toArray(new IJavaVariable[nestedVariables.size()]);
                  variables.add(new VariableWrapper("[" + k + "]", new ObjectWrapper(key, nestedResult)));
                } else {
                  variables.add(new VariableWrapper(key.getValueString(), value));
                }
            }
        }
View Full Code Here

Examples of org.eclipse.jdt.debug.core.IJavaObject

    public static IValue getValueByExpression(String expression, IValue value) {
        if (!(value instanceof IJavaObject)) {
            return null;
        }
        IJavaObject javaValue = (IJavaObject) value;
        try {
            IJavaType type = javaValue.getJavaType();
            if (!(type instanceof IJavaClassType)) {
                return null;
            }
            IJavaStackFrame stackFrame = getStackFrame(javaValue);
            if (stackFrame == null) {
                return null;
            }

            // find the project the snippets will be compiled in.
            ISourceLocator locator= javaValue.getLaunch().getSourceLocator();
            Object sourceElement= null;
            if (locator instanceof ISourceLookupDirector) {
                String[] sourcePaths = ((IJavaClassType) type).getSourcePaths(null);
                if (sourcePaths != null && sourcePaths.length > 0) {
                    sourceElement = ((ISourceLookupDirector) locator).getSourceElement(sourcePaths[0]);
View Full Code Here

Examples of org.eclipse.jdt.debug.core.IJavaObject

       
        private void addVariablesFromArray(List<VariableWrapper> variables, IJavaArray array) throws Exception {
            IJavaValue[] javaVals = array.getValues();
            for ( int k = 0; k < javaVals.length; k++ ) {
                IJavaValue mapEntry = javaVals[k];
                IJavaObject key = null;
                IJavaValue value = null;

                IVariable[] vars = mapEntry.getVariables();
                for ( int j = 0; j < vars.length; j++ ) {
                    IVariable var = vars[j];
                    if ("key".equals(var.getName())) {
                        key = (IJavaObject) var.getValue();
                    } else if ("value".equals(var.getName())) {
                        value = (IJavaValue) var.getValue();
                    }
                }
                if (value instanceof IJavaArray) {
                  List<VariableWrapper> nestedVariables = new ArrayList<VariableWrapper>();
                  addVariablesFromArray(nestedVariables, (IJavaArray)value);
                  IJavaVariable[] nestedResult = nestedVariables.toArray(new IJavaVariable[nestedVariables.size()]);
                  variables.add(new VariableWrapper("[" + k + "]", new ObjectWrapper(key, nestedResult)));
                } else {
                  variables.add(new VariableWrapper(key.getValueString(), value));
                }
            }
        }
View Full Code Here

Examples of org.eclipse.jdt.debug.core.IJavaObject

    } else if (value instanceof JDINullValue) {
      // null value can be cast to all non-primitive types (bug 31637).
      push(value);
    } else {
      IJavaObject classObject;
      if (fDimension == 0) {
        classObject = getClassObject(getType(fBaseTypeName));
      } else {
        classObject = getClassObject(getArrayType(
            Signature.createTypeSignature(fBaseTypeName, true),
            fDimension));
      }
      if (classObject == null) {
        throw new CoreException(
            new Status(
                IStatus.ERROR,
                JDIDebugPlugin.getUniqueIdentifier(),
                IStatus.OK,
                NLS.bind(InstructionsEvaluationMessages.Cast_No_class_object,
                        new String[] { typeName() }),
                null));
      }
      IJavaPrimitiveValue resultValue = (IJavaPrimitiveValue) classObject
          .sendMessage(IS_INSTANCE, IS_INSTANCE_SIGNATURE,
              new IJavaValue[] { value }, getContext()
                  .getThread(), false);
      if (!resultValue.getBooleanValue()) {
        throw new CoreException(
View Full Code Here

Examples of org.eclipse.jdt.debug.core.IJavaObject

      braces += "["; //$NON-NLS-1$
    }
    String signature = braces + typeSignature;
    // Force the class to be loaded, and record the class reference
    // for later use if there are multiple classes with the same name.
    IJavaObject classReference = getContext().classForName(signature);
    if (classReference == null) {
      throw new CoreException(new Status(IStatus.ERROR,
          JDIDebugPlugin.getUniqueIdentifier(), IStatus.OK,
          NLS.bind(
              InstructionsEvaluationMessages.Instruction_No_type,
              new String[] { qualifiedName }), null));
    }
    IJavaType[] types = getVM().getJavaTypes(qualifiedName);
    checkTypes(types, qualifiedName);
    if (types.length == 1) {
      // Found only one class.
      return (IJavaArrayType) types[0];
    }
    // Found many classes, look for the right one for this scope.
    for (IJavaType type : types) {
      if (classReference.equals(getClassObject(type))) {
        return (IJavaArrayType) type;
      }
    }

    // At this point a very strange thing has happened,
View Full Code Here

Examples of org.eclipse.jdt.debug.core.IJavaObject

    IJavaType[] types = getVM().getJavaTypes(tname);
    if (types != null && types.length > 0) {
      // find the one with the right class loader
      for (IJavaType type2 : types) {
        IJavaReferenceType type = (IJavaReferenceType) type2;
        IJavaObject cloader = type.getClassLoaderObject();
        if (isCompatibleLoader(loader, cloader)) {
          return type.getClassObject();
        }
      }
    }
View Full Code Here

Examples of org.eclipse.jdt.debug.core.IJavaObject

    }
    if (recLoader.equals(otherLoader)) {
      return true;
    }
    // check parent loaders
    IJavaObject parent = getParentLoader(recLoader);
    while (parent != null) {
      if (parent.equals(otherLoader)) {
        return true;
      }
      parent = getParentLoader(parent);
    }
    return false;
View Full Code Here

Examples of org.eclipse.jdt.debug.core.IJavaObject

              // *explicit* evaluation
              InvocationException invocationException = (InvocationException) exception
                  .getStatus().getException();
              ObjectReference exObject = invocationException
                  .exception();
              IJavaObject modelObject = (IJavaObject) JDIValue
                  .createValue(
                      (JDIDebugTarget) getDebugTarget(),
                      exObject);
              try {
                modelObject
                    .sendMessage(
                        "printStackTrace", "()V", null, jt, false); //$NON-NLS-1$ //$NON-NLS-2$
              } catch (DebugException e) {
                // unable to print stack trace
              }
View Full Code Here

Examples of org.eclipse.jdt.debug.core.IJavaObject

  /**
   * @see org.eclipse.jdt.internal.debug.eval.ast.instructions.Instruction#execute()
   */
  @Override
  public void execute() throws CoreException {
    IJavaObject exception = (IJavaObject) popValue();
    final IJavaThread javaThread = getContext().getThread();
    javaThread.stop(exception);
    javaThread.queueRunnable(new Runnable() {
      public void run() {
        try {
View Full Code Here

Examples of org.eclipse.jdt.debug.core.IJavaObject

    }
    return true;
  }

  public void run(IJavaThread thread, IProgressMonitor monitor) {
    IJavaObject codeSnippetInstance = null;
    try {
      codeSnippetInstance = newInstance(getCodeSnippetClassName());
      initializeLocals(codeSnippetInstance);
      codeSnippetInstance.sendMessage(RUN_METHOD,  "()V", null, getThread(), false); //$NON-NLS-1$
      restoreLocals(codeSnippetInstance);

      // now retrieve the description of the result
      IVariable[] fields = codeSnippetInstance.getVariables();
      IJavaVariable resultValue = null;
      IJavaVariable resultType = null;
      for (IVariable field : fields) {
        if (field.getName().equals(RESULT_TYPE_FIELD)) {
          resultType = (IJavaVariable) field;
        }
        if (field.getName().equals(RESULT_VALUE_FIELD)) {
          resultValue = (IJavaVariable) field;
        }
      }
      IJavaValue result = convertResult((IJavaClassObject) resultType.getValue(), (IJavaValue) resultValue.getValue());
      getResult().setValue(result);
    } catch (DebugException e) {
      getResult().setException(e);

      Throwable underlyingException = e.getStatus().getException();
      if (underlyingException instanceof InvocationException) {
        ObjectReference theException = ((InvocationException) underlyingException)
            .exception();
        if (theException != null) {
          try {
            try {
              IJavaObject v = (IJavaObject) JDIValue.createValue(
                  (JDIDebugTarget) getDebugTarget(),
                  theException);
              v.sendMessage(
                  "printStackTrace", "()V", null, getThread(), false); //$NON-NLS-2$ //$NON-NLS-1$
            } catch (DebugException de) {
              JDIDebugPlugin.log(de);
            }
          } catch (RuntimeException re) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.