object JDITools extends JDITools
Exposes utility methods related to the Java Debugger Interface.
- Alphabetic
- By Inheritance
- JDITools
- JDITools
- JDILoader
- Logging
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
-
implicit
class
LoggerExtras
extends AnyRef
- Definition Classes
- Logging
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
classForName(name: String, initialize: Boolean = true, classLoader: ClassLoader = getSystemClassLoader): Class[_]
Attempts to load the specified class.
Attempts to load the specified class.
- name
The full name of the class to load
- initialize
If true, initializes the class
- classLoader
The class loader to use for loading the class, defaults to the system class loader
- returns
The class loaded by the class loader
- Attributes
- protected
- Definition Classes
- JDILoader
- Annotations
- @throws( classOf[ClassNotFoundException] )
- Exceptions thrown
ClassNotFoundException
If the class was not found using the class loader or any of its parents- Note
Exposed for testing!
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
findOpenPort(): Option[Int]
Returns a random port that is currently open.
Returns a random port that is currently open. Note that there is no safety condition preventing this port from being taken later.
- returns
The number of the port
- Definition Classes
- JDITools
-
def
findPotentialJdkJarPaths(jarPath: String): Seq[String]
Attempts to find potential paths for a jar in the JDK.
Attempts to find potential paths for a jar in the JDK.
- jarPath
The path to the jar relative to the JDK
- returns
The sequence of potential paths
- Attributes
- protected
- Definition Classes
- JDILoader
-
def
generateJdwpString(port: Int, transport: String = "dt_socket", server: Boolean = true, suspend: Boolean = false, hostname: String = ""): String
Generates a JDWP string for use when launching JVMs.
Generates a JDWP string for use when launching JVMs.
- port
The port used to connect to a debugger or listen for debugger connections
- transport
The means of communication (defaults to dt_socket)
- server
If true, indicates that the target JVM should run as a server listening on the provided port for debugger connections; if false, indicates that the target JVM should connect to a debugger using the provided port
- suspend
If true, indicates that the target JVM should start up suspended until a connection with a debugger has been established
- hostname
If provided, used as the hostname to connect or bind to depending on the server flag
- returns
The string representing the JDWP settings
- Definition Classes
- JDITools
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
-
def
getJavaClassPath: String
Retrieves the system property for java.class.path.
Retrieves the system property for java.class.path.
- returns
The string representing the 'java.class.path' system property
- Attributes
- protected
- Definition Classes
- JDITools
-
def
getPathSeparator: String
Retrieves the system property for path.separator.
Retrieves the system property for path.separator.
- returns
The string representing the 'path.separator' system property
- Attributes
- protected
- Definition Classes
- JDITools
-
def
getSystemClassLoader: ClassLoader
Retrieves the system classloader.
-
def
getUserDir: String
Retrieves the system property for user.dir.
Retrieves the system property for user.dir.
- returns
The string representing the 'user.dir' system property
- Attributes
- protected
- Definition Classes
- JDITools
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
isJdiAvailable(classLoader: ClassLoader = _classLoader): Boolean
Checks if it is possible to use the JDI using either the given class loader or by using a jar located in the JDK (if possible).
Checks if it is possible to use the JDI using either the given class loader or by using a jar located in the JDK (if possible).
- classLoader
The class loader to use to check for JDI (default is this class's class loader)
- returns
True if JDI is able to be loaded, otherwise false
- Definition Classes
- JDILoader
-
def
javaProcesses(javaProcessFunc: (String) ⇒ Option[JavaProcess] = ...): Seq[JavaProcess]
Collects a list of active Java processes using the JPS tool.
Collects a list of active Java processes using the JPS tool.
- javaProcessFunc
Optional function to convert line of text into a Java process instance
- returns
The collection of active Java processes
- Definition Classes
- JDITools
- Note
Will fail if the JPS tool is not on PATH.
-
def
jvmClassPath: String
Retrieves a JVM classpath string that contains the current classpath.
Retrieves a JVM classpath string that contains the current classpath.
- returns
The classpath as a string
- Definition Classes
- JDITools
-
val
logger: Logger
- Attributes
- protected
- Definition Classes
- Logging
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
newJDIProcess(): JDIProcess
Creates a new JDI process instance.
Creates a new JDI process instance.
- returns
The new JDI process instance
- Attributes
- protected
- Definition Classes
- JDITools
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
-
def
scalaClassStringToFileString(classString: String): String
Converts a class string to a file string.
Converts a class string to a file string.
- classString
The class string to convert
- returns
The resulting file string
- Definition Classes
- JDITools
org.senkbeil.MyClass becomes org/senkbeil/MyClass.scala
Example: -
def
spawn(className: String, port: Int, hostname: String = "", server: Boolean = true, suspend: Boolean = false, args: Seq[String] = Nil, options: Seq[String] = Nil): Process
Spawns a new Scala process using the provided class name as the entrypoint.
Spawns a new Scala process using the provided class name as the entrypoint.
- className
The name of the class to use as the entrypoint for the Scala process
- port
The port to use for the Scala process to listen on
- hostname
Optional hostname to use for the Scala process to listen on
- server
Whether or not to launch the process as a server waiting for a debugger connection or a client connecting to a listening debugger
- suspend
Whether or not to start the process suspended until a debugger attaches to it or it attaches to a debugger
- args
The collection of arguments to pass to the Scala process
- options
Any additional JVM options to pass to the Scala process
- returns
The created Scala process
- Definition Classes
- JDITools
- Note
Assumes that Scala is available on the path!
-
def
spawnAndGetPid(className: String, port: Int, hostname: String = "", server: Boolean = true, args: Seq[String] = Nil, options: Seq[String] = Nil): (Int, Process)
Spawns a new Scala process using the provided class name as the entrypoint.
Spawns a new Scala process using the provided class name as the entrypoint. Retrieves the PID of the process. The spawned JVM cannot start suspended.
- className
The name of the class to use as the entrypoint for the Scala process
- port
The port to use for the Scala process to listen on
- hostname
Optional hostname to use for the Scala process to listen on
- server
Whether or not to launch the process as a server waiting for a debugger connection or a client connecting to a listening debugger
- args
The collection of arguments to pass to the Scala process
- options
Any additional JVM options to pass to the Scala process
- returns
The tuple containing the PID (or 0 if failed to retrieve) and the Scala process
- Definition Classes
- JDITools
- Note
Assumes that Scala is available on the path!
-
def
spawnJavaProcessRetrieval(): Process
Spawns a new process to retrieve the list of Java processes.
Spawns a new process to retrieve the list of Java processes.
- returns
The process instance
- Attributes
- protected
- Definition Classes
- JDITools
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
def
tryLoadJdi(classLoader: ClassLoader = _classLoader): Boolean
Attempts to ensure that the JDI is loaded.
Attempts to ensure that the JDI is loaded. First, checks if the JDI is already available. If not, attempts to find a JDK path and load it.
- classLoader
The class loader to use to check for JDI (default is this class's class loader)
- returns
True if successful, otherwise false
- Definition Classes
- JDILoader
-
def
usingOpenPort[T](f: (Int) ⇒ T): T
Finds an open port and provides it to the specified function.
Finds an open port and provides it to the specified function. This method is synchronized to prevent other threads within the same application from accidentally taking the same port when using this method; however, this does not prevent external applications from consuming the provided port.
- T
The return value from the function to evaluate
- f
The function to evaluate, taking the open port as its argument
- returns
The result of the evaluated function
- Definition Classes
- JDITools
- Annotations
- @throws( ... )
- Exceptions thrown
IOException
When no port is available
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )