本文整理汇总了Java中com.sun.jdi.Location类的典型用法代码示例。如果您正苦于以下问题:Java Location类的具体用法?Java Location怎么用?Java Location使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Location类属于com.sun.jdi包,在下文中一共展示了Location类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sourceFile
import com.sun.jdi.Location; //导入依赖的package包/类
/**
* 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;
}
}
示例2: shouldHandleStepInto
import com.sun.jdi.Location; //导入依赖的package包/类
protected boolean shouldHandleStepInto(final Location location)
{
try
{
if (getOriginalStepStackDepth() != getUnderlyingFrameCount())
{
return true;
}
if (getOriginalStepLocation().lineNumber() != location.lineNumber())
{
return true;
}
return false;
}
catch (final DebugException e)
{
// TODO log error
return false;
}
}
示例3: computeLineRange
import com.sun.jdi.Location; //导入依赖的package包/类
private void computeLineRange(final int[] lineRange, final List<?> locations)
{
int lineFrom = -1;
int lineTo = -1;
for (final Object o : locations)
{
final Location location = (Location) o;
if (lineFrom == -1 || lineFrom > location.lineNumber())
{
lineFrom = location.lineNumber();
}
if (lineTo == -1 || lineTo < location.lineNumber())
{
lineTo = location.lineNumber();
}
}
lineRange[0] = lineFrom;
lineRange[1] = lineTo;
}
示例4: handleNewArray
import com.sun.jdi.Location; //导入依赖的package包/类
boolean handleNewArray(final ArrayReference array, final Location location, final StackFrame frame)
{
if (array == null || !manager().generateArrayEvents())
{
return false;
}
// handle the instantiation of of small arrays
if (array != null && array.length() <= EventFactoryAdapter.SMALL_ARRAY_SIZE
&& contourFactory().lookupInstanceContour(array.type().name(), array.uniqueID()) == null)
{
handleTypeLoad((ReferenceType) array.type(), frame.thread());
// a specialized new event handles the immutable length of the array
manager().jiveDispatcher().dispatchNewEvent(array, frame.thread(), array.length());
visitArrayCells(location, frame, array);
return true;
}
return false;
}
示例5: submitCheckForMonitorEntered
import com.sun.jdi.Location; //导入依赖的package包/类
private void submitCheckForMonitorEntered(ObjectReference waitingMonitor) throws InternalExceptionWrapper, VMDisconnectedExceptionWrapper, ObjectCollectedExceptionWrapper, IllegalThreadStateExceptionWrapper {
try {
ThreadReferenceWrapper.suspend(threadReference);
logger.fine("submitCheckForMonitorEntered(): suspending "+threadName);
ObjectReference monitor = ThreadReferenceWrapper.currentContendedMonitor(threadReference);
if (monitor == null) return ;
Location loc = StackFrameWrapper.location(ThreadReferenceWrapper.frame(threadReference, 0));
loc = MethodWrapper.locationOfCodeIndex(LocationWrapper.method(loc), LocationWrapper.codeIndex(loc) + 1);
if (loc == null) return;
BreakpointRequest br = EventRequestManagerWrapper.createBreakpointRequest(
VirtualMachineWrapper.eventRequestManager(MirrorWrapper.virtualMachine(threadReference)), loc);
BreakpointRequestWrapper.addThreadFilter(br, threadReference);
submitMonitorEnteredRequest(br);
} catch (IncompatibleThreadStateException itex) {
Exceptions.printStackTrace(itex);
} catch (InvalidStackFrameExceptionWrapper isex) {
Exceptions.printStackTrace(isex);
} finally {
logger.fine("submitCheckForMonitorEntered(): resuming "+threadName);
ThreadReferenceWrapper.resume(threadReference);
}
}
示例6: doStepInto
import com.sun.jdi.Location; //导入依赖的package包/类
public static void doStepInto(final JPDADebuggerImpl debugger,
final EditorContext.Operation operation,
final Location location,
final ExpressionPool.Interval expressionLines) {
final String name = operation.getMethodName();
final boolean isNative = operation.isNative();
final String methodClassType = operation.getMethodClassType();
debugger.getRequestProcessor().post(new Runnable() {
@Override
public void run() {
RunIntoMethodActionSupport.doAction(debugger, name, methodClassType, isNative,
location, expressionLines, true,
MethodEntry.SELECTED);
}
});
}
示例7: isSyntheticMethod
import com.sun.jdi.Location; //导入依赖的package包/类
/**
* Test whether the method is considered to be synthetic
* @param m The method
* @param loc The current location in that method
* @return 0 when not synthetic
* positive when suggested step depth is returned
* negative when is synthetic and no further step depth is suggested.
*/
public static int isSyntheticMethod(Method m, Location loc) throws InternalExceptionWrapper, VMDisconnectedExceptionWrapper {
String name = TypeComponentWrapper.name(m);
if (name.startsWith("lambda$")) { // NOI18N
int lineNumber = LocationWrapper.lineNumber(loc);
if (lineNumber == 1) {
// We're in the initialization of the Lambda. We need to step over it.
return StepRequest.STEP_OVER;
}
return 0; // Do not treat Lambda methods as synthetic, because they contain user code.
} else {
// Do check the class for being Lambda synthetic class:
ReferenceType declaringType = LocationWrapper.declaringType(loc);
try {
String className = ReferenceTypeWrapper.name(declaringType);
if (className.contains("$$Lambda$")) { // NOI18N
// Lambda synthetic class
return -1;
}
} catch (ObjectCollectedExceptionWrapper ex) {
}
}
return TypeComponentWrapper.isSynthetic(m) ? -1 : 0;
}
示例8: addBreakpoint
import com.sun.jdi.Location; //导入依赖的package包/类
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();
}
}
示例9: isAtBreakpoint
import com.sun.jdi.Location; //导入依赖的package包/类
public boolean isAtBreakpoint() {
/*
* TO DO: This fails to take filters into account.
*/
try {
StackFrame frame = frame(0);
Location location = frame.location();
List<BreakpointRequest> requests = vm.eventRequestManager().breakpointRequests();
Iterator<BreakpointRequest> iter = requests.iterator();
while (iter.hasNext()) {
BreakpointRequest request = iter.next();
if (location.equals(request.location())) {
return true;
}
}
return false;
} catch (IndexOutOfBoundsException iobe) {
return false; // no frames on stack => not at breakpoint
} catch (IncompatibleThreadStateException itse) {
// Per the javadoc, not suspended => return false
return false;
}
}
示例10: LocalVariableImpl
import com.sun.jdi.Location; //导入依赖的package包/类
LocalVariableImpl(VirtualMachine vm, Method method,
int slot, Location scopeStart, Location scopeEnd,
String name, String signature,
String genericSignature) {
super(vm);
this.method = method;
this.slot = slot;
this.scopeStart = scopeStart;
this.scopeEnd = scopeEnd;
this.name = name;
this.signature = signature;
if (genericSignature != null && genericSignature.length() > 0) {
this.genericSignature = genericSignature;
} else {
// The Spec says to return null for non-generic types
this.genericSignature = null;
}
}
示例11: writeLocation
import com.sun.jdi.Location; //导入依赖的package包/类
void writeLocation(Location location) {
ReferenceTypeImpl refType = (ReferenceTypeImpl)location.declaringType();
byte tag;
if (refType instanceof ClassType) {
tag = JDWP.TypeTag.CLASS;
} else if (refType instanceof InterfaceType) {
// It's possible to have executable code in an interface
tag = JDWP.TypeTag.INTERFACE;
} else {
throw new InternalException("Invalid Location");
}
writeByte(tag);
writeClassRef(refType.ref());
writeMethodRef(((MethodImpl)location.method()).ref());
writeLong(location.codeIndex());
}
示例12: sourceNameFilter
import com.sun.jdi.Location; //导入依赖的package包/类
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;
}
}
示例13: locationsOfLine
import com.sun.jdi.Location; //导入依赖的package包/类
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));
}
示例14: allLineLocations
import com.sun.jdi.Location; //导入依赖的package包/类
public List<Location> allLineLocations(String stratumID, String sourceName)
throws AbsentInformationException {
boolean someAbsent = false; // A method that should have info, didn't
SDE.Stratum stratum = stratum(stratumID);
List<Location> list = new ArrayList<Location>(); // location list
for (Iterator<Method> iter = methods().iterator(); iter.hasNext(); ) {
MethodImpl method = (MethodImpl)iter.next();
try {
list.addAll(
method.allLineLocations(stratum, sourceName));
} catch(AbsentInformationException exc) {
someAbsent = true;
}
}
// If we retrieved no line info, and at least one of the methods
// should have had some (as determined by an
// AbsentInformationException being thrown) then we rethrow
// the AbsentInformationException.
if (someAbsent && list.size() == 0) {
throw new AbsentInformationException();
}
return list;
}
示例15: shouldDoExtraStepInto
import com.sun.jdi.Location; //导入依赖的package包/类
/**
* Check if the current top stack is same as the original top stack.
*
* @throws IncompatibleThreadStateException
* if the thread is not suspended in the target VM.
*/
private boolean shouldDoExtraStepInto(int originalStackDepth, Location originalLocation, int currentStackDepth, Location currentLocation)
throws IncompatibleThreadStateException {
if (originalStackDepth != currentStackDepth) {
return false;
}
if (originalLocation == null) {
return false;
}
Method originalMethod = originalLocation.method();
Method currentMethod = currentLocation.method();
if (!originalMethod.equals(currentMethod)) {
return false;
}
if (originalLocation.lineNumber() != currentLocation.lineNumber()) {
return false;
}
return true;
}