4040import java .io .File ;
4141import java .io .FilePermission ;
4242import java .io .IOException ;
43- import java .net .MalformedURLException ;
4443import java .net .URI ;
4544import java .net .URISyntaxException ;
46- import java .net . URL ;
45+ import java .util . Objects ;
4746
4847import javax .swing .JMenuBar ;
4948
@@ -505,13 +504,6 @@ public void print(File file) throws IOException {
505504 * {@code URIs} of the specified type is invoked. The application
506505 * is determined from the protocol and path of the {@code URI}, as
507506 * defined by the {@code URI} class.
508- * <p>
509- * If the calling thread does not have the necessary permissions,
510- * and this is invoked from within an applet,
511- * {@code AppletContext.showDocument()} is used. Similarly, if the calling
512- * does not have the necessary permissions, and this is invoked from within
513- * a Java Web Started application, {@code BasicService.showDocument()}
514- * is used.
515507 *
516508 * @param uri the URI to be displayed in the user default browser
517509 * @throws NullPointerException if {@code uri} is {@code null}
@@ -524,46 +516,16 @@ public void print(File file) throws IOException {
524516 * denies the
525517 * {@code AWTPermission("showWindowWithoutWarningBanner")}
526518 * permission, or the calling thread is not allowed to create a
527- * subprocess; and not invoked from within an applet or Java Web Started
528- * application
529- * @throws IllegalArgumentException if the necessary permissions
530- * are not available and the URI can not be converted to a {@code URL}
519+ * subprocess
531520 * @see java.net.URI
532521 * @see java.awt.AWTPermission
533- * @see java.applet.AppletContext
534522 */
535523 public void browse (URI uri ) throws IOException {
536- SecurityException securityException = null ;
537- try {
538- checkAWTPermission ();
539- checkExec ();
540- } catch (SecurityException e ) {
541- securityException = e ;
542- }
524+ checkAWTPermission ();
525+ checkExec ();
543526 checkActionSupport (Action .BROWSE );
544- if (uri == null ) {
545- throw new NullPointerException ();
546- }
547- if (securityException == null ) {
548- peer .browse (uri );
549- return ;
550- }
551-
552- // Calling thread doesn't have necessary privileges.
553- // Delegate to DesktopBrowse so that it can work in
554- // applet/webstart.
555- URL url = null ;
556- try {
557- url = uri .toURL ();
558- } catch (MalformedURLException e ) {
559- throw new IllegalArgumentException ("Unable to convert URI to URL" , e );
560- }
561- sun .awt .DesktopBrowse db = sun .awt .DesktopBrowse .getInstance ();
562- if (db == null ) {
563- // Not in webstart/applet, throw the exception.
564- throw securityException ;
565- }
566- db .browse (url );
527+ Objects .requireNonNull (uri );
528+ peer .browse (uri );
567529 }
568530
569531 /**
0 commit comments