Java 类com.sun.jdi.Field 实例源码

项目:jdk8u_jdk    文件:OomDebugTest.java   
@SuppressWarnings("unused") // called via reflection
private void test1() throws Exception {
    System.out.println("DEBUG: ------------> Running test1");
    try {
        Field field = targetClass.fieldByName("fooCls");
        ClassType clsType = (ClassType)field.type();
        Method constructor = getConstructorForClass(clsType);
        for (int i = 0; i < 15; i++) {
            @SuppressWarnings({ "rawtypes", "unchecked" })
            ObjectReference objRef = clsType.newInstance(mainThread,
                                                         constructor,
                                                         new ArrayList(0),
                                                         ObjectReference.INVOKE_NONVIRTUAL);
            if (objRef.isCollected()) {
                System.out.println("DEBUG: Object got GC'ed before we can use it. NO-OP.");
                continue;
            }
            invoke("testMethod", "(LOomDebugTestTarget$FooCls;)V", objRef);
        }
    } catch (InvocationException e) {
        handleFailure(e);
    }
}
项目:jdk8u-jdk    文件:OomDebugTest.java   
@SuppressWarnings("unused") // called via reflection
private void test1() throws Exception {
    System.out.println("DEBUG: ------------> Running test1");
    try {
        Field field = targetClass.fieldByName("fooCls");
        ClassType clsType = (ClassType)field.type();
        Method constructor = getConstructorForClass(clsType);
        for (int i = 0; i < 15; i++) {
            @SuppressWarnings({ "rawtypes", "unchecked" })
            ObjectReference objRef = clsType.newInstance(mainThread,
                                                         constructor,
                                                         new ArrayList(0),
                                                         ObjectReference.INVOKE_NONVIRTUAL);
            if (objRef.isCollected()) {
                System.out.println("DEBUG: Object got GC'ed before we can use it. NO-OP.");
                continue;
            }
            invoke("testMethod", "(LOomDebugTestTarget$FooCls;)V", objRef);
        }
    } catch (InvocationException e) {
        handleFailure(e);
    }
}
项目:jdk8u-jdk    文件:OomDebugTest.java   
@SuppressWarnings("unused") // called via reflection
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);
    }
}
项目:openjdk-jdk10    文件:ReferenceTypeImpl.java   
void addVisibleFields(List<Field> visibleList, Map<String, Field> visibleTable, List<String> ambiguousNames) {
    for (Field field : visibleFields()) {
        String name = field.name();
        if (!ambiguousNames.contains(name)) {
            Field duplicate = visibleTable.get(name);
            if (duplicate == null) {
                visibleList.add(field);
                visibleTable.put(name, field);
            } else if (!field.equals(duplicate)) {
                ambiguousNames.add(name);
                visibleTable.remove(name);
                visibleList.remove(duplicate);
            } else {
                // identical field from two branches; do nothing
            }
        }
    }
}
项目:openjdk-jdk10    文件:OomDebugTest.java   
@SuppressWarnings("unused") // called via reflection
private void test1() throws Exception {
    System.out.println("DEBUG: ------------> Running test1");
    try {
        Field field = targetClass.fieldByName("fooCls");
        ClassType clsType = (ClassType)field.type();
        Method constructor = getConstructorForClass(clsType);
        for (int i = 0; i < 15; i++) {
            @SuppressWarnings({ "rawtypes", "unchecked" })
            ObjectReference objRef = clsType.newInstance(mainThread,
                                                         constructor,
                                                         new ArrayList(0),
                                                         ObjectReference.INVOKE_NONVIRTUAL);
            if (objRef.isCollected()) {
                System.out.println("DEBUG: Object got GC'ed before we can use it. NO-OP.");
                continue;
            }
            invoke("testMethod", "(LOomDebugTestTarget$FooCls;)V", objRef);
        }
    } catch (InvocationException e) {
        handleFailure(e);
    }
}
项目:openjdk-jdk10    文件:OomDebugTest.java   
@SuppressWarnings("unused") // called via reflection
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);
    }
}
项目:openjdk9    文件:ReferenceTypeImpl.java   
void addVisibleFields(List visibleList, Map visibleTable, List ambiguousNames) {
    List list = visibleFields();
    Iterator iter = list.iterator();
    while (iter.hasNext()) {
        Field field = (Field)iter.next();
        String name = field.name();
        if (!ambiguousNames.contains(name)) {
            Field duplicate = (Field)visibleTable.get(name);
            if (duplicate == null) {
                visibleList.add(field);
                visibleTable.put(name, field);
            } else if (!field.equals(duplicate)) {
                ambiguousNames.add(name);
                visibleTable.remove(name);
                visibleList.remove(duplicate);
            } else {
                // identical field from two branches; do nothing
            }
        }
    }
}
项目:jdk8u_jdk    文件:OomDebugTest.java   
@SuppressWarnings("unused") // called via reflection
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);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:OomDebugTest.java   
@SuppressWarnings("unused") // called via reflection
private void test1() throws Exception {
    System.out.println("DEBUG: ------------> Running test1");
    try {
        Field field = targetClass.fieldByName("fooCls");
        ClassType clsType = (ClassType)field.type();
        Method constructor = getConstructorForClass(clsType);
        for (int i = 0; i < 15; i++) {
            @SuppressWarnings({ "rawtypes", "unchecked" })
            ObjectReference objRef = clsType.newInstance(mainThread,
                                                         constructor,
                                                         new ArrayList(0),
                                                         ObjectReference.INVOKE_NONVIRTUAL);
            if (objRef.isCollected()) {
                System.out.println("DEBUG: Object got GC'ed before we can use it. NO-OP.");
                continue;
            }
            invoke("testMethod", "(LOomDebugTestTarget$FooCls;)V", objRef);
        }
    } catch (InvocationException e) {
        handleFailure(e);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:OomDebugTest.java   
@SuppressWarnings("unused") // called via reflection
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);
    }
}
项目:intellij-ce-playground    文件:ThisEvaluator.java   
@Nullable
@SuppressWarnings({"HardCodedStringLiteral"})
private static ObjectReference getOuterObject(ObjectReference objRef) {
  if (objRef == null) {
    return null;
  }
  List<Field> list = objRef.referenceType().fields();
  for (final Field field : list) {
    final String name = field.name();
    if (name != null && name.startsWith("this$")) {
      final ObjectReference rv = (ObjectReference)objRef.getValue(field);
      if (rv != null) {
        return rv;
      }
    }
  }
  return null;
}
项目:form-follows-function    文件:F3ObjectReference.java   
public int getFlagWord(Field field) {
    F3ReferenceType clazz = (F3ReferenceType)referenceType();
    // could this be a java field inherited by an f3 class??
    if (!clazz.isF3Type()) {
        return 0;
    }
    Field jdiField = F3Wrapper.unwrap(field); 
    String jdiFieldName = jdiField.name();
    String vflgFieldName = "VFLG" + jdiFieldName;

    Field  vflgField = clazz.fieldByName(vflgFieldName);
    if (vflgField == null) {
        // not all fields have a VFLG, eg, a private field that isn't accessed
        return 0;
    }
    Value vflgValue = underlying().getValue(F3Wrapper.unwrap(vflgField));
    return((ShortValue)vflgValue).value();
}
项目:tools-idea    文件:ThisEvaluator.java   
@Nullable
@SuppressWarnings({"HardCodedStringLiteral"})
private static ObjectReference getOuterObject(ObjectReference objRef) {
  if (objRef == null) {
    return null;
  }
  List<Field> list = objRef.referenceType().fields();
  for (final Field field : list) {
    final String name = field.name();
    if (name != null && name.startsWith("this$")) {
      final ObjectReference rv = (ObjectReference)objRef.getValue(field);
      if (rv != null) {
        return rv;
      }
    }
  }
  return null;
}
项目:codehint    文件:SideEffectHandler.java   
private Set<IJavaObject> getAllReachableObjects(SubMonitor monitor) {
    try {
        Set<IJavaObject> objs = new HashSet<IJavaObject>();
        getReachableObjects(stack.getThis(), objs);
        for (IVariable var: stack.getLocalVariables())
            getReachableObjects((IJavaValue)var.getValue(), objs);
        for (ReferenceType type: getAllLoadedTypes(stack)) {
            for (Field field: type.allFields())
                if (field.isStatic() && isUsefulStaticDFSField(type.name(), field))
                    getReachableObjects(JDIValue.createValue((JDIDebugTarget)stack.getDebugTarget(), type.getValue(field)), objs);
            monitor.worked(1);
        }
        return objs;
    } catch (DebugException e) {
        throw new RuntimeException(e);
    }
}
项目:incubator-netbeans    文件:VisualDebuggerListener.java   
private void stopDebuggerRemoteService(JPDADebugger d) {
    ClassObjectReference serviceClass = RemoteServices.getServiceClass(d, RemoteServices.ServiceType.AWT);
    if (serviceClass == null) {
        return ;
    }
    try {
        ReferenceType serviceType = serviceClass.reflectedType();
        Field awtAccessLoop = serviceType.fieldByName("awtAccessLoop"); // NOI18N
        if (awtAccessLoop != null) {
            ((ClassType) serviceType).setValue(awtAccessLoop, serviceClass.virtualMachine().mirrorOf(false));
        }
        serviceClass.enableCollection();
    } catch (VMDisconnectedException vdex) {
        // Ignore
    } catch (Exception ex) {
        Exceptions.printStackTrace(ex);
    }
}
项目:incubator-netbeans    文件:ObjectFieldVariable.java   
private ObjectFieldVariable (
    JPDADebuggerImpl debugger,
    ObjectReference value,
    //String className,
    Field field,
    String parentID,
    ObjectReference objectReference
) {
    super (
        debugger,
        value,
        getID(parentID, field)
    );
    this.field = field;
    //this.className = className;
    this.objectReference = objectReference;
}
项目:incubator-netbeans    文件:ObjectFieldVariable.java   
protected ObjectFieldVariable (
    JPDADebuggerImpl debugger, 
    ObjectReference value, 
    //String className,
    Field field,
    String parentID,
    String genericSignature,
    ObjectReference objectReference
) {
    this (
        debugger,
        value,
        field,
        parentID,
        objectReference
    );
    this.genericSignature = genericSignature;
}
项目:incubator-netbeans    文件:ObjectFieldVariable.java   
public ObjectFieldVariable (
    JPDADebuggerImpl debugger,
    Field field,
    String parentID,
    String genericSignature,
    ObjectReference objectReference
) {
    this (
        debugger,
        null,
        field,
        parentID,
        genericSignature,
        objectReference
    );
    this.valueSet = false;
}
项目:incubator-netbeans    文件:FieldVariable.java   
public FieldVariable (
    JPDADebuggerImpl debugger,
    PrimitiveValue value,
//    String className,
    Field field,
    String parentID,
    ObjectReference objectReference    // instance or null for static fields
) {
    super (
        debugger, 
        value, 
        getID(parentID, field)
    );
    this.field = field;
    //this.className = className;
    this.objectReference = objectReference;
}
项目:incubator-netbeans    文件:InvocationExceptionTranslated.java   
private String getMessageFromField() throws InternalExceptionWrapper,
                                            VMDisconnectedExceptionWrapper,
                                            ObjectCollectedExceptionWrapper,
                                            ClassNotPreparedExceptionWrapper {
    List<ReferenceType> throwableClasses = VirtualMachineWrapper.classesByName(exeption.virtualMachine(), Throwable.class.getName());
    if (throwableClasses.isEmpty()) {
        return null;
    }
    Field detailMessageField = ReferenceTypeWrapper.fieldByName(throwableClasses.get(0), "detailMessage");
    if (detailMessageField != null) {
        Value messageValue = ObjectReferenceWrapper.getValue(exeption, detailMessageField);
        if (messageValue instanceof StringReference) {
            message = StringReferenceWrapper.value((StringReference) messageValue);
            if (invocationMessage != null) {
                return invocationMessage + ": " + message;
            } else {
                return message;
            }
        }
    }
    return null;
}
项目:incubator-netbeans    文件:EvaluatorVisitor.java   
@Override
public Value getValue(Field field) {
    String name = field.name();
    for (ReferenceType t : types) {
        if (field.equals(t.fieldByName(name))) {
            return t.getValue(field);
        }
    }
    return types[0].getValue(field); // Likely throws some appropriate error.
}
项目:incubator-netbeans    文件:EvaluatorVisitor.java   
@Override
public Map<Field, Value> getValues(List<? extends Field> list) {
    List[] listByTypes = new List[types.length];
    for (int i = 0; i < types.length; i++) {
        listByTypes[i] = new ArrayList();
        ReferenceType t = types[i];
        for (Field field : list) {
            String name = field.name();
            if (field.equals(t.fieldByName(name))) {
                listByTypes[i].add(field);
            }
        }
    }
    Map<Field, Value> map = null;
    Map<Field, Value> singleMap = null;
    for (int i = 0; i < types.length; i++) {
        if (!listByTypes[i].isEmpty()) {
            Map<Field, Value> tmap = types[i].getValues(listByTypes[i]);
            if (singleMap == null) {
                singleMap = tmap;
            } else {
                if (map == null) {
                    map = new HashMap<Field, Value>(list.size());
                    map.putAll(singleMap);
                }
                map.putAll(tmap);
            }
        }
    }
    if (map != null) {
        return map;
    } else {
        return singleMap;
    }
}
项目:openjdk-jdk10    文件:EventRequestManagerImpl.java   
/**
 * Constructor.
 */
