示例#1
0
  private void commandClear(StringTokenizer t) throws NoSessionException {
    if (!t.hasMoreTokens()) {
      // Print set breakpoints
      listEventRequests();
      return;
    }
    // ### need 'clear all'
    BreakpointSpec bpSpec = parseBreakpointSpec(t.nextToken());
    if (bpSpec != null) {
      List<EventRequestSpec> specs = runtime.eventRequestSpecs();

      if (specs.isEmpty()) {
        env.notice("No breakpoints set.");
      } else {
        List<EventRequestSpec> toDelete = new ArrayList<EventRequestSpec>();
        for (EventRequestSpec spec : specs) {
          if (spec.equals(bpSpec)) {
            toDelete.add(spec);
          }
        }
        // The request used for matching should be found
        if (toDelete.size() <= 1) {
          env.notice("No matching breakpoint set.");
        }
        for (EventRequestSpec spec : toDelete) {
          runtime.delete(spec);
        }
      }
    } else {
      env.error("Ill-formed breakpoint specification.");
    }
  }
示例#2
0
 private void listEventRequests() throws NoSessionException {
   // Print set breakpoints
   List<EventRequestSpec> specs = runtime.eventRequestSpecs();
   if (specs.isEmpty()) {
     env.notice("No breakpoints/watchpoints/exceptions set.");
   } else {
     OutputSink out = env.getOutputSink();
     out.println("Current breakpoints/watchpoints/exceptions set:");
     for (EventRequestSpec bp : specs) {
       out.println("\t" + bp);
     }
     out.show();
   }
 }
示例#3
0
  public List<ReferenceType> nestedTypes(ReferenceType refType) {
    List<ReferenceType> nestedTypes = myNestedClassesCache.get(refType);
    if (nestedTypes == null) {
      List<ReferenceType> list = Collections.emptyList();
      try {
        list = refType.nestedTypes();
      } catch (Throwable e) {
        // sometimes some strange errors are thrown from JDI. Do not crash debugger because of this.
        // Example:
        // java.lang.StringIndexOutOfBoundsException: String index out of range: 487700285
        //	at java.lang.String.checkBounds(String.java:375)
        //	at java.lang.String.<init>(String.java:415)
        //	at com.sun.tools.jdi.PacketStream.readString(PacketStream.java:392)
        //	at
        // com.sun.tools.jdi.JDWP$VirtualMachine$AllClassesWithGeneric$ClassInfo.<init>(JDWP.java:1644)
        LOG.info(e);
      }
      if (!list.isEmpty()) {
        final Set<ReferenceType> candidates = new HashSet<>();
        final ClassLoaderReference outerLoader = refType.classLoader();
        for (ReferenceType nested : list) {
          try {
            if (outerLoader == null
                ? nested.classLoader() == null
                : outerLoader.equals(nested.classLoader())) {
              candidates.add(nested);
            }
          } catch (ObjectCollectedException ignored) {
          }
        }

        if (!candidates.isEmpty()) {
          // keep only direct nested types
          final Set<ReferenceType> nested2 = new HashSet<>();
          for (final ReferenceType candidate : candidates) {
            nested2.addAll(nestedTypes(candidate));
          }
          candidates.removeAll(nested2);
        }

        nestedTypes = candidates.isEmpty() ? Collections.emptyList() : new ArrayList<>(candidates);
      } else {
        nestedTypes = Collections.emptyList();
      }
      myNestedClassesCache.put(refType, nestedTypes);
    }
    return nestedTypes;
  }