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

项目:incubator-netbeans    文件:SourcePath.java   
public boolean sourceAvailable (
    CallStackFrame csf,
    String stratumn
) {
    String url = getClassURL(((CallStackFrameImpl) csf).getClassType(), stratumn);
    if (url != null) {
        return true;
    }
    try {
        return sourceAvailable (
            convertSlash (csf.getSourcePath (stratumn)), true
        );
    } catch (AbsentInformationException e) {
        return sourceAvailable (
            convertClassNameToRelativePath (csf.getClassName ()), true
        );
    }
}
项目:incubator-netbeans    文件:DebuggingActionsProvider.java   
private static void popToHere (final CallStackFrame frame) {
    try {
        JPDAThread t = frame.getThread ();
        CallStackFrame[] stack = t.getCallStack ();
        int i, k = stack.length;
        if (k < 2) return ;
        for (i = 0; i < k; i++)
            if (stack [i].equals (frame)) {
                if (i > 0) {
                    stack [i - 1].popFrame ();
                }
                return;
            }
    } catch (AbsentInformationException ex) {
    }
}
项目:incubator-netbeans    文件:CallStackTableModel.java   
public Object getValueAt (Object row, String columnID) throws 
UnknownTypeException {
    if (row instanceof CallStackFrame) {
        if (CALL_STACK_FRAME_LOCATION_COLUMN_ID.equals (columnID))
            try {
                return ((CallStackFrame) row).getSourceName (
                    null // default stratumn for current csf is used
                );
            } catch (AbsentInformationException e) {
                return NbBundle.getMessage (
                    CallStackTableModel.class, 
                    "MSG_Callstack_NoInformation"
                );
            }
    }
    throw new UnknownTypeException (row);
}
项目:java-debug    文件:StackTraceRequestHandler.java   
private Types.StackFrame convertDebuggerStackFrameToClient(StackFrame stackFrame, int frameId, IDebugAdapterContext context)
        throws URISyntaxException, AbsentInformationException {
    Location location = stackFrame.location();
    Method method = location.method();
    Types.Source clientSource = this.convertDebuggerSourceToClient(location, context);
    String methodName = formatMethodName(method, true, true);
    int lineNumber = AdapterUtils.convertLineNumber(location.lineNumber(), context.isDebuggerLinesStartAt1(), context.isClientLinesStartAt1());
    // Line number returns -1 if the information is not available; specifically, always returns -1 for native methods.
    if (lineNumber < 0) {
        if (method.isNative()) {
            // For native method, display a tip text "native method" in the Call Stack View.
            methodName += "[native method]";
        } else {
            // For other unavailable method, such as lambda expression's built-in methods run/accept/apply,
            // display "Unknown Source" in the Call Stack View.
            clientSource = null;
        }
    }

    return new Types.StackFrame(frameId, methodName, clientSource, lineNumber, 0);
}
项目:incubator-netbeans    文件:BaseComponentBreakpointImpl.java   
final protected void navigateToCustomCode(final JPDAThread thread) {
    CallStackFrame callStackFrame = null;
    try {
        CallStackFrame[] callStack = thread.getCallStack();
        for (CallStackFrame csf : callStack) {
            String cn = csf.getClassName();
            if (JavaComponentInfo.isCustomType(cn)) {
                callStackFrame = csf;
                break;
            }
        }
    } catch (AbsentInformationException ex) {
    }
    if (callStackFrame != null) {
        ((JPDAThreadImpl) thread).getDebugger().setPreferredTopFrame(callStackFrame);
    }
}
项目:incubator-netbeans    文件:DeadlockDetectorImpl.java   
private ObjectVariable[] checkForThreadJoin(JPDAThread thread, ObjectVariable[] ownedMonitors) {
    CallStackFrame[] callStack;
    try {
        callStack = thread.getCallStack(0, 2);
    } catch (AbsentInformationException ex) {
        return ownedMonitors;
    }
    if (callStack.length < 2) {
        return ownedMonitors;
    }
    if (Thread.class.getName().equals(callStack[1].getClassName()) && "join".equals(callStack[1].getMethodName())) {    // NOI18N
        // This current thread is the "owned" monitor, it's joning the contended monitor.
        ObjectVariable[] ownedMonitorsWithThread = Arrays.copyOf(ownedMonitors, ownedMonitors.length + 1);
        ownedMonitorsWithThread[ownedMonitors.length] = (ObjectVariable) ((JPDAThreadImpl) thread).getDebugger().getVariable(((JPDAThreadImpl) thread).getThreadReference());
        return ownedMonitorsWithThread;
    } else {
        return ownedMonitors;
    }
}
项目:incubator-netbeans    文件:JPDADebuggerImpl.java   
/**
 * Test whether we should stop here according to the smart-stepping rules.
 */
