3535import java .util .HashMap ;
3636import java .util .List ;
3737import java .util .Map ;
38+ import java .util .Optional ;
3839import java .util .Properties ;
3940import java .util .ResourceBundle ;
4041import java .util .jar .Attributes ;
@@ -635,15 +636,13 @@ private jdk.jpackage.internal.Bundler getPlatformBundler() {
635636 for (jdk .jpackage .internal .Bundler bundler :
636637 Bundlers .createBundlersInstance ().getBundlers (bundleType )) {
637638 if (type == null ) {
638- if (bundler .isDefault ()
639- && bundler .supported (runtimeInstaller )) {
640- return bundler ;
641- }
639+ if (bundler .isDefault ()) {
640+ return bundler ;
641+ }
642642 } else {
643- if ((appImage || type .equalsIgnoreCase (bundler .getID ()))
644- && bundler .supported (runtimeInstaller )) {
645- return bundler ;
646- }
643+ if (appImage || type .equalsIgnoreCase (bundler .getID ())) {
644+ return bundler ;
645+ }
647646 }
648647 }
649648 return null ;
@@ -652,8 +651,6 @@ private jdk.jpackage.internal.Bundler getPlatformBundler() {
652651 private void generateBundle (Map <String ,? super Object > params )
653652 throws PackagerException {
654653
655- boolean bundleCreated = false ;
656-
657654 // the temp dir needs to be fetched from the params early,
658655 // to prevent each copy of the params (such as may be used for
659656 // additional launchers) from generating a separate temp dir when
@@ -665,9 +662,10 @@ private void generateBundle(Map<String,? super Object> params)
665662 // determine what bundler to run
666663 jdk .jpackage .internal .Bundler bundler = getPlatformBundler ();
667664
668- if (bundler == null ) {
669- throw new PackagerException ("ERR_InvalidInstallerType" ,
670- deployParams .getTargetFormat ());
665+ if (bundler == null || !bundler .supported (runtimeInstaller )) {
666+ String type = Optional .ofNullable (bundler ).map (Bundler ::getID ).orElseGet (
667+ () -> deployParams .getTargetFormat ());
668+ throw new PackagerException ("ERR_InvalidInstallerType" , type );
671669 }
672670
673671 Map <String , ? super Object > localParams = new HashMap <>(params );
0 commit comments