private void setPreferredClassType(LineBreakpoint lb, JPDAClassType classType) { try { Method setPreferredClassTypeMethod = lb.getClass().getMethod("setPreferredClassType", JPDAClassType.class); setPreferredClassTypeMethod.setAccessible(true); setPreferredClassTypeMethod.invoke(lb, classType); } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { Exceptions.printStackTrace(ex); lb.setPreferredClassName(source.getClassType().getName()); } }
public static Variable getSourceInfo(JPDADebugger debugger, JPDAClassType classType) { List<JPDAClassType> supportClasses = debugger.getClassesByName(DEBUGGER_SUPPORT_CLASS); if (supportClasses.isEmpty()) { return null; } JPDAClassType supportClass = supportClasses.get(0); try { Variable sourceInfo = supportClass.invokeMethod(METHOD_SOURCE_INFO, SIGNAT_SOURCE_INFO, new Variable[] { classType.classObject() }); return sourceInfo; } catch (NoSuchMethodException | InvalidExpressionException ex) { return null; } }
private static ObjectVariable getSourceVar(JPDADebugger debugger, JPDAClassType classType) { List<Field> staticFields = classType.staticFields(); for (Field sf : staticFields) { if (sf instanceof ObjectVariable && SOURCE_FIELD.equals(sf.getName()) && SOURCE_CLASS.equals(sf.getType())) { return (ObjectVariable) sf; } } return null; }
superTypeVar = superTypeVar.getSuper(); List<JPDAClassType> allInterfaces = thisVar.getClassType().getAllInterfaces(); for (JPDAClassType intrfc : allInterfaces) { superTypeNames.add(intrfc.getName());
public static Variable getVarStringValueAsVar(JPDADebugger debugger, ObjectVariable ov) { List<JPDAClassType> supportClasses = debugger.getClassesByName(DEBUGGER_SUPPORT_CLASS); if (supportClasses.isEmpty()) { return ov; } JPDAClassType supportClass = supportClasses.get(0); Variable[] args = new Variable[1]; try { args[0] = ov; Variable strVar = supportClass.invokeMethod(METHOD_VALUE_AS_STRING, SIGNAT_VALUE_AS_STRING, args); // This method returns quoted value. :-( if (String.class.getName().equals(strVar.getType())) { return adjustQuotes(debugger, (ObjectVariable) strVar); } else { return strVar; } } catch (NoSuchMethodException | InvalidExpressionException ex) { Exceptions.printStackTrace(ex); return ov; } }
public static Source getSource(JPDAClassType classType) { long uniqueClassID = classType.classObject().getUniqueID();
static Variable[] getValueInfos(JPDADebugger debugger, Variable scope, boolean all) { List<JPDAClassType> supportClasses = debugger.getClassesByName(DEBUGGER_SUPPORT_CLASS); if (supportClasses.isEmpty()) { return null; } JPDAClassType supportClass = supportClasses.get(0); Variable[] args = new Variable[2]; try { args[0] = scope; args[1] = debugger.createMirrorVar(all, true); ObjectVariable infosVar = (ObjectVariable) supportClass.invokeMethod(METHOD_VALUE_INFOS, SIGNAT_VALUE_INFOS, args); return infosVar.getFields(0, Integer.MAX_VALUE); } catch (InvalidObjectException ioex) { return null; } catch (NoSuchMethodException | InvalidExpressionException nsmex) { Exceptions.printStackTrace(nsmex); return null; } }
public static Source getSource(JPDADebugger debugger, JPDAClassType classType, ObjectVariable sourceVar) { long uniqueClassID = classType.classObject().getUniqueID(); Field fieldName = sourceVar.getField(SOURCE_VAR_NAME); Field fieldContent = sourceVar.getField(SOURCE_VAR_CONTENT);
public String getURL(JPDAClassType clazz, String stratum) { if (!(stratum == null || JSUtils.JS_STRATUM.equals(stratum)) || !clazz.getName().startsWith(JSUtils.NASHORN_SCRIPT)) { return null; } Source source = Source.getSource(clazz); if (source == null) { return null; } URL url = source.getRuntimeURL(); if (url == null) { url = source.getUrl(); } if (url != null) { return url.toExternalForm(); } else { return null; } }
static Variable getValueInfoDesc(JPDADebugger debugger, String name, Variable value, boolean all) { List<JPDAClassType> supportClasses = debugger.getClassesByName(DEBUGGER_SUPPORT_CLASS); if (supportClasses.isEmpty()) { return null; } JPDAClassType supportClass = supportClasses.get(0); Variable[] args = new Variable[3]; try { args[0] = debugger.createMirrorVar(name); args[1] = value; args[2] = debugger.createMirrorVar(all, true); return supportClass.invokeMethod(METHOD_VALUE_INFO, SIGNAT_VALUE_INFO, args); } catch (InvalidObjectException | InvalidExpressionException iex) { return null; } catch (NoSuchMethodException nsmex) { Exceptions.printStackTrace(nsmex); return null; } }
this.classType = classType; if (LOG.isLoggable(Level.FINE)) { LOG.fine("new Source("+name+", "+classType.getName()+", "+url+")");
try { args[0] = var; var = supportClass.invokeMethod(METHOD_VALUE_AS_STRING, SIGNAT_VALUE_AS_STRING, args); } catch (NoSuchMethodException ex) { Exceptions.printStackTrace(ex);
private void scriptToBeInvoked(ObjectVariable mh) { ObjectVariable member = (ObjectVariable) mh.getField("member"); if (!(member instanceof ObjectVariable)) { logger.info("Variable "+mh+" does not have member field: "+member); return ; } ObjectVariable clazz = (ObjectVariable) member.getField("clazz"); if (!(clazz instanceof ClassVariable)) { logger.info("Variable "+mh+" does not have clazz field: "+clazz); return ; } //JPDAClassType classType = ((ClassVariable) clazz).getReflectedType(); JPDAClassType classType; try { classType = (JPDAClassType) clazz.getClass().getMethod("getReflectedType").invoke(clazz); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException ex) { Exceptions.printStackTrace(ex); return ; } String className = classType.getName(); MethodBreakpoint mb = MethodBreakpoint.create(className, ""); mb.setHidden(true); mb.setSuspend(debugger.getSuspend()); mb.setSession(debugger); mb.addJPDABreakpointListener(new InScriptBPListener(mb)); DebuggerManager.getDebuggerManager().addBreakpoint(mb); logger.log(Level.FINE, "Created {0} for any method in {1}", new Object[]{mb, className}); }
args[2] = debugger.createMirrorVar(expression); args[3] = debugger.createMirrorVar(false, true); return supportClass.invokeMethod(METHOD_EVAL, SIGNAT_EVAL, args); } catch (InvalidObjectException ioex) { Exceptions.printStackTrace(ioex);
private LineBreakpoint createLineBreakpoint() { int lineNo = jslb.getLineNumber(); lineNo += source.getContentLineShift(); LineBreakpoint lb = LineBreakpoint.create("", lineNo); lb.setHidden(true); //lb.setPreferredClassType(source.getClassType()); setPreferredClassType(lb, source.getClassType()); if (LOG.isLoggable(Level.FINE)) { LOG.fine("LineBreakpointHandler.createLineBreakpoint() classtype = "+source.getClassType().getName()); } lb.setSuspend(JPDABreakpoint.SUSPEND_EVENT_THREAD); lb.setSession(debugger); if (!jslb.isEnabled()) { lb.disable(); } return lb; }
MethodBreakpoint scriptMethodBP = MethodBreakpoint.create(scriptType.getName(), "*getMap"); scriptMethodBP.setHidden(true); scriptMethodBP.setSuspend(EventRequest.SUSPEND_EVENT_THREAD);