public String getEventMessage(LocatableEvent event) { final Location location = event.location(); final String locationQName = location.declaringType().name() + "." + location.method().name(); String locationFileName = ""; try { locationFileName = location.sourceName(); } catch (AbsentInformationException e) { locationFileName = ""; } final int locationLine = location.lineNumber(); if (event instanceof MethodEntryEvent) { MethodEntryEvent entryEvent = (MethodEntryEvent) event; final Method method = entryEvent.method(); return DebuggerBundle.message( "status.method.entry.breakpoint.reached", method.declaringType().name() + "." + method.name() + "()", locationQName, locationFileName, locationLine); } if (event instanceof MethodExitEvent) { MethodExitEvent exitEvent = (MethodExitEvent) event; final Method method = exitEvent.method(); return DebuggerBundle.message( "status.method.exit.breakpoint.reached", method.declaringType().name() + "." + method.name() + "()", locationQName, locationFileName, locationLine); } return ""; }
private void commandMethods(StringTokenizer t) throws NoSessionException { if (!t.hasMoreTokens()) { env.error("No class specified."); return; } String idClass = t.nextToken(); ReferenceType cls = findClass(idClass); if (cls != null) { List<Method> methods = cls.allMethods(); OutputSink out = env.getOutputSink(); for (int i = 0; i < methods.size(); i++) { Method method = methods.get(i); out.print(method.declaringType().name() + " " + method.name() + "("); Iterator<String> it = method.argumentTypeNames().iterator(); if (it.hasNext()) { while (true) { out.print(it.next()); if (!it.hasNext()) { break; } out.print(", "); } } out.println(")"); } out.show(); } else { // ### Should validate class name syntax. env.failure("\"" + idClass + "\" is not a valid id or class name."); } }
protected boolean handleMethodEvent( LocatableEvent event, Method method, JDXDebugTarget target, JDXThread thread) { try { if (isNativeOnly()) { if (!method.isNative()) { return true; } } if (getMethodName() != null) { if (!method.name().equals(getMethodName())) { return true; } } if (getMethodSignature() != null) { if (!method.signature().equals(getMethodSignature())) { return true; } } if (fPattern != null) { if (!fPattern.matcher(method.declaringType().name()).find()) { return true; } } Integer count = (Integer) event.request().getProperty(HIT_COUNT); if (count != null && handleHitCount(event, count)) { return true; } return !suspendForEvent(event, thread); // Resume if suspend fails } catch (CoreException e) { Plugin.log(e); } return true; }
@Override public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { // ### We should indicate the current thread independently of the // ### selection, e.g., with an icon, because the user may change // ### the selection graphically without affecting the current // ### thread. super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (value == null) { this.setText("<unavailable>"); } else { StackFrame frame = (StackFrame) value; Location loc = frame.location(); Method meth = loc.method(); String methName = meth.declaringType().name() + '.' + meth.name(); String position = ""; if (meth.isNative()) { position = " (native method)"; } else if (loc.lineNumber() != -1) { position = ":" + loc.lineNumber(); } else { long pc = loc.codeIndex(); if (pc != -1) { position = ", pc = " + pc; } } // Indices are presented to the user starting from 1, not 0. this.setText("[" + (index + 1) + "] " + methName + position); } return this; }
private void dumpStack(ThreadReference thread, boolean showPC) { // ### Check for these. // env.failure("Thread no longer exists."); // env.failure("Target VM must be in interrupted state."); // env.failure("Current thread isn't suspended."); // ### Should handle extremely long stack traces sensibly for user. List<StackFrame> stack = null; try { stack = thread.frames(); } catch (IncompatibleThreadStateException e) { env.failure("Thread is not suspended."); } // ### Fix this! // ### Previously mishandled cases where thread was not current. // ### Now, prints all of the stack regardless of current frame. int frameIndex = 0; // int frameIndex = context.getCurrentFrameIndex(); if (stack == null) { env.failure("Thread is not running (no stack)."); } else { OutputSink out = env.getOutputSink(); int nFrames = stack.size(); for (int i = frameIndex; i < nFrames; i++) { StackFrame frame = stack.get(i); Location loc = frame.location(); Method meth = loc.method(); out.print(" [" + (i + 1) + "] "); out.print(meth.declaringType().name()); out.print('.'); out.print(meth.name()); out.print(" ("); if (meth.isNative()) { out.print("native method"); } else if (loc.lineNumber() != -1) { try { out.print(loc.sourceName()); } catch (AbsentInformationException e) { out.print("<unknown>"); } out.print(':'); out.print(loc.lineNumber()); } out.print(')'); if (showPC) { long pc = loc.codeIndex(); if (pc != -1) { out.print(", pc = " + pc); } } out.println(); } out.show(); } }
void validateConstructorInvocation(Method method) throws InvalidTypeException, InvocationException { /* * Method must be in this class. */ ReferenceTypeImpl declType = (ReferenceTypeImpl) method.declaringType(); if (!declType.equals(this)) { throw new IllegalArgumentException("Invalid constructor"); } /* * Method must be a constructor */ if (!method.isConstructor()) { throw new IllegalArgumentException("Cannot create instance with non-constructor"); } }
public boolean isEmptyAnonymousClassConstructor(final SuspendContext context) { try { StackFrameProxy _frameProxy = context.getFrameProxy(); final Location location = _frameProxy.location(); boolean _notEquals = (!Objects.equal(location, null)); if (_notEquals) { final Method method = location.method(); if (((((!Objects.equal(method, null)) && method.isConstructor()) && method.argumentTypes().isEmpty()) && (method.declaringType().name().indexOf("$") > 0))) { return true; } } return false; } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
void validateMethodInvocation(Method method) throws InvalidTypeException, InvocationException { /* * Method must be in this class or a superclass. */ ReferenceTypeImpl declType = (ReferenceTypeImpl) method.declaringType(); if (!declType.isAssignableFrom(this)) { throw new IllegalArgumentException("Invalid method"); } /* * Method must be a static and not a static initializer */ if (!method.isStatic()) { throw new IllegalArgumentException("Cannot invoke instance method on a class type"); } else if (method.isStaticInitializer()) { throw new IllegalArgumentException("Cannot invoke static initializer"); } }
public Type findType(String signature) throws ClassNotLoadedException { ReferenceTypeImpl enclosing = (ReferenceTypeImpl) method.declaringType(); return enclosing.findType(signature); }
public static String methodName(final Method m) { return methodName(signatureToName(m.declaringType().signature()), m.name(), m.signature()); }