EventRequestManagerImpl(VirtualMachine vm) {
    super(vm);
    java.lang.reflect.Field[] ekinds =
        JDWP.EventKind.class.getDeclaredFields();
    int highest = 0;
    for (int i = 0; i < ekinds.length; ++i) {
        int val;
        try {
            val = ekinds[i].getInt(null);
        } catch (IllegalAccessException exc) {
            throw new RuntimeException("Got: " + exc);
        }
        if (val > highest) {
            highest = val;
        }
    }
    requestLists = new List[highest+1];
    for (int i=0; i <= highest; i++) {
        requestLists[i] = Collections.synchronizedList(new ArrayList<>());
    }
}
项目:openjdk-jdk10    文件:ReferenceTypeImpl.java   
void addAllFields(List<Field> fieldList, Set<ReferenceType> typeSet) {
    /* Continue the recursion only if this type is new */
    if (!typeSet.contains(this)) {
        typeSet.add(this);

        /* Add local fields */
        fieldList.addAll(fields());

        /* Add inherited fields */
        List<? extends ReferenceType> types = inheritedTypes();
        Iterator<? extends ReferenceType> iter = types.iterator();
        while (iter.hasNext()) {
            ReferenceTypeImpl type = (ReferenceTypeImpl)iter.next();
            type.addAllFields(fieldList, typeSet);
        }
    }
}
项目:java-debug    文件:SetVariableRequestHandler.java   
private Value handleSetValueForObject(String name, String belongToClass, String valueString,
        ObjectReference container, Map<String, Object> options) throws InvalidTypeException, ClassNotLoadedException {
    Value newValue;
    if (container instanceof ArrayReference) {
        ArrayReference array = (ArrayReference) container;
        Type eleType = ((ArrayType) array.referenceType()).componentType();
        newValue = setArrayValue(array, eleType, Integer.parseInt(name), valueString, options);
    } else {
        if (StringUtils.isBlank(belongToClass)) {
            Field field = container.referenceType().fieldByName(name);
            if (field != null) {
                if (field.isStatic()) {
                    newValue = this.setStaticFieldValue(container.referenceType(), field, name, valueString, options);
                } else {
                    newValue = this.setObjectFieldValue(container, field, name, valueString, options);
                }
            } else {
                throw new IllegalArgumentException(
                        String.format("SetVariableRequest: Variable %s cannot be found.", name));
            }
        } else {
            newValue = setFieldValueWithConflict(container, container.referenceType().allFields(), name, belongToClass, valueString, options);
        }
    }
    return newValue;
}
项目:java-debug    文件:SetVariableRequestHandler.java   
private Value setFieldValueWithConflict(ObjectReference obj, List<Field> fields, String name, String belongToClass,
                                        String value, Map<String, Object> options) throws ClassNotLoadedException, InvalidTypeException {
    Field field;
    // first try to resolve field by fully qualified name
    List<Field> narrowedFields = fields.stream().filter(TypeComponent::isStatic)
            .filter(t -> t.name().equals(name) && t.declaringType().name().equals(belongToClass))
            .collect(Collectors.toList());
    if (narrowedFields.isEmpty()) {
        // second try to resolve field by formatted name
        narrowedFields = fields.stream().filter(TypeComponent::isStatic)
                .filter(t -> t.name().equals(name)
                        && context.getVariableFormatter().typeToString(t.declaringType(), options).equals(belongToClass))
                .collect(Collectors.toList());
    }
    if (narrowedFields.size() == 1) {
        field = narrowedFields.get(0);
    } else {
        throw new UnsupportedOperationException(String.format("SetVariableRequest: Name conflicted for %s.", name));
    }
    return field.isStatic() ? setStaticFieldValue(field.declaringType(), field, name, value, options)
            : this.setObjectFieldValue(obj, field, name, value, options);
}
项目:acdebugger    文件:BreakpointProcessor.java   
private void checkConditions(ThreadReference threadRef, Field contextField) throws Exception {
  ArrayReference contextArray = getContextArray(contextField, threadRef);
  int size = contextArray.getValues().size();

  for (int i = 0; i < size; i++) {
    ObjectReference context = (ObjectReference) contextArray.getValues().get(i);
    if (context != null
        && (hasBundlePerms(context)
            || hasBundleProtectionDomain(context)
            || hasBlueprintProtectionDomain(context))) {
      missingPerms.put(getBundleLocation(context), getPermissionString(threadRef));
    }
  }

  if (missingPerms.isEmpty()) {
    System.out.println("this is wrong");
  }
}
项目:intellij-ce-playground    文件:InspectAction.java   
private boolean canInspect(ValueDescriptorImpl descriptor, DebuggerContextImpl context) {
  DebuggerSession session = context.getDebuggerSession();
  if (session == null || !session.isPaused()) return false;

  boolean isField = descriptor instanceof FieldDescriptorImpl;

  if(descriptor instanceof WatchItemDescriptor) {
    Modifier modifier = ((WatchItemDescriptor)descriptor).getModifier();
    if(modifier == null || !modifier.canInspect()) return false;
    isField = modifier instanceof Field;
  }

  if (isField) { // check if possible
    if (!context.getDebugProcess().canWatchFieldModification()) {
      Messages.showMessageDialog(
        context.getProject(),
        DebuggerBundle.message("error.modification.watchpoints.not.supported"),
        ActionsBundle.actionText(DebuggerActions.INSPECT),
        Messages.getInformationIcon()
      );
      return false;
    }
  }
  return true;
}
项目:form-follows-function    文件:F3ReferenceType.java   
public F3Field fieldByName(String name) {
    // There could be both an F3 field $xxx and a java field xxx
    Field javaField = underlying().fieldByName(name);
    Field f3Field = underlying().fieldByName("$" + name);
    if (javaField == null) {
        if (f3Field == null ) {
            // an ivar that is a referenced in an outer class can be prefixed with
            //  'classname$'
            return null;
        }
        // we'll return f3Field
    } else {
        if (f3Field != null) {
            // we found both name and $name
            return null;
        }
        f3Field = javaField;
    }
    return F3Wrapper.wrap(virtualMachine(), f3Field);
}
项目:form-follows-function    文件:F3ReferenceType.java   
public int getFlagWord(Field field) {
    // could this be a java field inherited by an f3 class??
    if (!isF3Type()) {
        return 0;
    }
    if (scriptType == null) {
        ReferenceType jdiRefType = underlying();
        String jdiRefTypeName = jdiRefType.name();
        String scriptClassName = jdiRefTypeName;
        int lastDot = scriptClassName.lastIndexOf('.');
        if (lastDot != -1) {
            scriptClassName = scriptClassName.substring(lastDot + 1);
        }
        scriptClassName = jdiRefTypeName + "$" + scriptClassName + "$Script";
        List<ReferenceType> rtx =  virtualMachine().classesByName(scriptClassName);
        if (rtx.size() != 1) {
            System.out.println("--F3JDI Error: Can't find the class: " + scriptClassName);
            return 0;
        }
        scriptType = rtx.get(0);
    }
    Field jdiField = F3Wrapper.unwrap(field); 
    String jdiFieldName = jdiField.name();
    String vflgFieldName = "VFLG" + jdiFieldName;

    Field  vflgField = scriptType.fieldByName(vflgFieldName);
    if (vflgField == null) {
        // not all fields have a VFLG, eg, a private field that isn't accessed
        return 0;
    }
    Value vflgValue = F3Wrapper.unwrap(scriptType).getValue(F3Wrapper.unwrap(vflgField));
    return((ShortValue)vflgValue).value();
}
项目:tools-idea    文件:InspectAction.java   
private boolean canInspect(ValueDescriptorImpl descriptor, DebuggerContextImpl context) {
  DebuggerSession session = context.getDebuggerSession();
  if (session == null || !session.isPaused()) return false;

  boolean isField = descriptor instanceof FieldDescriptorImpl;

  if(descriptor instanceof WatchItemDescriptor) {
    Modifier modifier = ((WatchItemDescriptor)descriptor).getModifier();
    if(modifier == null || !modifier.canInspect()) return false;
    isField = modifier instanceof Field;
  }

  if (isField) { // check if possible
    if (!context.getDebugProcess().canWatchFieldModification()) {
      Messages.showMessageDialog(
        context.getProject(),
        DebuggerBundle.message("error.modification.watchpoints.not.supported"),
        ActionsBundle.actionText(DebuggerActions.INSPECT),
        Messages.getInformationIcon()
      );
      return false;
    }
  }
  return true;
}
项目:jive    文件:StaticModelDelegateForJDI.java   
void createField(final Field field, final int lineFrom, final int lineTo, final ITypeNode typeNode)
{
  // this field never generates a field read or field write event
  if (!filter.acceptsType(field.declaringType()) || !filter.acceptsField(field))
  {
    return;
  }
  ITypeNodeRef fieldTypeNode;
  try
  {
    fieldTypeNode = upstream.resolveType(field.type().signature(), field.typeName());
  }
  catch (final ClassNotLoadedException e)
  {
    fieldTypeNode = modelFactory().lookupTypeRefByName(field.typeName());
  }
  typeNode.addDataMember(field.name(), lineFrom, lineTo, fieldTypeNode, NO_JDI,
      createModifiers(field), createVisibility(field),
      fieldTypeNode instanceof ITypeNode ? ((ITypeNode) fieldTypeNode).defaultValue() : model
          .valueFactory().createNullValue());
}
项目:jive    文件:EventHandlerLite.java   
public long getTypeId(final ReferenceType type)
{
  final String sig = Signatures.getPrefixed(type);
  Long id = store.get(sig);
  if (id != null)
  {
    return id;
  }
  id = register(Signatures.PREFIX_TYPE, sig, TYPE_ID.incrementAndGet());
  if (type != null)
  {
    jdiTypeLoad(type);
    for (final Method m : type.allMethods())
    {
      getMethodId(m);
    }
    for (final Field f : type.allFields())
    {
      getFieldId(f);
    }
  }
  return id;
}
项目:EclipseTracer    文件:Watchpoint.java   
/**
 * 
 * @param type the type of the field on which this watchpoint is registered 
 */
