--- old/src/jdk.jartool/share/classes/sun/tools/jar/Main.java 2018-11-26 13:25:39.000000000 -0500 +++ new/src/jdk.jartool/share/classes/sun/tools/jar/Main.java 2018-11-26 13:25:38.000000000 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -693,7 +693,7 @@ usageError(getMsg("error.bad.cflag")); return false; } else if (uflag) { - if ((mname != null) || (ename != null)) { + if ((mname != null) || (ename != null) || moduleVersion != null) { /* just want to update the manifest */ return true; } else { --- old/test/jdk/tools/jar/modularJar/Basic.java 2018-11-26 13:25:40.000000000 -0500 +++ new/test/jdk/tools/jar/modularJar/Basic.java 2018-11-26 13:25:40.000000000 -0500 @@ -46,7 +46,7 @@ /* * @test - * @bug 8167328 8171830 8165640 8174248 8176772 8196748 8191533 + * @bug 8167328 8171830 8165640 8174248 8176772 8196748 8191533 8210454 * @library /test/lib * @modules jdk.compiler * jdk.jartool @@ -878,6 +878,50 @@ } } + /** + * Validate that you can update a jar only specifying --module-version + * @throws IOException + */ + @Test + public void updateFooModuleVersion() throws IOException { + Path mp = Paths.get("updateFooModuleVersion"); + createTestDir(mp); + Path modClasses = MODULE_CLASSES.resolve(FOO.moduleName); + Path modularJar = mp.resolve(FOO.moduleName + ".jar"); + String newFooVersion = "87.0"; + + jar("--create", + "--file=" + modularJar.toString(), + "--main-class=" + FOO.mainClass, + "--module-version=" + FOO.version, + "--no-manifest", + "-C", modClasses.toString(), ".") + .assertSuccess(); + + jarWithStdin(modularJar.toFile(), "--describe-module") + .assertSuccess() + .resultChecker(r -> + assertTrue(r.output.contains(FOO.moduleName + "@" + FOO.version), + "Expected to find ", FOO.moduleName + "@" + FOO.version, + " in [", r.output, "]") + ); + + jar("--update", + "--file=" + modularJar.toString(), + "--module-version=" + newFooVersion) + .assertSuccess(); + + for (String option : new String[] {"--describe-module", "-d" }) { + jarWithStdin(modularJar.toFile(), + option) + .assertSuccess() + .resultChecker(r -> + assertTrue(r.output.contains(FOO.moduleName + "@" + newFooVersion), + "Expected to find ", FOO.moduleName + "@" + newFooVersion, + " in [", r.output, "]") + ); + } + } @DataProvider(name = "autoNames") public Object[][] autoNames() {