Esempio n. 1
0
 @Override
 protected void createRequestForPreparedClass(
     DebugVMEventsProcessor debugProcess, final ReferenceType classType) {
   RequestManager requestManager = debugProcess.getRequestManager();
   try {
     int lineIndex = myLocation.getLineIndexInFile();
     List<Location> locs = classType.locationsOfLine(lineIndex);
     if (locs.size() > 0) {
       for (final Location location : locs) {
         BreakpointRequest request = requestManager.createBreakpointRequest(this, location);
         requestManager.enableRequest(request);
       }
     } else {
       //  there's no executable code in this class
       requestManager.setInvalid(this, "no executable code found");
       String message =
           "No locations of type "
               + classType.name()
               + " found at line "
               + myLocation.getLineIndexInFile();
       LOG.warning(message);
     }
   } catch (ClassNotPreparedException ex) {
     LOG.warning("ClassNotPreparedException: " + ex.getMessage());
     //  there's a chance to add a breakpoint when the class is prepared
   } catch (ObjectCollectedException ex) {
     LOG.warning("ObjectCollectedException: " + ex.getMessage());
     //  there's a chance to add a breakpoint when the class is prepared
   } catch (InvalidLineNumberException ex) {
     requestManager.setInvalid(this, "no executable code found");
     LOG.warning("InvalidLineNumberException: " + ex.getMessage());
   } catch (InternalException ex) {
     LOG.error(ex);
   } catch (Exception ex) {
     LOG.error(ex);
   }
 }
 @Override
 protected void createRequestForPreparedClass(
     final DebugProcessImpl debugProcess, final ReferenceType classType) {
   if (!isInScopeOf(debugProcess, classType.name())) {
     if (LOG.isDebugEnabled()) {
       LOG.debug(
           classType.name()
               + " is out of debug-process scope, breakpoint request won't be created for line "
               + getLineIndex());
     }
     return;
   }
   try {
     List<Location> locations =
         debugProcess.getPositionManager().locationsOfLine(classType, getSourcePosition());
     if (!locations.isEmpty()) {
       for (Location loc : locations) {
         if (LOG.isDebugEnabled()) {
           LOG.debug(
               "Found location [codeIndex="
                   + loc.codeIndex()
                   + "] for reference type "
                   + classType.name()
                   + " at line "
                   + getLineIndex()
                   + "; isObsolete: "
                   + (debugProcess.getVirtualMachineProxy().versionHigher("1.4")
                       && loc.method().isObsolete()));
         }
         if (!acceptLocation(debugProcess, classType, loc)) {
           continue;
         }
         final BreakpointRequest request =
             debugProcess.getRequestsManager().createBreakpointRequest(this, loc);
         debugProcess.getRequestsManager().enableRequest(request);
         if (LOG.isDebugEnabled()) {
           LOG.debug(
               "Created breakpoint request for reference type "
                   + classType.name()
                   + " at line "
                   + getLineIndex()
                   + "; codeIndex="
                   + loc.codeIndex());
         }
       }
     } else {
       // there's no executable code in this class
       debugProcess
           .getRequestsManager()
           .setInvalid(
               this,
               DebuggerBundle.message(
                   "error.invalid.breakpoint.no.executable.code",
                   (getLineIndex() + 1),
                   classType.name()));
       if (LOG.isDebugEnabled()) {
         LOG.debug(
             "No locations of type " + classType.name() + " found at line " + getLineIndex());
       }
     }
   } catch (ClassNotPreparedException ex) {
     if (LOG.isDebugEnabled()) {
       LOG.debug("ClassNotPreparedException: " + ex.getMessage());
     }
     // there's a chance to add a breakpoint when the class is prepared
   } catch (ObjectCollectedException ex) {
     if (LOG.isDebugEnabled()) {
       LOG.debug("ObjectCollectedException: " + ex.getMessage());
     }
     // there's a chance to add a breakpoint when the class is prepared
   } catch (InvalidLineNumberException ex) {
     if (LOG.isDebugEnabled()) {
       LOG.debug("InvalidLineNumberException: " + ex.getMessage());
     }
     debugProcess
         .getRequestsManager()
         .setInvalid(this, DebuggerBundle.message("error.invalid.breakpoint.bad.line.number"));
   } catch (InternalException ex) {
     LOG.info(ex);
   } catch (Exception ex) {
     LOG.info(ex);
   }
   updateUI();
 }