public void setField(Field field) {
    try {
        this.field = field;
        this.type = field.type();
    } catch (ClassNotLoadedException e) {
        e.printStackTrace();
    }
}
项目:codehint    文件:SideEffectHandler.java   
private void getReachableObjects(IJavaValue value, Set<IJavaObject> objs) throws DebugException {
    if (value instanceof IJavaArray) {
        IJavaArray arr = (IJavaArray)value;
        if (objs.add(arr) && !EclipseUtils.isPrimitive(Signature.getElementType(arr.getSignature())) && !arr.getSignature().equals("[Ljava/lang/String;"))
            for (IJavaValue elem: arr.getValues())
                getReachableObjects(elem, objs);
    } else if (value instanceof IJavaObject) {
        IJavaObject obj = (IJavaObject)value;
        if (objs.add(obj)) {
            // We use the internal API here because the Eclipse one must get each field's value one-by-one and so is much slower.
            ObjectReference obj2 = ((JDIObjectValue)obj).getUnderlyingObject();
            if (obj2 != null)  // null values fail this test
                for (Map.Entry<Field, Value> field: obj2.getValues(obj2.referenceType().allFields()).entrySet())
                    if (isUsefulStaticDFSField(field.getKey().declaringType().name(), field.getKey()))
                        getReachableObjects(JDIValue.createValue((JDIDebugTarget)stack.getDebugTarget(), field.getValue()), objs);
        }
    }
}
项目:codehint    文件:FieldNameConstraint.java   
/**
 * Gets the fields that can satisfy the given constraint.
 * @param stack The stack frame.
 * @param target The debug target.
 * @param subtypeChecker the subtype checker.
 * @param typeCache The type cache.
 * @return A mapping from the type of the receiving object to
 * a list of those of its fields that satisfy this constraint.
 */
