You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+12-2Lines changed: 12 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -23,6 +23,7 @@
23
23
*[Assembling a Classpath String](#assembling-a-classpath-string)
24
24
*[Finding a JAR File Path](#finding-a-jar-file-path)
25
25
*[Extracting the `Premain-Class` Attribute](#extracting-the-premain-class-attribute)
26
+
*[UriUtils](#uriutils) provides convenience methods for assembling **URI** objects without having to deal with **URISyntaxException**.
26
27
27
28
## StackTrace
28
29
@@ -384,8 +385,8 @@ This code uses a static import to eliminate redundant references to the **Params
384
385
385
386
The **JarUtils** class provides methods related to Java JAR files.
386
387
387
-
*`getClasspath`assemble a classpath string from the specified array of dependencies.
388
-
*`findJarPathFor`find the path to the JAR file from which the named class was loaded.
388
+
*`getClasspath`assembles a classpath string from the specified array of dependencies.
389
+
*`findJarPathFor`finds the path to the JAR file from which the named class was loaded.
389
390
*`getJarPremainClass` gets the 'Premain-Class' attribute from the indicated JAR file.
390
391
391
392
The methods of this class provide critical services for the `Local Grid` feature of [**Selenium Foundation**](https://github.com/sbabcoc/Selenium-Foundation), handling the task of locating the JAR files that declare the classes required by the Java-based servers it launches.
@@ -405,4 +406,13 @@ The **`findJarPathFor`** method will find the absolute path to the JAR file from
405
406
406
407
The **`getJarPremainClass`** method will extract the `Premain-Class` attribute from the manifest of the indicated JAR file. The value of this attribute specifies the name of a `Java agent` class declared by the JAR.
407
408
409
+
## UriUtils
410
+
411
+
As of Java 20, all of the constructors of the **URL** class have been deprecated. The recommended replacement is the **`toURL()`** method of the **URI** class, but all of the constructors of this class throw **URISyntaxtException**. While this isn't a huge ordeal, having to handle this exception in contexts where the constructor arguments have already been validated can degrade code readability with no benefit to code safety. The **UriUtils** class provides two convenience methods that employ the same strategy used by the **`create()`** method of the **URI** class - wrapping the **URISyntaxException** in an **IllegalArgumentException**:
412
+
413
+
*`makeBasicUri` assembles a basic URI from the specified components - scheme, host, port, and path.
414
+
*`uriForPath` assembles a URI for the specified path under the provided context.
415
+
416
+
Note that the **`toURL()`** method of the **URI** class throws the **MalformedURLException**, but this exception is a subclass of **IOException**, which affected code is almost certain to be handling already.
417
+
408
418
> Written with [StackEdit](https://stackedit.io/).
0 commit comments