StopOrStep stopHere(JPDAThread t) {
    CallStackFrame topFrame = null;
    try {
        CallStackFrame[] topFrameArr = t.getCallStack(0, 1);
        if (topFrameArr.length > 0) {
            topFrame = topFrameArr[0];
        }
    } catch (AbsentInformationException aiex) {}
    if (topFrame != null) {
        return getCompoundSmartSteppingListener().stopAt
                    (lookupProvider, topFrame, getSmartSteppingFilter());
    } else {
        return getCompoundSmartSteppingListener().stopHere
                    (lookupProvider, t, getSmartSteppingFilter()) ?
                StopOrStep.stop() : StopOrStep.skip();
    }
}
项目:incubator-netbeans    文件:JPDADebuggerImpl.java   
private CallStackFrame getTopFrame(JPDAThread thread) {
    CallStackFrame callStackFrame;
    if (preferredTopFrame != null) {
        callStackFrame = preferredTopFrame;
        preferredTopFrame = null;
        return callStackFrame;
    }
    if ((thread == null) || (thread.getStackDepth () < 1)) {
        callStackFrame = null;
    } else {
        try {
            CallStackFrame[] csfs = thread.getCallStack(0, 1);
            if (csfs.length > 0) {
                callStackFrame = csfs[0];
            } else {
                callStackFrame = null;
            }
        } catch (AbsentInformationException e) {
            callStackFrame = null;
        }
    }
    return callStackFrame;
}
项目:incubator-netbeans    文件:CallStackFrameImpl.java   
/**
* Returns name of file of this frame.
*
* @return name of file of this frame
* @throws NoInformationException if informations about source are not included or some other error
*   occurres.
*/
public synchronized String getSourceName (String stratum) throws AbsentInformationException {
    if (!valid && sfLocation == null) return "";
    assert !Mutex.EVENT.isReadAccess();
    try {
        Location l = getStackFrameLocation();
        return LocationWrapper.sourceName(l, stratum);
    } catch (InvalidStackFrameExceptionWrapper ex) {
        // this stack frame is not available or information in it is not available
        valid = false;
        return "";
    } catch (InternalExceptionWrapper ex) {
        return "";
    } catch (VMDisconnectedExceptionWrapper ex) {
        return "";
    }
}
项目:incubator-netbeans    文件:CallStackFrameImpl.java   
/**
 * Returns source path of file this frame is stopped in or null.
 *
 * @return source path of file this frame is stopped in or null
 */
public synchronized String getSourcePath (String stratum) throws AbsentInformationException {
    if (!valid && sfLocation == null) return "";
    assert !Mutex.EVENT.isReadAccess();
    try {
        Location l = getStackFrameLocation();
        return LocationWrapper.sourcePath(l, stratum);
    } catch (InvalidStackFrameExceptionWrapper ex) {
        // this stack frame is not available or information in it is not available
        valid = false;
        return "";
    } catch (InternalExceptionWrapper ex) {
        return "";
    } catch (VMDisconnectedExceptionWrapper ex) {
        return "";
    }
}
项目:OpenJSharp    文件:SourceMapper.java   
/**
 * Return a File cooresponding to the source of this location.
 * Return null if not available.
 */
