Java Code Examples for com.sun.jdi.ReferenceType#fieldByName()

The following examples show how to use com.sun.jdi.ReferenceType#fieldByName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VisualDebuggerListener.java    From netbeans with Apache License 2.0 6 votes vote down vote up
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);
    }
}
 
Example 2
Source File: Watchpoint.java    From java-debug with Eclipse Public License 1.0 6 votes vote down vote up
private List<WatchpointRequest> createWatchpointRequests(ReferenceType type) {
    List<WatchpointRequest> watchpointRequests = new ArrayList<>();
    Field field = type.fieldByName(fieldName);
    if (field != null) {
        if ("read".equals(accessType)) {
            watchpointRequests.add(vm.eventRequestManager().createAccessWatchpointRequest(field));
        } else if ("readWrite".equals(accessType)) {
            watchpointRequests.add(vm.eventRequestManager().createAccessWatchpointRequest(field));
            watchpointRequests.add(vm.eventRequestManager().createModificationWatchpointRequest(field));
        } else {
            watchpointRequests.add(vm.eventRequestManager().createModificationWatchpointRequest(field));
        }
    }

    watchpointRequests.forEach(request -> {
        request.setSuspendPolicy(WatchpointRequest.SUSPEND_EVENT_THREAD);
        if (hitCount > 0) {
            request.addCountFilter(hitCount);
        }
        request.enable();
    });
    return watchpointRequests;
}
 
Example 3
Source File: DataBreakpointInfoRequestHandler.java    From java-debug with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public CompletableFuture<Response> handle(Command command, Arguments arguments, Response response, IDebugAdapterContext context) {
    DataBreakpointInfoArguments dataBpArgs = (DataBreakpointInfoArguments) arguments;
    if (dataBpArgs.variablesReference > 0) {
        Object container = context.getRecyclableIdPool().getObjectById(dataBpArgs.variablesReference);
        if (container instanceof VariableProxy) {
            if (!(((VariableProxy) container).getProxiedVariable() instanceof StackFrameReference)) {
                ObjectReference containerObj = (ObjectReference) ((VariableProxy) container).getProxiedVariable();
                ReferenceType type = containerObj.referenceType();
                Field field = type.fieldByName(dataBpArgs.name);
                if (field != null) {
                    String fullyQualifiedName = type.name();
                    String dataId = String.format("%s#%s", fullyQualifiedName, dataBpArgs.name);
                    String description = String.format("%s.%s : %s", getSimpleName(fullyQualifiedName), dataBpArgs.name, getSimpleName(field.typeName()));
                    response.body = new DataBreakpointInfoResponseBody(dataId, description,
                        DataBreakpointAccessType.values(), true);
                }
            }
        }
    }
    return CompletableFuture.completedFuture(response);
}
 
Example 4
Source File: FieldMonitor.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void addFieldWatch(VirtualMachine vm,
    ReferenceType refType) {
  EventRequestManager erm = vm.eventRequestManager();
  Field field = refType.fieldByName(FIELD_NAME);
  ModificationWatchpointRequest modificationWatchpointRequest = erm
      .createModificationWatchpointRequest(field);
  modificationWatchpointRequest.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
  modificationWatchpointRequest.setEnabled(true);
}
 
Example 5
Source File: FieldMonitor.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private static void addFieldWatch(VirtualMachine vm,
    ReferenceType refType) {
  EventRequestManager erm = vm.eventRequestManager();
  Field field = refType.fieldByName(FIELD_NAME);
  ModificationWatchpointRequest modificationWatchpointRequest = erm
      .createModificationWatchpointRequest(field);
  modificationWatchpointRequest.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
  modificationWatchpointRequest.setEnabled(true);
}
 