public Map<String, ArrayList<Field>> getFields(IJavaStackFrame stack, IJavaDebugTarget target, SubtypeChecker subtypeChecker, TypeCache typeCache) {
    try {
        IJavaType[] receiverTypes = expressionConstraint.getTypes(stack, target, typeCache);
        Map<String, ArrayList<Field>> fieldsByType = new HashMap<String, ArrayList<Field>>(receiverTypes.length);
        for (IJavaType receiverType: receiverTypes) {
            String typeName = receiverType.getName();
            for (Field field: ExpressionGenerator.getFields(receiverType))
                if (ExpressionGenerator.isLegalField(field, stack.getReferenceType()) && fieldFulfills(field, stack, target, subtypeChecker, typeCache))
                    Utils.addToListMap(fieldsByType, typeName, field);
        }
        return fieldsByType;
    } catch (DebugException e) {
        throw new RuntimeException(e);
    }
}
项目:codehint    文件:ExpressionSkeleton.java   
/**
 * Creates a new SkeletonFiller.  Many common values are
 * stored as ivars for convenience.
 * @param extraDepth Extra depth to search.
 * @param searchConstructors Whether or not to search constructors.
 * @param searchOperators Whether or not to search operator expressions.
 * @param searchStatements Whether or not to search statements.
 * @param holeInfos The information about the holes in the skeleton.
 * @param stack The current stack frame.
 * @param target The debug target.
 * @param expressionMaker The expression maker.
 * @param expressionEvaluator The expression evaluator;
 * @param evalManager The evaluation manager.
 * @param staticEvaluator Evaluator of String method calls.
 * @param expressionGenerator The expression generator.
 * @param sideEffectHandler The side effect handler.
 * @param subtypeChecker The subtype checker.
 * @param typeCache The type cache.
 * @param valueCache The value cache.
 * @param monitor The progress monitor.
 */