File sourceFile(Location loc) {
    try {
        String filename = loc.sourceName();
        String refName = loc.declaringType().name();
        int iDot = refName.lastIndexOf('.');
        String pkgName = (iDot >= 0)? refName.substring(0, iDot+1) : "";
        String full = pkgName.replace('.', File.separatorChar) + filename;
        for (int i= 0; i < dirs.length; ++i) {
            File path = new File(dirs[i], full);
            if (path.exists()) {
                return path;
            }
        }
        return null;
    } catch (AbsentInformationException e) {
        return null;
    }
}
项目:jdk8u-jdk    文件:SourceMapper.java   
/**
 * Return a File cooresponding to the source of this location.
 * Return null if not available.
 */
File sourceFile(Location loc) {
    try {
        String filename = loc.sourceName();
        String refName = loc.declaringType().name();
        int iDot = refName.lastIndexOf('.');
        String pkgName = (iDot >= 0)? refName.substring(0, iDot+1) : "";
        String full = pkgName.replace('.', File.separatorChar) + filename;
        for (int i= 0; i < dirs.length; ++i) {
            File path = new File(dirs[i], full);
            if (path.exists()) {
                return path;
            }
        }
        return null;
    } catch (AbsentInformationException e) {
        return null;
    }
}
项目:openjdk-jdk10    文件:GetObjectLockCount.java   
private static void addBreakpoint(VirtualMachine vm, ReferenceType refType) {
    Location breakpointLocation = null;
    List<Location> locs;
    try {
        locs = refType.allLineLocations();
        for (Location loc: locs) {
            if (loc.method().name().equals(METHOD_NAME)) {
                breakpointLocation = loc;
                break;
            }
        }
    } catch (AbsentInformationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    if (breakpointLocation != null) {
        EventRequestManager evtReqMgr = vm.eventRequestManager();
        BreakpointRequest bReq = evtReqMgr.createBreakpointRequest(breakpointLocation);
        bReq.setSuspendPolicy(BreakpointRequest.SUSPEND_ALL);
        bReq.enable();
    }
}
项目:openjdk-jdk10    文件:ConcreteMethodImpl.java   
List<Location> sourceNameFilter(List<Location> list,
                                SDE.Stratum stratum,
                                String sourceName)
                        throws AbsentInformationException {
    if (sourceName == null) {
        return list;
    } else {
        /* needs sourceName filteration */
        List<Location> locs = new ArrayList<>();
        for (Location loc : list) {
            if (((LocationImpl)loc).sourceName(stratum).equals(sourceName)) {
                locs.add(loc);
            }
        }
        return locs;
    }
}
项目:openjdk-jdk10    文件:ConcreteMethodImpl.java   
List<Location> locationsOfLine(SDE.Stratum stratum,
                               String sourceName,
                               int lineNumber)
                        throws AbsentInformationException {
    SoftLocationXRefs info = getLocations(stratum);

    if (info.lineLocations.size() == 0) {
        throw new AbsentInformationException();
    }

    /*
     * Find the locations which match the line number
     * passed in.
     */
    List<Location> list = info.lineMapper.get(lineNumber);

    if (list == null) {
        list = new ArrayList<>(0);
    }
    return Collections.unmodifiableList(
        sourceNameFilter(list, stratum, sourceName));
}
项目:openjdk-jdk10    文件:ReferenceTypeImpl.java   
String baseSourceName() throws AbsentInformationException {
    String bsn = baseSourceName;
    if (bsn == null) {
        // Does not need synchronization, since worst-case
        // static info is fetched twice
        try {
            bsn = JDWP.ReferenceType.SourceFile.
                process(vm, this).sourceFile;
        } catch (JDWPException exc) {
            if (exc.errorCode() == JDWP.Error.ABSENT_INFORMATION) {
                bsn = ABSENT_BASE_SOURCE_NAME;
            } else {
                throw exc.toJDIException();
            }
        }
        baseSourceName = bsn;
    }
    if (bsn == ABSENT_BASE_SOURCE_NAME) {
        throw new AbsentInformationException();
    }
    return bsn;
}
项目:openjdk-jdk10    文件:StackFrameImpl.java   
/**
 * Build the visible variable map.
 * Need not be synchronized since it cannot be provably stale.
 */
private void createVisibleVariables() throws AbsentInformationException {
    if (visibleVariables == null) {
        List<LocalVariable> allVariables = location.method().variables();
        Map<String, LocalVariable> map = new HashMap<>(allVariables.size());

        for (LocalVariable variable : allVariables) {
            String name = variable.name();
            if (variable.isVisible(this)) {
                LocalVariable existing = map.get(name);
                if ((existing == null) ||
                    ((LocalVariableImpl)variable).hides(existing)) {
                    map.put(name, variable);
                }
            }
        }
        visibleVariables = map;
    }
}
项目:incubator-netbeans    文件:SourcePath.java   
public String getURL (
    CallStackFrame csf,
    String stratumn,
    String[] sourcePathPtr
) {
    JPDAClassType classType = ((CallStackFrameImpl) csf).getClassType();
    String url = null;
    if (classType != null) {
        url = getClassURL(classType, stratumn);
    }
    if (url == null) {
        String sourcePath;
        try {
            sourcePath = convertSlash (csf.getSourcePath (stratumn));
            url = getURL(sourcePath, true);
            if (url == null) {
                String ds = csf.getDefaultStratum();
                sourcePath = convertSlash (csf.getSourcePath (ds));
                url = getURL(sourcePath, true);
            }
        } catch (AbsentInformationException e) {
            sourcePath = convertClassNameToRelativePath (csf.getClassName ());
            url = getURL(sourcePath, true);
        }

        if (sourcePathPtr != null) {
            sourcePathPtr[0] = sourcePath;
        }
    }
    return url;
}
项目:incubator-netbeans    文件:EditorContextBridge.java   
public static String getRelativePath (
    JPDAThread thread,
    String stratumn
) {
    try {
        return convertSlash (thread.getSourcePath (stratumn));
    } catch (AbsentInformationException e) {
        return getRelativePath (thread.getClassName ());
    }
}
项目:incubator-netbeans    文件:EditorContextBridge.java   
public static String getRelativePath (
    CallStackFrame csf,
    String stratumn
) {
    try {
        return convertSlash (csf.getSourcePath (stratumn));
    } catch (AbsentInformationException e) {
        return getRelativePath (csf.getClassName ());
    }
}
项目:incubator-netbeans    文件:CallStackNodeModel.java   
public static String getCSFName (
    Session s, 
    CallStackFrame sf,
    boolean l
) {
    String language = s.getCurrentLanguage();//sf.getDefaultStratum ();
    int ln = sf.getLineNumber (language);
    String fileName = null;
    boolean isJava = "Java".equals (language) || !sf.getAvailableStrata().contains(language);
    if (!isJava) {
        try {
            if (l) {
                fileName = sf.getSourcePath(language);
                if ("JS".equals(language) && (fileName.startsWith("jdk/nashorn/internal/scripts/") ||
                                              fileName.startsWith("jdk\\nashorn\\internal\\scripts\\"))) {
                    fileName = sf.getSourceName(language);
                }
            } else {
                fileName = sf.getSourceName(language);
            }
            int dot = fileName.lastIndexOf('.');
            if (dot > 0) {
                fileName = fileName.substring(0, dot + 1);
            }
            fileName += sf.getMethodName();
        } catch (AbsentInformationException e) {
            isJava = true;
        }
    }
    if (isJava) {
        fileName = l ? sf.getClassName () :
                       BreakpointsNodeModel.getShort (sf.getClassName ());
        fileName += "." + sf.getMethodName ();
    }
    if (ln < 0)
        return fileName;
    return fileName + ":" + ln;
}
项目:java-debug    文件:VariableUtils.java   
/**
 * Get the variables of the object.
 *
 * @param obj
 *            the object
 * @return the variable list
 * @throws AbsentInformationException
 *             when there is any error in retrieving information
 */
public static List<Variable> listFieldVariables(ObjectReference obj, boolean includeStatic) throws AbsentInformationException {
    List<Variable> res = new ArrayList<>();
    Type type = obj.type();
    if (type instanceof ArrayType) {
        int arrayIndex = 0;
        for (Value elementValue : ((ArrayReference) obj).getValues()) {
            Variable ele = new Variable(String.valueOf(arrayIndex++), elementValue);
            res.add(ele);
        }
        return res;
    }
    List<Field> fields = obj.referenceType().allFields().stream().filter(t -> includeStatic || !t.isStatic())
            .sorted((a, b) -> {
                try {
                    boolean v1isStatic = a.isStatic();
                    boolean v2isStatic = b.isStatic();
                    if (v1isStatic && !v2isStatic) {
                        return -1;
                    }
                    if (!v1isStatic && v2isStatic) {
                        return 1;
                    }
                    return a.name().compareToIgnoreCase(b.name());
                } catch (Exception e) {
                    logger.log(Level.SEVERE, String.format("Cannot sort fields: %s", e), e);
                    return -1;
                }
            }).collect(Collectors.toList());
    fields.forEach(f -> {
        Variable var = new Variable(f.name(), obj.getValue(f));
        var.field = f;
        res.add(var);
    });
    return res;
}
项目:incubator-netbeans    文件:JavaComponentInfo.java   
public Stack(CallStackFrame[] stackFrames) {
    int n = stackFrames.length;
    frames = new Frame[n];
    for (int i = 0; i < n; i++) {
        CallStackFrame sf = stackFrames[i];
        try {
            frames[i] = new Frame(sf.getClassName(), sf.getMethodName(), sf.getSourceName(null), sf.getLineNumber(null));
        } catch (AbsentInformationException ex) {
            frames[i] = new Frame(sf.getClassName(), sf.getMethodName(), null, sf.getLineNumber(null));
        }
    }
}
项目:incubator-netbeans    文件:EditorContextBridge.java   
public static String getRelativePath (
    JPDAThread thread,
    String stratumn
) {
    try {
        return convertSlash (thread.getSourcePath (stratumn));
    } catch (AbsentInformationException e) {
        return getRelativePath (thread.getClassName ());
    }
}
项目:incubator-netbeans    文件:EditorContextBridge.java   
public static String getRelativePath (
    CallStackFrame csf,
    String stratumn
) {
    try {
        return convertSlash (csf.getSourcePath (stratumn));
    } catch (AbsentInformationException e) {
        return getRelativePath (csf.getClassName ());
    }
}
项目:incubator-netbeans    文件:JPDADebuggerImpl.java   
private void checkJSR45Languages (JPDAThread t) {
    if (t.getStackDepth () > 0) {
        try {
            CallStackFrame[] frames = t.getCallStack (0, 1);
            if (frames.length < 1) {
                return ; // Internal error or disconnected
            }
            checkJSR45Languages(frames[0]);
        } catch (AbsentInformationException e) {
        }
    }
}
项目:java-debug    文件:ArrayObjectFormatterTest.java   
@Test(expected = UnsupportedOperationException.class)
public void testValueOfNotUnsupported() {
    try {
        ObjectReference array = (ObjectReference)this.getLocalValue("arrays");
        formatter.valueOf("new int[] { 1, 2, 3}", array.referenceType(), new HashMap<>());
    } catch (AbsentInformationException e) {
        e.printStackTrace();
        fail("Failure due to exception.");
    }

}
项目:incubator-netbeans    文件:PopToHereActionProvider.java   
public void runAction() {
    try {
        JPDAThread t = getDebuggerImpl ().getCurrentThread ();
        ((JPDAThreadImpl) t).accessLock.writeLock().lock();
        try {
            CallStackFrame[] frames = t.getCallStack (0, 2);
            if (frames.length > 1) {
                frames[0].popFrame ();
            }
        } finally {
            ((JPDAThreadImpl) t).accessLock.writeLock().unlock();
        }
    } catch (AbsentInformationException ex) {
    }
}
项目:incubator-netbeans    文件:JPDAStepImpl.java   
private static CallStackFrame getTopFrame(JPDAThread thread) {
    CallStackFrame topFrame = null;
    try {
        CallStackFrame[] topFrameArr = thread.getCallStack(0, 1);
        if (topFrameArr.length > 0) {
            topFrame = topFrameArr[0];
        }
    } catch (AbsentInformationException aiex) {}
    return topFrame;
}
项目:Pogamut3    文件:EngineThread.java   
/**
 * @return this variable of the JPDA thread.
 */
public This getThisVariable() throws AbsentInformationException {
    CallStackFrame frame = engineThread.getCallStack()[0];
    This thisVar = frame.getThisVariable();

    return thisVar;
}
项目:Pogamut3    文件:EvaluationListener.java   
/**
 * @return this variable of the JPDA thread.
 */
public final This getThisVariable(JPDAThread thread) throws AbsentInformationException {
    CallStackFrame frame = thread.getCallStack()[0];
    This thisVar = frame.getThisVariable();

    return thisVar;
}
项目:openjdk-jdk10    文件:MethodImpl.java   
public List<Location> locationsOfLine(String stratumID,
                                      String sourceName,
                                      int lineNumber)
                      throws AbsentInformationException {
    return locationsOfLine(declaringType.stratum(stratumID),
                           sourceName, lineNumber);
}
项目:openjdk-jdk10    文件:LocalVariableImpl.java   
public boolean isArgument() {
    try {
        MethodImpl method = (MethodImpl)scopeStart.method();
        return (slot < method.argSlotCount());
    } catch (AbsentInformationException e) {
        // If this variable object exists, there shouldn't be absent info
        throw new InternalException();
    }
}
项目:java-debug    文件:StackFrameUtility.java   
/**
 * Get the StackFrame associated source file path.
 *
 * @param frame
 *            StackFrame for the source path
 * @return the source file path
 */
public static String getSourcePath(StackFrame frame) {
    try {
        return frame.location().sourcePath();
    } catch (AbsentInformationException e) {
        // Ignore it
    }
    return null;
}
项目:openjdk-jdk10    文件:ConcreteMethodImpl.java   
List<Location> allLineLocations(SDE.Stratum stratum,
                                String sourceName)
                        throws AbsentInformationException {
    List<Location> lineLocations = getLocations(stratum).lineLocations;

    if (lineLocations.size() == 0) {
        throw new AbsentInformationException();
    }

    return Collections.unmodifiableList(
        sourceNameFilter(lineLocations, stratum, sourceName));
}
项目:openjdk-jdk10    文件:ConcreteMethodImpl.java   
public List<LocalVariable> variablesByName(String name) throws AbsentInformationException {
    List<LocalVariable> variables = getVariables();

    List<LocalVariable> retList = new ArrayList<>(2);
    Iterator<LocalVariable> iter = variables.iterator();
    while(iter.hasNext()) {
        LocalVariable variable = iter.next();
        if (variable.name().equals(name)) {
            retList.add(variable);
        }
    }
    return retList;
}
项目:openjdk-jdk10    文件:ConcreteMethodImpl.java   
public List<LocalVariable> arguments() throws AbsentInformationException {
    List<LocalVariable> variables = getVariables();

    List<LocalVariable> retList = new ArrayList<>(variables.size());
    Iterator<LocalVariable> iter = variables.iterator();
    while(iter.hasNext()) {
        LocalVariable variable = iter.next();
        if (variable.isArgument()) {
            retList.add(variable);
        }
    }
    return retList;
}
项目:openjdk-jdk10    文件:ConcreteMethodImpl.java   
private List<LocalVariable> getVariables() throws AbsentInformationException {
    if (absentVariableInformation) {
        throw new AbsentInformationException();
    }

    List<LocalVariable> variables = (variablesRef == null) ? null :
                                     variablesRef.get();
    if (variables != null) {
        return variables;
    }
    variables = getVariables1();
    variables = Collections.unmodifiableList(variables);
    variablesRef = new SoftReference<>(variables);
    return variables;
}
项目:openjdk-jdk10    文件:ReferenceTypeImpl.java   
public List<String> sourceNames(String stratumID)
                            throws AbsentInformationException {
    SDE.Stratum stratum = stratum(stratumID);
    if (stratum.isJava()) {
        List<String> result = new ArrayList<String>(1);
        result.add(baseSourceName());
        return result;
    }
    return stratum.sourceNames(this);
}
项目:openjdk-jdk10    文件:ReferenceTypeImpl.java   
public List<String> sourcePaths(String stratumID)
                            throws AbsentInformationException {
    SDE.Stratum stratum = stratum(stratumID);
    if (stratum.isJava()) {
        List<String> result = new ArrayList<String>(1);
        result.add(baseSourceDir() + baseSourceName());
        return result;
    }
    return stratum.sourcePaths(this);
}