diff --git a/java/debugger.jpda/test/unit/src/org/netbeans/api/debugger/jpda/JPDASupport.java b/java/debugger.jpda/test/unit/src/org/netbeans/api/debugger/jpda/JPDASupport.java index 28c45f59406e..0a2112f4696c 100644 --- a/java/debugger.jpda/test/unit/src/org/netbeans/api/debugger/jpda/JPDASupport.java +++ b/java/debugger.jpda/test/unit/src/org/netbeans/api/debugger/jpda/JPDASupport.java @@ -90,7 +90,7 @@ private JPDASupport (JPDADebugger jpdaDebugger, ProcessIO pio) { public static Test createTestSuite(Class clazz) { Configuration suiteConfiguration = NbModuleSuite.createConfiguration(clazz); - suiteConfiguration = suiteConfiguration.clusters(".*").enableModules(".*java.source.*").gui(false); + suiteConfiguration = suiteConfiguration.clusters(".*").enableModules(".*java.source.*").enableModules(".*libs.nbjavacapi.*").gui(false); if (!(ClassLoader.getSystemClassLoader() instanceof URLClassLoader)) { //when running on JDK 9+, to make the com.sun.jdi package dependency work, we need to make getPackage("com.sun.jdi") work //for system CL's parent (which otherwise happily loads the VirtualMachineManager class, diff --git a/java/java.source.base/manifest.mf b/java/java.source.base/manifest.mf index e47516a822f0..8e95ab8e592a 100644 --- a/java/java.source.base/manifest.mf +++ b/java/java.source.base/manifest.mf @@ -3,4 +3,3 @@ OpenIDE-Module: org.netbeans.modules.java.source.base OpenIDE-Module-Implementation-Version: 6 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/java/source/base/Bundle.properties OpenIDE-Module-Layer: org/netbeans/modules/java/source/base/layer.xml -OpenIDE-Module-Recommends: org.netbeans.libs.nbjavac diff --git a/nb/ide.branding/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/wizards/Bundle_nb.properties b/nb/ide.branding/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/wizards/Bundle_nb.properties index c311ec410e86..376d282d3b23 100644 --- a/nb/ide.branding/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/wizards/Bundle_nb.properties +++ b/nb/ide.branding/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/wizards/Bundle_nb.properties @@ -24,6 +24,8 @@ InstallStep_Header_Restart_Head=Restart NetBeans IDE to complete installation. InstallStep_Header_Restart_Content=Restart NetBeans IDE to finish plugin installation. UninstallStep_Header_Restart_Head=Restart NetBeans IDE to complete deactivation. UninstallStep_Header_Restart_Content=Restart NetBeans IDE to finish plugin deactivation. +UninstallStep_Activate_Header_Restart_Head=Restart NetBeans IDE to complete activation. +UninstallStep_Activate_Header_Restart_Content=Restart NetBeans IDE to finish plugin activation. InstallUnitWizardModel_Buttons_RestartNow=&Restart IDE Now InstallUnitWizardModel_Buttons_RestartLater=Restart IDE &Later InstallStep_InstallDone_Text=The NetBeans IDE Installer has successfully \ diff --git a/platform/autoupdate.services/libsrc/org/netbeans/updater/Bundle.properties b/platform/autoupdate.services/libsrc/org/netbeans/updater/Bundle.properties index 5afe441dd067..936ee3324c7a 100644 --- a/platform/autoupdate.services/libsrc/org/netbeans/updater/Bundle.properties +++ b/platform/autoupdate.services/libsrc/org/netbeans/updater/Bundle.properties @@ -20,6 +20,7 @@ CTL_UnpackingFile=Unpacking CTL_DownloadingFile=Downloading CTL_DeletingFiles=Uninstalling files... CTL_DisablingFiles=Deactivating files... +CTL_EnablingFiles=Enabling files... UpdaterFrame.jTextArea1.text=Update is in progress.\n\nPlease wait... UpdaterFrame.textLabel.text=Preparing to Unpack UpdaterFrame.Form.title=Updater diff --git a/platform/autoupdate.services/libsrc/org/netbeans/updater/ModuleDeactivator.java b/platform/autoupdate.services/libsrc/org/netbeans/updater/ModuleDeactivator.java index 4613e5d6c3be..325858a86493 100644 --- a/platform/autoupdate.services/libsrc/org/netbeans/updater/ModuleDeactivator.java +++ b/platform/autoupdate.services/libsrc/org/netbeans/updater/ModuleDeactivator.java @@ -31,6 +31,7 @@ public final class ModuleDeactivator extends Object { public static final String TO_UNINSTALL = "to_uninstall.txt"; // NOI18N public static final String TO_DISABLE = "to_disable.txt"; // NOI18N + public static final String TO_ENABLE = "to_enable.txt"; // NOI18N public static final String CONFIG = "config"; // NOI18N public static final String MODULES = "Modules"; // NOI18N @@ -60,19 +61,22 @@ public void delete () { } } - public void disable () { + public void enableDisable(boolean enable) { assert ! SwingUtilities.isEventDispatchThread () : "Cannot run in EQ"; - context.setLabel (Localization.getBrandedString ("CTL_DisablingFiles")); + context.setLabel (enable ? Localization.getBrandedString ("CTL_EnablingFiles") + : Localization.getBrandedString ("CTL_DisablingFiles")); Collection allControlFiles = new HashSet (); for (File cluster : UpdateTracking.clusters (true)) { - allControlFiles.addAll (readFilesMarkedForDisableInCluster (cluster)); - doDelete (getControlFileForMarkedForDisable (cluster)); - doDelete (getDeactivateLater (cluster)); + allControlFiles.addAll (readFilesMarkedForEnableDisableInCluster(cluster, enable)); + doDelete (getControlFileForMarkedForEnableDisable(cluster, enable)); + if (!enable) { + doDelete (getDeactivateLater (cluster)); + } } context.setProgressRange (0, allControlFiles.size ()); int i = 0; for (File f : allControlFiles) { - doDisable (f); + doEnableDisable(f, enable); context.setProgressValue (i ++); } } @@ -87,6 +91,11 @@ public static boolean hasModulesForDisable (File updateDir) { return deactivateDir.exists () && deactivateDir.isDirectory () && Arrays.asList (deactivateDir.list ()).contains (TO_DISABLE); } + public static boolean hasModulesForEnable (File updateDir) { + File deactivateDir = new File (updateDir, UpdaterDispatcher.DEACTIVATE_DIR); + return deactivateDir.exists () && deactivateDir.isDirectory () && Arrays.asList (deactivateDir.list ()).contains (TO_ENABLE); + } + public static File getDeactivateLater (File cluster) { File file = new File (cluster, UpdaterDispatcher.UPDATE_DIR + // update @@ -103,11 +112,13 @@ public static File getControlFileForMarkedForDelete (File cluster) { return file; } - public static File getControlFileForMarkedForDisable (File cluster) { + public static File getControlFileForMarkedForEnableDisable (File cluster, boolean enable) { + String fileName = enable ? ModuleDeactivator.TO_ENABLE // to_enable.txt + : ModuleDeactivator.TO_DISABLE; // to_disable.txt File file = new File (cluster, UpdaterDispatcher.UPDATE_DIR + // update UpdateTracking.FILE_SEPARATOR + UpdaterDispatcher.DEACTIVATE_DIR + // update/deactivate - UpdateTracking.FILE_SEPARATOR + ModuleDeactivator.TO_DISABLE); // to_disable.txt + UpdateTracking.FILE_SEPARATOR + fileName); return file; } @@ -219,9 +230,9 @@ private static Set readFilesMarkedForDeleteInCluster (File cluster) { return toDelete; } - private static Set readFilesMarkedForDisableInCluster (File cluster) { + private static Set readFilesMarkedForEnableDisableInCluster (File cluster, boolean enable) { - File mark4disableFile = getControlFileForMarkedForDisable (cluster); + File mark4disableFile = getControlFileForMarkedForEnableDisable(cluster, enable); if (! mark4disableFile.exists ()) { return Collections.emptySet (); } @@ -244,18 +255,24 @@ private static Set readFilesMarkedForDisableInCluster (File cluster) { private static String ENABLE_TAG = "true"; private static String DISABLE_TAG = "false"; - private static void doDisable (File f) { + private static void doEnableDisable (File f, boolean enable) { + String expected = enable ? DISABLE_TAG : ENABLE_TAG; + String target = enable ? ENABLE_TAG : DISABLE_TAG; + String content = readStringFromFile (f); - int pos = content.indexOf (ENABLE_TAG); - assert pos != -1 : ENABLE_TAG + " must be contained in " + content; - int shift = ENABLE_TAG.length (); - String pre = content.substring (0, pos); - String post = content.substring (pos + shift); - String res = pre + DISABLE_TAG + post; + if (!content.contains(target)) { + int pos = content.indexOf(expected); + assert pos != -1 : expected + " must be contained in " + content; + int shift = expected.length (); + String pre = content.substring (0, pos); + String post = content.substring (pos + shift); + + content = pre + target + post; + } File configDir = new File (new File (UpdateTracking.getUserDir (), CONFIG), MODULES); configDir.mkdirs (); File dest = new File (configDir, f.getName()); - writeStringToFile (res, dest); + writeStringToFile (content, dest); } } diff --git a/platform/autoupdate.services/libsrc/org/netbeans/updater/UpdaterDispatcher.java b/platform/autoupdate.services/libsrc/org/netbeans/updater/UpdaterDispatcher.java index 4fe0be9f21a8..22b35898033f 100644 --- a/platform/autoupdate.services/libsrc/org/netbeans/updater/UpdaterDispatcher.java +++ b/platform/autoupdate.services/libsrc/org/netbeans/updater/UpdaterDispatcher.java @@ -29,6 +29,7 @@ */ public final class UpdaterDispatcher implements Runnable { private Boolean disable = null; + private Boolean enable = null; private Boolean install = null; private Boolean uninstall = null; @@ -60,7 +61,12 @@ private void dispatch () { // then disable if (isDisableScheduled ()) { - new ModuleDeactivator(context).disable(); + new ModuleDeactivator(context).enableDisable(false); + } + + // then disable + if (isEnableScheduled()) { + new ModuleDeactivator(context).enableDisable(true); } // finally install/update @@ -87,6 +93,13 @@ private boolean isDisableScheduled () { return disable; } + private boolean isEnableScheduled () { + if (enable == null) { + exploreUpdateDir (); + } + return enable; + } + private boolean isUninstallScheduled () { if (uninstall == null) { exploreUpdateDir (); @@ -106,6 +119,7 @@ private void exploreUpdateDir () { install = false; uninstall = false; disable = false; + enable = false; // go over all clusters for (File cluster : UpdateTracking.clusters (true)) { @@ -123,6 +137,10 @@ private void exploreUpdateDir () { if (disable == null || ! disable) { disable = ModuleDeactivator.hasModulesForDisable (updateDir); } + // enable + if (enable == null || ! enable) { + enable = ModuleDeactivator.hasModulesForEnable (updateDir); + } } } } diff --git a/platform/autoupdate.services/src/org/netbeans/modules/autoupdate/services/ModuleDeleterImpl.java b/platform/autoupdate.services/src/org/netbeans/modules/autoupdate/services/ModuleEnableDisableDeleteHelper.java similarity index 94% rename from platform/autoupdate.services/src/org/netbeans/modules/autoupdate/services/ModuleDeleterImpl.java rename to platform/autoupdate.services/src/org/netbeans/modules/autoupdate/services/ModuleEnableDisableDeleteHelper.java index babb7ff35385..4d3cf7542c54 100644 --- a/platform/autoupdate.services/src/org/netbeans/modules/autoupdate/services/ModuleDeleterImpl.java +++ b/platform/autoupdate.services/src/org/netbeans/modules/autoupdate/services/ModuleEnableDisableDeleteHelper.java @@ -59,18 +59,18 @@ * * @author Jiri Rechtacek */ -public final class ModuleDeleterImpl { - private static final ModuleDeleterImpl INSTANCE = new ModuleDeleterImpl(); +public final class ModuleEnableDisableDeleteHelper { + private static final ModuleEnableDisableDeleteHelper INSTANCE = new ModuleEnableDisableDeleteHelper(); private static final String ELEMENT_MODULE = "module"; // NOI18N private static final String ELEMENT_VERSION = "module_version"; // NOI18N private static final String ATTR_LAST = "last"; // NOI18N private static final String ATTR_FILE_NAME = "name"; // NOI18N - private static final Logger err = Logger.getLogger (ModuleDeleterImpl.class.getName ()); // NOI18N + private static final Logger err = Logger.getLogger (ModuleEnableDisableDeleteHelper.class.getName ()); // NOI18N private Set storageFilesForDelete = null; - public static ModuleDeleterImpl getInstance() { + public static ModuleEnableDisableDeleteHelper getInstance() { return INSTANCE; } @@ -88,7 +88,7 @@ public boolean canDelete (ModuleInfo moduleInfo) { } } - public Collection markForDisable (Collection modules, ProgressHandle handle) { + public Collection findControlFiles(Collection modules, ProgressHandle handle) { if (modules == null) { throw new IllegalArgumentException ("ModuleInfo argument cannot be null."); } @@ -96,7 +96,11 @@ public Collection markForDisable (Collection modules, Progress if (handle != null) { handle.switchToDeterminate (modules.size() + 1); } - + + return doFindControlFiles(modules, handle); + } + + private Collection doFindControlFiles(Collection modules, ProgressHandle handle) { Collection configs = new HashSet (); int i = 0; for (ModuleInfo moduleInfo : modules) { @@ -125,18 +129,9 @@ public Collection markForDelete (Collection modules, ProgressH handle.switchToDeterminate (modules.size () * 2 + 1); } - Collection configFiles = new HashSet (); - int i = 0; - for (ModuleInfo moduleInfo : modules) { - Collection configs = locateAllConfigFiles (moduleInfo); - assert configs != null : "Located config files for " + moduleInfo.getCodeName (); - assert ! configs.isEmpty () : configs + " config files must exists for " + moduleInfo.getCodeName (); - configFiles.addAll (configs); - err.log(Level.FINE, "Locate config files of " + moduleInfo.getCodeNameBase () + ": " + configs); - if (handle != null) { - handle.progress (++i); - } - } + Collection configFiles = doFindControlFiles(modules, handle); + int i = configFiles.size(); + getStorageFilesForDelete ().addAll (configFiles); for (ModuleInfo moduleInfo : modules) { diff --git a/platform/autoupdate.services/src/org/netbeans/modules/autoupdate/services/OperationSupportImpl.java b/platform/autoupdate.services/src/org/netbeans/modules/autoupdate/services/OperationSupportImpl.java index f0225e29e583..590a545e06d5 100644 --- a/platform/autoupdate.services/src/org/netbeans/modules/autoupdate/services/OperationSupportImpl.java +++ b/platform/autoupdate.services/src/org/netbeans/modules/autoupdate/services/OperationSupportImpl.java @@ -95,6 +95,8 @@ private OperationSupportImpl() { } private static class ForEnable extends OperationSupportImpl { + private Collection controlFileForEnable = null; + private Collection affectedModules = null; @Override public synchronized Boolean doOperation(ProgressHandle progress, OperationContainer container) throws OperationException { @@ -128,21 +130,26 @@ public synchronized Boolean doOperation(ProgressHandle progress, assert mm != null; needsRestart = mm.hasToEnableCompatModules(modules); - - final ModuleManager fmm = mm; - try { - fmm.mutex ().writeAccess (new ExceptionAction () { - @Override - public Boolean run () throws Exception { - return enable(fmm, modules); + + if (!needsRestart) { + final ModuleManager fmm = mm; + try { + fmm.mutex ().writeAccess (new ExceptionAction () { + @Override + public Boolean run () throws Exception { + return enable(fmm, modules); + } + }); + } catch (MutexException ex) { + Exception x = ex.getException (); + assert x instanceof OperationException : x + " is instanceof OperationException"; + if (x instanceof OperationException) { + throw (OperationException) x; } - }); - } catch (MutexException ex) { - Exception x = ex.getException (); - assert x instanceof OperationException : x + " is instanceof OperationException"; - if (x instanceof OperationException) { - throw (OperationException) x; } + } else { + ModuleEnableDisableDeleteHelper helper = new ModuleEnableDisableDeleteHelper (); + controlFileForEnable = helper.findControlFiles(moduleInfos, progress); } } finally { if (progress != null) { @@ -155,7 +162,12 @@ public Boolean run () throws Exception { @Override public void doCancel () throws OperationException { - assert false : "Not supported yet"; + if (controlFileForEnable != null) { + controlFileForEnable = null; + } + if (affectedModules != null) { + affectedModules = null; + } } private static boolean enable(ModuleManager mm, Set toRun) throws OperationException { @@ -173,13 +185,36 @@ private static boolean enable(ModuleManager mm, Set toRun) throws Operat @Override public void doRestart (Restarter restarter, ProgressHandle progress) throws OperationException { - LifecycleManager.getDefault().markForRestart(); - LifecycleManager.getDefault().exit(); + if (controlFileForEnable != null) { + // write files marked to enable into a temp file + // Updater will handle it + Utilities.writeFileMarkedForEnable(controlFileForEnable); + + // restart IDE + Utilities.deleteAllDoLater (); + LifecycleManager.getDefault ().exit (); + // if exit&restart fails => use restart later as fallback + doRestartLater (restarter); + } else { + LifecycleManager.getDefault().markForRestart(); + LifecycleManager.getDefault().exit(); + } } @Override public void doRestartLater (Restarter restarter) { - LifecycleManager.getDefault().markForRestart(); + if (controlFileForEnable != null) { + // write files marked to enable into a temp file + // Updater will handle it + Utilities.writeFileMarkedForEnable(controlFileForEnable); + + // schedule module for restart + for (UpdateElement el : affectedModules) { + UpdateUnitFactory.getDefault().scheduleForRestart (el); + } + } else { + LifecycleManager.getDefault().markForRestart(); + } } } @@ -214,8 +249,8 @@ public synchronized Boolean doOperation(ProgressHandle progress, } } assert mm != null; - ModuleDeleterImpl deleter = new ModuleDeleterImpl (); - controlFileForDisable = deleter.markForDisable (modules, progress); + ModuleEnableDisableDeleteHelper deleter = new ModuleEnableDisableDeleteHelper (); + controlFileForDisable = deleter.findControlFiles(modules, progress); } finally { if (progress != null) { progress.finish(); @@ -354,7 +389,7 @@ public synchronized Boolean doOperation(ProgressHandle progress, if (progress != null) { progress.start(); } - ModuleDeleterImpl deleter = new ModuleDeleterImpl(); + ModuleEnableDisableDeleteHelper deleter = new ModuleEnableDisableDeleteHelper(); List infos = container.listAll (); Set moduleInfos = new HashSet (); @@ -446,7 +481,7 @@ public synchronized Boolean doOperation(ProgressHandle progress, if (progress != null) { progress.start(); } - ModuleDeleterImpl deleter = new ModuleDeleterImpl(); + ModuleEnableDisableDeleteHelper deleter = new ModuleEnableDisableDeleteHelper(); List infos = container.listAll (); Set moduleInfos = new HashSet (); diff --git a/platform/autoupdate.services/src/org/netbeans/modules/autoupdate/services/OperationValidator.java b/platform/autoupdate.services/src/org/netbeans/modules/autoupdate/services/OperationValidator.java index edce93edd5d3..71f16dd86dd7 100644 --- a/platform/autoupdate.services/src/org/netbeans/modules/autoupdate/services/OperationValidator.java +++ b/platform/autoupdate.services/src/org/netbeans/modules/autoupdate/services/OperationValidator.java @@ -218,13 +218,13 @@ private boolean isValidOperationImpl (UpdateElementImpl impl) { case KIT_MODULE : case MODULE : Module m = Utilities.toModule (((ModuleUpdateElementImpl) impl).getModuleInfo ()); - res = ModuleDeleterImpl.getInstance ().canDelete (m); + res = ModuleEnableDisableDeleteHelper.getInstance ().canDelete (m); break; case STANDALONE_MODULE : case FEATURE : for (ModuleInfo info : ((FeatureUpdateElementImpl) impl).getModuleInfos ()) { Module module = Utilities.toModule (info); - res |= ModuleDeleterImpl.getInstance ().canDelete (module); + res |= ModuleEnableDisableDeleteHelper.getInstance ().canDelete (module); } break; case CUSTOM_HANDLED_COMPONENT : @@ -261,7 +261,7 @@ List getRequiredElementsImpl (UpdateElement uElement, List files) { } public static void writeFileMarkedForDisable (Collection files) { - writeMarkedFilesToFile (files, ModuleDeactivator.getControlFileForMarkedForDisable (InstallManager.getUserDir ())); + writeMarkedFilesToFile (files, ModuleDeactivator.getControlFileForMarkedForEnableDisable(InstallManager.getUserDir (), false)); } - + + public static void writeFileMarkedForEnable (Collection files) { + writeMarkedFilesToFile (files, ModuleDeactivator.getControlFileForMarkedForEnableDisable(InstallManager.getUserDir (), true)); + } + private static void writeMarkedFilesToFile (Collection files, File dest) { // don't forget for content written before StringBuilder content = new StringBuilder(); diff --git a/platform/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/wizards/UninstallStep.java b/platform/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/wizards/UninstallStep.java index 77bf1a4d6069..fb3150f8e503 100644 --- a/platform/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/wizards/UninstallStep.java +++ b/platform/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/wizards/UninstallStep.java @@ -278,11 +278,17 @@ private void presentActionFailed (OperationException ex) { @NbBundle.Messages({ "UninstallStep_Header_Restart_Head=Restart application to complete deactivation", "UninstallStep_Header_Restart_Content=Restart application to finish plugin deactivation.", + "UninstallStep_Activate_Header_Restart_Head=Restart application to complete activation", + "UninstallStep_Activate_Header_Restart_Content=Restart application to finish plugin activation.", "UninstallStep_ActivateLater_Text=The Plugin Installer has successfully activated the following plugins:", "UninstallStep_UninstallLater_Text=The Plugin Installer has successfully uninstalled the following plugins:", "UninstallStep_DeactivateLater_Text=The Plugin Installer has successfully deactivated the following plugins:"}) private void presentActionNeedsRestart (Restarter r) { - component.setHeadAndContent (UninstallStep_Header_Restart_Head(), UninstallStep_Header_Restart_Content()); + if (model.getOperation() == OperationWizardModel.OperationType.ENABLE) { + component.setHeadAndContent (UninstallStep_Activate_Header_Restart_Head(), UninstallStep_Activate_Header_Restart_Content()); + } else { + component.setHeadAndContent (UninstallStep_Header_Restart_Head(), UninstallStep_Header_Restart_Content()); + } model.modifyOptionsForDoClose (wd, true); restarter = r; panel.setRestartButtonsVisible (true); diff --git a/platform/core.startup/src/org/netbeans/core/startup/NbInstaller.java b/platform/core.startup/src/org/netbeans/core/startup/NbInstaller.java index dcdecd07a82e..7d9a11575742 100644 --- a/platform/core.startup/src/org/netbeans/core/startup/NbInstaller.java +++ b/platform/core.startup/src/org/netbeans/core/startup/NbInstaller.java @@ -231,13 +231,13 @@ private void checkForHiddenPackages(Module m) throws InvalidException { List mWithDeps = new LinkedList(); mWithDeps.add(m); if (mgr != null) { - mWithDeps.addAll(mgr.getAttachedFragments(m)); + addEnabledFragments(m, mWithDeps); for (Dependency d : m.getDependencies()) { if (d.getType() == Dependency.TYPE_MODULE) { Module _m = mgr.get((String) Util.parseCodeName(d.getName())[0]); assert _m != null : d; mWithDeps.add(_m); - mWithDeps.addAll(mgr.getAttachedFragments(_m)); + addEnabledFragments(_m, mWithDeps); } } } @@ -283,6 +283,14 @@ private void checkForHiddenPackages(Module m) throws InvalidException { } } + private void addEnabledFragments(Module forModule, List moduleWithDependencies) { + for (Module fragment : mgr.getAttachedFragments(forModule)) { + if (mgr.isOrWillEnable(fragment)) { + moduleWithDependencies.add(fragment); + } + } + } + public void dispose(Module m) { Util.err.fine("dispose: " + m); // Events probably not needed here. diff --git a/platform/o.n.bootstrap/launcher/unix/nbexec b/platform/o.n.bootstrap/launcher/unix/nbexec index 0b5217845a14..1d6ad6e53019 100755 --- a/platform/o.n.bootstrap/launcher/unix/nbexec +++ b/platform/o.n.bootstrap/launcher/unix/nbexec @@ -291,7 +291,7 @@ look_for_pre_runs() { run_updater=yes else dir="${base}/update/deactivate" - if [ -f "${dir}/to_disable.txt" -o -f "${dir}/to_uninstall.txt" ] ; then + if [ -f "${dir}/to_disable.txt" -o -f "${dir}/to_uninstall.txt" -o -f "${dir}/to_enable.txt" ] ; then run_updater=yes fi fi @@ -306,7 +306,7 @@ look_for_post_runs() { else dir="${base}/update/deactivate" if [ \! -f "${dir}/deactivate_later.txt" ] ; then - if [ -f "${dir}/to_disable.txt" -o -f "${dir}/to_uninstall.txt" ] ; then + if [ -f "${dir}/to_disable.txt" -o -f "${dir}/to_uninstall.txt" -o -f "${dir}/to_enable.txt" ] ; then run_updater=yes fi fi diff --git a/platform/o.n.bootstrap/src/org/netbeans/ModuleManager.java b/platform/o.n.bootstrap/src/org/netbeans/ModuleManager.java index dd62e9eb154c..a8d5facc6a35 100644 --- a/platform/o.n.bootstrap/src/org/netbeans/ModuleManager.java +++ b/platform/o.n.bootstrap/src/org/netbeans/ModuleManager.java @@ -1109,19 +1109,21 @@ private void subCreate(Module m) throws DuplicateException { } /** - * Attaches a fragment to an existing module. The hosting module must NOT - * be already enabled, otherwise an exception will be thrown. Enabled module - * may have some classes already loaded, and they cannot be patched. + * Finds the host module for a given fragment. * + * If assertNotEnabled, the hosting module must NOT be already enabled, + * otherwise an exception will be thrown. Enabled module may have some + * classes already loaded, and they cannot be patched. + * * @param m module to attach if it is a fragment */ - private Module attachModuleFragment(Module m) { + private Module findHostModule(Module m, boolean assertNotEnabled) { String codeNameBase = m.getFragmentHostCodeName(); if (codeNameBase == null) { return null; } Module host = modulesByName.get(codeNameBase); - if (host != null && host.isEnabled() && host.getClassLoader() != null) { + if (assertNotEnabled && host != null && host.isEnabled() && host.getClassLoader() != null) { throw new IllegalStateException("Host module " + host + " was enabled before, will not accept fragment " + m); } return host; @@ -1294,7 +1296,7 @@ public EnableContext(List willEnable) { * @param m module to check * @return true, if the module is/will enable. */ - boolean isOrWillEnable(Module m) { + public boolean isOrWillEnable(Module m) { if (m.isEnabled()) { return true; } @@ -1331,9 +1333,11 @@ private void enable(Set modules, boolean honorAutoloadEager) throws Ille throw new IllegalModuleException(IllegalModuleException.Reason.ENABLE_MISSING, errors); } for (Module m : testing) { + //lookup host here, to ensure enablement fails in the host is already enabled: + Module maybeHost = findHostModule(m, true); + if (!modules.contains(m) && !m.isAutoload() && !m.isEager()) { // it is acceptable if the module is a non-autoload host fragment, and its host enabled (thus enabled the fragment): - Module maybeHost = attachModuleFragment(m); if (maybeHost == null && !testing.contains(maybeHost)) { throw new IllegalModuleException(IllegalModuleException.Reason.ENABLE_TESTING, m); } @@ -1798,7 +1802,7 @@ private void maybeAddToEnableList(Set willEnable, Set mightEnabl addedBecauseOfDependent = m; // need to register fragments eagerly, so they are available during // dependency sort - Module host = attachModuleFragment(m); + Module host = findHostModule(m, false); if (host != null && !host.isEnabled()) { maybeAddToEnableList(willEnable, mightEnable, host, okToFail, "Fragment host"); } diff --git a/platform/o.n.bootstrap/test/unit/src/org/netbeans/ModuleManagerTest.java b/platform/o.n.bootstrap/test/unit/src/org/netbeans/ModuleManagerTest.java index 06813848ccb7..d60864328e7f 100644 --- a/platform/o.n.bootstrap/test/unit/src/org/netbeans/ModuleManagerTest.java +++ b/platform/o.n.bootstrap/test/unit/src/org/netbeans/ModuleManagerTest.java @@ -2879,8 +2879,9 @@ public void testInstallFragmentAfterHostEnabled() throws Exception { mgr.enable(m1); Module m2 = mgr.create(new File(jars, "fragment-module.jar"), null, false, false, false); + try { - mgr.simulateEnable(Collections.singleton(m2)); + mgr.enable(Collections.singleton(m2)); fail("Enabling fragment must fail if host is already live"); } catch (IllegalStateException ex) { // ok