Example 6
Source File: FieldMonitor.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void addFieldWatch(VirtualMachine vm,
    ReferenceType refType) {
  EventRequestManager erm = vm.eventRequestManager();
  Field field = refType.fieldByName(FIELD_NAME);
  ModificationWatchpointRequest modificationWatchpointRequest = erm
      .createModificationWatchpointRequest(field);
  modificationWatchpointRequest.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
  modificationWatchpointRequest.setEnabled(true);
}
 
Example 7
Source File: FieldMonitor.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static void addFieldWatch(VirtualMachine vm,
    ReferenceType refType) {
  EventRequestManager erm = vm.eventRequestManager();
  Field field = refType.fieldByName(FIELD_NAME);
  ModificationWatchpointRequest modificationWatchpointRequest = erm
      .createModificationWatchpointRequest(field);
  modificationWatchpointRequest.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
  modificationWatchpointRequest.setEnabled(true);
}
 
Example 8
Source File: FieldMonitor.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static void addFieldWatch(VirtualMachine vm,
    ReferenceType refType) {
  EventRequestManager erm = vm.eventRequestManager();
  Field field = refType.fieldByName(FIELD_NAME);
  ModificationWatchpointRequest modificationWatchpointRequest = erm
      .createModificationWatchpointRequest(field);
  modificationWatchpointRequest.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
  modificationWatchpointRequest.setEnabled(true);
}
 
Example 9
Source File: SetVariableRequestHandler.java    From java-debug with Eclipse Public License 1.0 5 votes vote down vote up
private Value handleSetValueForStackFrame(String name, String belongToClass, String valueString,
        boolean showStaticVariables, StackFrame container, Map<String, Object> options)
                throws AbsentInformationException, InvalidTypeException, ClassNotLoadedException {
    Value newValue;
    if (name.equals("this")) {
        throw new UnsupportedOperationException("SetVariableRequest: 'This' variable cannot be changed.");
    }
    LocalVariable variable = container.visibleVariableByName(name);
    if (StringUtils.isBlank(belongToClass) && variable != null) {
        newValue = this.setFrameValue(container, variable, valueString, options);
    } else {
        if (showStaticVariables && container.location().method().isStatic()) {
            ReferenceType type = container.location().declaringType();
            if (StringUtils.isBlank(belongToClass)) {
                Field field = type.fieldByName(name);
                newValue = setStaticFieldValue(type, field, name, valueString, options);
            } else {
                newValue = setFieldValueWithConflict(null, type.allFields(), name, belongToClass,
                        valueString, options);
            }
        } else {
            throw new UnsupportedOperationException(
                    String.format("SetVariableRequest: Variable %s cannot be found.", name));
        }
    }
    return newValue;
}
 
Example 10
Source File: FieldMonitor.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private static void addFieldWatch(VirtualMachine vm,
    ReferenceType refType) {
  EventRequestManager erm = vm.eventRequestManager();
  Field field = refType.fieldByName(FIELD_NAME);
  ModificationWatchpointRequest modificationWatchpointRequest = erm
      .createModificationWatchpointRequest(field);
  modificationWatchpointRequest.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
  modificationWatchpointRequest.setEnabled(true);
}
 
Example 11
Source File: FieldMonitor.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private static void addFieldWatch(VirtualMachine vm,
    ReferenceType refType) {
  EventRequestManager erm = vm.eventRequestManager();
  Field field = refType.fieldByName(FIELD_NAME);
  ModificationWatchpointRequest modificationWatchpointRequest = erm
      .createModificationWatchpointRequest(field);
  modificationWatchpointRequest.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
  modificationWatchpointRequest.setEnabled(true);
}
 
Example 12
Source File: FieldMonitor.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void addFieldWatch(VirtualMachine vm,
    ReferenceType refType) {
  EventRequestManager erm = vm.eventRequestManager();
  Field field = refType.fieldByName(FIELD_NAME);
  ModificationWatchpointRequest modificationWatchpointRequest = erm
      .createModificationWatchpointRequest(field);
  modificationWatchpointRequest.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
  modificationWatchpointRequest.setEnabled(true);
}