private SkeletonFiller(int extraDepth, boolean searchConstructors, boolean searchOperators, boolean searchStatements, Map<String, HoleInfo> holeInfos, IJavaStackFrame stack, IJavaDebugTarget target, ExpressionMaker expressionMaker, ExpressionEvaluator expressionEvaluator, EvaluationManager evalManager, StaticEvaluator staticEvaluator, ExpressionGenerator expressionGenerator, SideEffectHandler sideEffectHandler, SubtypeChecker subtypeChecker, TypeCache typeCache, ValueCache valueCache, IProgressMonitor monitor) {
    this.extraDepth = extraDepth;
    this.searchConstructors = searchConstructors;
    this.searchOperators = searchOperators;
    this.searchStatements = searchStatements;
    this.holeFields = new HashMap<String, Map<String, ArrayList<Field>>>();
    this.holeMethods = new HashMap<String, Map<String, ArrayList<Method>>>();
    this.holeInfos = holeInfos;
    this.expressionMaker = expressionMaker;
    this.expressionEvaluator = expressionEvaluator;
    this.evalManager = evalManager;
    this.staticEvaluator = staticEvaluator;
    this.expressionGenerator = expressionGenerator;
    this.sideEffectHandler = sideEffectHandler;
    this.subtypeChecker = subtypeChecker;
    this.typeCache = typeCache;
    this.valueCache = valueCache;
    this.stack = stack;
    this.target = target;
    this.thread = (IJavaThread)stack.getThread();
    this.monitor = monitor;
    intType = EclipseUtils.getFullyQualifiedType("int", stack, target, typeCache);
    booleanType = EclipseUtils.getFullyQualifiedType("boolean", stack, target, typeCache);
}
项目:codehint    文件:ExpressionEvaluator.java   
private ExpressionEvaluator(IJavaStackFrame stack, ValueCache valueCache, TypeCache typeCache, SubtypeChecker subtypeChecker, TimeoutChecker timeoutChecker, NativeHandler nativeHandler, SideEffectHandler sideEffectHandler, Map<Integer, Method> methods, Map<Integer, Field> fields) {
    this.stack = stack;
    this.target = (IJavaDebugTarget)stack.getDebugTarget();
    this.thread = (IJavaThread)stack.getThread();
    results = new HashMap<Set<Effect>, Map<Integer, Result>>();
    this.resultStrings = new HashMap<Integer, String>();
    this.methods = new HashMap<Integer, Method>(methods);  // Make copies so that changes we make here don't affect the metadata's maps.
    this.fields = new HashMap<Integer, Field>(fields);
    statics = new HashMap<Integer, IJavaReferenceType>();
    depths = new HashMap<Integer, Integer>();
    this.valueCache = valueCache;
    this.typeCache = typeCache;
    this.subtypeChecker = subtypeChecker;
    numCrashes = 0;
    this.timeoutChecker = timeoutChecker;
    this.nativeHandler = nativeHandler;
    this.sideEffectHandler = sideEffectHandler;
}
项目:codehint    文件:ExpressionEvaluator.java   
public void addMetadataFor(List<Statement> stmts, final ExpressionEvaluator expressionEvaluator) {
    ASTVisitor visitor = new ASTVisitor() {
        @Override
        public void postVisit(ASTNode node) {
            if (node instanceof Expression) {
                int id = ((Expression)node).getID();
                    Method method = expressionEvaluator.getMethod(id);
                    if (method != null)
                        subsetMethods.put(id, method);
                    Field field = expressionEvaluator.getField(id);
                    if (field != null)
                        subsetFields.put(id, field);
            }
        }
    };
    for (Statement s: stmts)
        s.accept(visitor);
}
项目:incubator-netbeans    文件:AWTGrabHandler.java   
private void ungrabWindowFX(ClassType WindowClass, ObjectReference w, ThreadReference tr) throws Exception {
    // javafx.stage.Window w
    // w.focusGrabCounter
    // while (focusGrabCounter-- > 0) {
    //     w.impl_getPeer().ungrabFocus(); OR: w.impl_peer.ungrabFocus();
    // }
    Field focusGrabCounterField = WindowClass.fieldByName("focusGrabCounter");
    if (focusGrabCounterField == null) {
        logger.info("Unable to release FX X grab, no focusGrabCounter field in "+w);
        return ;
    }
    Value focusGrabCounterValue = w.getValue(focusGrabCounterField);
    if (!(focusGrabCounterValue instanceof IntegerValue)) {
        logger.info("Unable to release FX X grab, focusGrabCounter does not have an integer value in "+w);
        return ;
    }
    int focusGrabCounter = ((IntegerValue) focusGrabCounterValue).intValue();
    if (logger.isLoggable(Level.FINE)) {
        logger.fine("Focus grab counter of "+w+" is: "+focusGrabCounter);
    }
    while (focusGrabCounter-- > 0) {
        //Method impl_getPeerMethod = WindowClass.concreteMethodByName("impl_getPeer", "");
        Field impl_peerField = WindowClass.fieldByName("impl_peer");
        if (impl_peerField == null) {
            logger.info("Unable to release FX X grab, no impl_peer field in "+w);
            return ;
        }
        ObjectReference impl_peer = (ObjectReference) w.getValue(impl_peerField);
        if (impl_peer == null) {
            continue;
        }
        InterfaceType TKStageClass = (InterfaceType) w.virtualMachine().classesByName("com.sun.javafx.tk.TKStage").get(0);
        Method ungrabFocusMethod = TKStageClass.methodsByName("ungrabFocus", "()V").get(0);
        impl_peer.invokeMethod(tr, ungrabFocusMethod, Collections.EMPTY_LIST, ObjectReference.INVOKE_SINGLE_THREADED);
        if (logger.isLoggable(Level.FINE)) {
            logger.fine("FX Window "+w+" was successfully ungrabbed.");
        }
    }
}