--- a/ant.debugger/nbproject/project.xml +++ a/ant.debugger/nbproject/project.xml @@ -48,6 +48,7 @@ org.apache.tools.ant.module + 3 --- a/apisupport.ant/nbproject/project.properties +++ a/apisupport.ant/nbproject/project.properties @@ -39,6 +39,6 @@ antsrc.cp=\ ${ant.core.lib}:\ - ${o.n.core.dir}/core/core.jar + ${core.startup.dir}/core/core.jar javadoc.arch=${basedir}/arch.xml --- a/apisupport.harness/nbproject/project.properties +++ a/apisupport.harness/nbproject/project.properties @@ -42,6 +42,7 @@ jnlp.cp=\ ${o.n.bootstrap.dir}/lib/boot.jar:\ ${openide.modules.dir}/lib/org-openide-modules.jar:\ + ${openide.util.dir}/lib/org-openide-util-lookup.jar:\ ${openide.util.dir}/lib/org-openide-util.jar release.../nbbuild/templates/common.xml=common.xml --- a/autoupdate.pluginimporter/nbproject/project.xml +++ a/autoupdate.pluginimporter/nbproject/project.xml @@ -33,6 +33,7 @@ org.netbeans.modules.autoupdate.ui + 1.6 @@ -75,7 +76,15 @@ - 7.22 + 8.0 + + + + org.openide.util.lookup + + + + 8.0 --- a/core.startup/nbproject/project.xml +++ a/core.startup/nbproject/project.xml @@ -79,6 +79,14 @@ + + org.openide.util.lookup + + + + + + --- a/db/nbproject/project.properties +++ a/db/nbproject/project.properties @@ -51,6 +51,7 @@ fake-jdbc-40.build=${fake-jdbc-40}/build lib.cp=\ ${fake-jdbc-40.build}:\ + ${openide.util.lookup.dir}/lib/org-openide-util-lookup.jar:\ ${openide.util.dir}/lib/org-openide-util.jar:\ ${openide.dialogs.dir}/modules/org-openide-dialogs.jar:\ ${openide.io.dir}/modules/org-openide-io.jar --- a/gsfpath.api/nbproject/project.properties +++ a/gsfpath.api/nbproject/project.properties @@ -40,4 +40,3 @@ is.autoload=true javac.compilerargs=-Xlint:unchecked javac.source=1.5 -test.unit.run.cp.extra=${o.n.core.dir}/lib/boot.jar:${o.n.core.dir}/core/core.jar --- a/j2ee.sun.appsrv81/appsrvbridge/nbproject/project.properties +++ a/j2ee.sun.appsrv81/appsrvbridge/nbproject/project.properties @@ -28,6 +28,7 @@ file.reference.org-openide-explorer.jar=../../nbbuild/netbeans/platform11/modules/org-openide-explorer.jar file.reference.org-openide-nodes.jar=../../nbbuild/netbeans/platform11/modules/org-openide-nodes.jar file.reference.org-openide-util.jar=../../nbbuild/netbeans/platform11/lib/org-openide-util.jar +file.reference.org-openide-util-lookup.jar=../../nbbuild/netbeans/platform11/lib/org-openide-util-lookup.jar application.args= build.classes.dir=${build.dir}/classes build.classes.excludes=**/*.java,**/*.form @@ -56,6 +57,7 @@ ${file.reference.org-netbeans-modules-j2ee-sun-appsrv.jar}:\ ${file.reference.org-netbeans-modules-schema2beans.jar}:\ ${file.reference.org-openide-util.jar}:\ + ${file.reference.org-openide-util-lookup.jar}:\ ${file.reference.org-openide-nodes.jar}:\ ${file.reference.org-openide-dialogs.jar}:\ ${file.reference.org-openide-actions.jar}:\ --- a/jemmy/nbproject/project.properties +++ a/jemmy/nbproject/project.properties @@ -39,7 +39,6 @@ is.autoload=true javac.compilerargs=-Xlint -Xlint:-serial javac.source=1.5 -test.unit.cp.extra=${ant.core.lib} release.external/jemmy-2.3.0.0.jar=modules/ext/jemmy-2.3.0.0.jar sigtest.gen.fail.on.error=false --- a/nbbuild/antsrc/org/netbeans/nbbuild/FixDependencies.java +++ a/nbbuild/antsrc/org/netbeans/nbbuild/FixDependencies.java @@ -66,7 +66,7 @@ /** files to fix */ private FileSet set; /** verify target */ - private String target; + private String tgt; /** clean target */ private String clean; /** relative path from module file to build script to use for verification */ @@ -75,6 +75,7 @@ private boolean onlyChanged; /** fail on error */ private boolean fail; + private boolean doSanity = true; /** tasks to be executed */ @@ -95,9 +96,13 @@ this.set = new FileSet(); return this.set; } + + public void setSanityCheck(boolean s) { + doSanity = s; + } public void setBuildTarget (String s) { - target = s; + tgt = s; } public void setCleanTarget (String s) { @@ -116,6 +121,7 @@ fail = b; } + @Override public void execute () throws org.apache.tools.ant.BuildException { FileScanner scan = this.set.getDirectoryScanner(getProject()); File dir = scan.getBasedir(); @@ -128,7 +134,7 @@ File script = null; Ant task = null; Ant cleanTask = null; - if (ant != null && target != null) { + if (ant != null && tgt != null) { task = (org.apache.tools.ant.taskdefs.Ant)getProject ().createTask ("ant"); script = FileUtils.getFileUtils().resolveFile(xml, ant); if (!script.exists ()) { @@ -141,7 +147,7 @@ } task.setAntfile (script.getPath ()); task.setDir (script.getParentFile ()); - task.setTarget (target); + task.setTarget (tgt); if (clean != null) { cleanTask = (Ant) getProject().createTask("ant"); cleanTask.setAntfile (script.getPath ()); @@ -155,14 +161,16 @@ log ("Cleaning " + clean + " in " + script, org.apache.tools.ant.Project.MSG_INFO); cleanTask.execute (); } - log ("Sanity check executes " + target + " in " + script, org.apache.tools.ant.Project.MSG_INFO); - task.execute (); + if (doSanity) { + log ("Sanity check executes " + tgt + " in " + script, org.apache.tools.ant.Project.MSG_INFO); + task.execute (); + } } catch (BuildException ex) { if (fail) { throw ex; } - log("Skipping. Could not execute " + target + " in " + script, org.apache.tools.ant.Project.MSG_ERR); + log("Skipping. Could not execute " + tgt + " in " + script, org.apache.tools.ant.Project.MSG_ERR); continue; } } @@ -199,8 +207,19 @@ data = null; for (Replace r : replaces) { - int idx = stream.indexOf ("" + r.codeNameBase + ""); - if (idx == -1) continue; + int md = stream.indexOf("", md); + ed = ed == -1 ? stream.indexOf ("", md) : ed; + if (ed == -1) { + ed = stream.length(); + } + + int idx = stream.indexOf ("" + r.codeNameBase + "", md); + if (idx == -1 || idx > ed) continue; int from = stream.lastIndexOf ("", idx); if (from == -1) throw new BuildException ("No tag before index " + idx); @@ -220,8 +239,24 @@ sb.append (stream.substring (0, from)); for (Module m : r.modules) { - if (stream.indexOf ("" + m.codeNameBase + "") != -1) { - continue; + if (m.codeNameBase.equals(r.codeNameBase)) { + if (remove.contains("")) { + return false; + } + + String b = ""; + int specBeg = remove.indexOf(b); + int specEnd = remove.indexOf(""); + if (specBeg != -1 && specEnd != -1) { + String v = remove.substring(specBeg + b.length(), specEnd); + if (olderThanOrEqual(m.specVersion, v)) { + return false; + } + } + } else { + if (stream.indexOf ("" + m.codeNameBase + "") != -1) { + continue; + } } int beg = remove.indexOf (r.codeNameBase); @@ -263,7 +298,7 @@ private void simplify ( File file, File script, org.apache.tools.ant.taskdefs.Ant task, org.apache.tools.ant.taskdefs.Ant cleanTask ) throws IOException, BuildException { - if (ant == null || target == null) { + if (ant == null || tgt == null) { return; } @@ -328,7 +363,7 @@ String result; try { - log ("Executing target " + target + " in " + script, Project.MSG_INFO); + log ("Executing target " + tgt + " in " + script, Project.MSG_INFO); task.execute (); result = "Ok"; success.append (dep); @@ -349,10 +384,9 @@ fw.close (); } - log ("Final verification runs " + target + " in " + script, Project.MSG_INFO); + log ("Final verification runs " + tgt + " in " + script, Project.MSG_INFO); // now verify, if there is a failure then something is wrong now task.execute (); - if (success.length () == 0) { log ("No dependencies removed from " + script); } else { @@ -367,6 +401,22 @@ return from; } + private static boolean olderThanOrEqual(String v1, String v2) { + String[] arr1 = v1.split("\\."); + String[] arr2 = v2.split("\\."); + int min = Math.min(arr1.length, arr2.length); + for (int i = 0; i < min; i++) { + int i1 = Integer.parseInt(arr1[i]); + int i2 = Integer.parseInt(arr2[i]); + + if (i1 == i2) { + continue; + } + return i1 < i2; + } + return arr1.length <= arr2.length; + } + public static final class Replace extends Object { String codeNameBase; List modules = new ArrayList(); --- a/nbbuild/antsrc/org/netbeans/nbbuild/FixTestDependencies.java +++ a/nbbuild/antsrc/org/netbeans/nbbuild/FixTestDependencies.java @@ -56,6 +56,8 @@ import java.util.Set; import java.util.StringTokenizer; import java.util.TreeSet; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Task; @@ -129,11 +131,11 @@ if (cnb.length() <= 0) { throw new BuildException("Invalid codename base:" + cnb); } + final boolean td = xml.contains(""); // test if project.xml contains test-deps - if (xml.contains("") && !testFix) { + if (td && !testFix) { // yes -> exit - log(" already exists."); - log("update only schema version"); + xml = fixOpenideUtil(xml); PrintStream ps = new PrintStream(projectXmlFile); ps.print(xml); ps.close(); @@ -153,10 +155,16 @@ Set runtimeTestCNB = new TreeSet(); Properties projectProperties = getTestProperties(); - readCodeNameBases(compileCNB,compileTestCNB,projectProperties,"test.unit.cp",allCnbs,entries); - readCodeNameBases(compileCNB,compileTestCNB,projectProperties,"test.unit.cp.extra",allCnbs,entries); - readCodeNameBases(runtimeCNB,runtimeTestCNB,projectProperties,"test.unit.run.cp",allCnbs,entries); - readCodeNameBases(runtimeCNB,runtimeTestCNB,projectProperties,"test.unit.run.cp.extra",allCnbs,entries); + boolean found; + found = readCodeNameBases(compileCNB,compileTestCNB,projectProperties,"test.unit.cp",allCnbs,entries); + found |= readCodeNameBases(compileCNB,compileTestCNB,projectProperties,"test.unit.cp.extra",allCnbs,entries); + found |= readCodeNameBases(runtimeCNB,runtimeTestCNB,projectProperties,"test.unit.run.cp",allCnbs,entries); + found |= readCodeNameBases(runtimeCNB,runtimeTestCNB,projectProperties,"test.unit.run.cp.extra",allCnbs,entries); + + if (!found && !td) { + return; + } + updateProperties(projectProperties,new String[]{"test.unit.cp","test.unit.cp.extra","test.unit.run.cp","test.unit.run.cp.extra"}); StringWriter writer = new StringWriter(); @@ -220,7 +228,7 @@ resultXml.append(xml.substring(moduleDepEnd + 1, xml.length())); if (!testFix) { PrintStream ps = new PrintStream(projectXmlFile); - ps.print(resultXml); + ps.print(fixOpenideUtil(resultXml.toString())); ps.close(); } else { System.out.println(resultXml); @@ -255,7 +263,7 @@ } /** parses all codenamebases from path */ - void readCodeNameBases(Set compileCNB, + boolean readCodeNameBases(Set compileCNB, Set testsCNB, Properties projectPropertis, String property, @@ -343,7 +351,9 @@ } } // while projectPropertis.setProperty(property,newProp.toString()); + return true; } + return false; } private void addDependencies(PrintWriter buffer, Set moduleCNB, Set testCNB, boolean compile, boolean recursive) { @@ -370,7 +380,7 @@ private Properties getTestProperties() throws IOException { if (propertiesFile == null || !propertiesFile.isFile()) { - throw new BuildException("Property file doesn't exist"); + return new Properties(); } Properties props = new Properties(); FileInputStream fis = new FileInputStream(propertiesFile); @@ -393,22 +403,30 @@ return null; } private void updateProperties(Properties projectProperties,String names[]) { + if (propertiesFile == null) { + return; + } try { - - // read properties - BufferedReader reader = new BufferedReader (new FileReader(propertiesFile)); List lines = new ArrayList(); - String line = null; - while ((line = reader.readLine()) != null) { - lines.add(line); + if (propertiesFile.isFile()) { + // read properties + BufferedReader reader = new BufferedReader (new FileReader(propertiesFile)); + String line = null; + while ((line = reader.readLine()) != null) { + lines.add(line); + } + reader.close(); } - reader.close(); // merge properties for (String propName : names) { String value = projectProperties.getProperty(propName); lines = replaceProperty(propName,value,lines); } + if (lines.isEmpty() && !propertiesFile.isFile()) { + return; + } + // store properties PrintStream ps = new PrintStream(propertiesFile); for (String l : lines) { @@ -444,6 +462,33 @@ retLines.add(line); } return retLines; - } + } + + private String fixOpenideUtil(String xml) { + Pattern l = Pattern.compile( + "^ *[^/]*" + + "org.openide.util.lookup", Pattern.MULTILINE); + if (l.matcher(xml).find()) { + return xml; + } + + Pattern p = Pattern.compile( + "^ *[^/]*" + + "org.openide.util", Pattern.MULTILINE); + + Matcher m = p.matcher(xml); + if (m.find()) { + final String txt = ""; + final int s = m.start(); + int end = xml.indexOf(txt, s); + if (end == -1) { + throw new BuildException("No end of dependency " + xml); + } + final int e = end + txt.length(); + String dep = xml.substring(s, e); + return xml.substring(0, s) + dep + '\n' + dep.replace("org.openide.util", "org.openide.util.lookup") + xml.substring(e); + } + return xml; + } } --- a/nbbuild/build.xml +++ a/nbbuild/build.xml @@ -180,7 +180,22 @@ - + + + + + + + + + + + + + + + + @@ -1630,6 +1645,8 @@ + + --- a/nbbuild/cluster.properties +++ a/nbbuild/cluster.properties @@ -230,6 +230,7 @@ openide.text,\ openide.util,\ openide.util.enumerations,\ + openide.util.lookup,\ openide.windows,\ options.api,\ options.keymap,\ --- a/nbbuild/templates/common.xml +++ a/nbbuild/templates/common.xml @@ -62,6 +62,15 @@ + + + + + + + + + @@ -922,7 +931,7 @@ - + @@ -939,6 +948,10 @@ + + + + --- a/nbbuild/test/unit/src/org/netbeans/nbbuild/FixDependencies-core.kit.xml +++ a/nbbuild/test/unit/src/org/netbeans/nbbuild/FixDependencies-core.kit.xml @@ -0,0 +1,144 @@ + + + org.netbeans.modules.apisupport.project + + + org.netbeans.modules.core.kit + + + org.netbeans.core + + 2 + 3.6 + + + + org.netbeans.core.ui + + 1 + 1.10 + + + + org.netbeans.core.windows + + 2 + 2.10 + + + + org.netbeans.modules.autoupdate.services + + 1.3 + + + + org.netbeans.modules.autoupdate.ui + + 1.2 + + + + org.netbeans.modules.favorites + + 1 + 1.12 + + + + org.netbeans.modules.masterfs + + 2 + 1.11 + + + + org.netbeans.modules.options.api + + 1 + 1.5 + + + + org.netbeans.modules.options.keymap + + 1.1 + + + + org.netbeans.modules.print + + 7.0 + + + + org.netbeans.modules.templates + + 1.0 + + + + org.netbeans.swing.plaf + + 1.6 + + + + + + unit + + org.netbeans.libs.junit4 + + + + org.netbeans.modules.nbjunit + + + + + org.openide.actions + + + + org.openide.awt + + + + org.openide.compat + + + + org.openide.dialogs + + + + org.openide.explorer + + + + org.openide.filesystems + + + + org.openide.loaders + + + + org.openide.nodes + + + + org.openide.util + + + + org.openide.windows + + + + + + + + --- a/nbbuild/test/unit/src/org/netbeans/nbbuild/FixDependencies-openide.util.xml +++ a/nbbuild/test/unit/src/org/netbeans/nbbuild/FixDependencies-openide.util.xml @@ -0,0 +1,88 @@ + + + + org.netbeans.modules.apisupport.project + + + org.openide.util + + + org.openide.util.lookup + + + + + + + + + + unit + + org.netbeans.libs.junit4 + + + + org.netbeans.modules.nbjunit + + + + + org.openide.util.lookup + + + + + + + org.openide + org.openide.util + org.openide.util.datatransfer + org.openide.util.actions + org.openide.util.lookup + org.openide.util.io + org.openide.xml + + + + --- a/nbbuild/test/unit/src/org/netbeans/nbbuild/FixDependencies-xml.wsdl.model.xml +++ a/nbbuild/test/unit/src/org/netbeans/nbbuild/FixDependencies-xml.wsdl.model.xml @@ -0,0 +1,118 @@ + + + + org.netbeans.modules.apisupport.project + + + org.netbeans.modules.xml.wsdl.model + + + org.netbeans.modules.xml.schema.model + + + + 1 + 1.0 + + + + org.netbeans.modules.xml.xam + + + + 1 + 1.0 + + + + org.openide.util + + + + + + + + + unit + + + + org.netbeans.modules.xml.text + + + + + + + + + org.netbeans.modules.xml.xdm + + + + + org.netbeans.modules.xml.retriever + + + + + org.netbeans.modules.masterfs + + + + + + + org.netbeans.modules.xml.wsdl.model + org.netbeans.modules.xml.wsdl.model.extensions.http + org.netbeans.modules.xml.wsdl.model.extensions.soap + org.netbeans.modules.xml.wsdl.model.extensions.soap12 + org.netbeans.modules.xml.wsdl.model.extensions.xsd + org.netbeans.modules.xml.wsdl.model.spi + org.netbeans.modules.xml.wsdl.model.visitor + org.netbeans.modules.xml.wsdl.validator.spi + + + + --- a/nbbuild/test/unit/src/org/netbeans/nbbuild/FixDependenciesTest.java +++ a/nbbuild/test/unit/src/org/netbeans/nbbuild/FixDependenciesTest.java @@ -41,20 +41,6 @@ package org.netbeans.nbbuild; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.FileReader; -import java.io.IOException; -import java.io.InputStream; -import java.util.Arrays; -import java.util.StringTokenizer; -import java.util.jar.JarEntry; -import java.util.jar.JarOutputStream; -import java.util.jar.Manifest; -import java.util.zip.ZipEntry; -import java.util.zip.ZipOutputStream; -import junit.framework.*; import org.netbeans.junit.*; @@ -68,6 +54,134 @@ public FixDependenciesTest (String name) { super (name); } + public void testCanFixXmlWsdlModel() throws Exception { + java.io.File xml = PublicPackagesInProjectizedXMLTest.extractResource("FixDependencies-xml.wsdl.model.xml"); + + java.io.File f = PublicPackagesInProjectizedXMLTest.extractString ( + "" + + "" + + " " + + "" + + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + "" + + "" + + "" + + ); + + PublicPackagesInProjectizedXMLTest.execute (f, new String[] { }); + String result = PublicPackagesInProjectizedXMLTest.readFile (xml); + + if (result.indexOf ("org.openide.util") == -1) { + fail ("org.openide.util should be there: " + result); + } + if (result.indexOf ("org.openide.util.lookup") == -1) { + fail ("org.openide.util.lookup should be there: " + result); + } + } + public void testCanParseCoreKit () throws Exception { + java.io.File xml = PublicPackagesInProjectizedXMLTest.extractResource("FixDependencies-core.kit.xml"); + + java.io.File f = PublicPackagesInProjectizedXMLTest.extractString ( + "" + + "" + + " " + + "" + + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + "" + + "" + + "" + + ); + + String before = PublicPackagesInProjectizedXMLTest.readFile(xml); + PublicPackagesInProjectizedXMLTest.execute (f, new String[] { }); + String after = PublicPackagesInProjectizedXMLTest.readFile(xml); + + assertEquals("No change", before, after); + } + public void testCanParseOpenideUtil () throws Exception { + java.io.File xml = PublicPackagesInProjectizedXMLTest.extractResource("FixDependencies-openide.util.xml"); + + java.io.File f = PublicPackagesInProjectizedXMLTest.extractString ( + "" + + "" + + " " + + "" + + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + "" + + "" + + "" + + ); + + String before = PublicPackagesInProjectizedXMLTest.readFile(xml); + PublicPackagesInProjectizedXMLTest.execute (f, new String[] { }); + String after = PublicPackagesInProjectizedXMLTest.readFile(xml); + + assertEquals("No change", before, after); + } + public void testNoModuleDependenciesDoesNotCrash() throws Exception { + java.io.File xml = PublicPackagesInProjectizedXMLTest.extractString( + "" + + "" + + "org.netbeans.modules.apisupport.project" + + "" + + "" + + "org.netbeans.api.annotations.common" + + "" + + "" + + "" + + "" + + "" + ); + + java.io.File f = PublicPackagesInProjectizedXMLTest.extractString ( + "" + + "" + + " " + + "" + + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + "" + + "" + + "" + + ); + + String before = PublicPackagesInProjectizedXMLTest.readFile(xml); + PublicPackagesInProjectizedXMLTest.execute (f, new String[] { }); + String after = PublicPackagesInProjectizedXMLTest.readFile(xml); + + assertEquals("No change", before, after); + } public void testReplaceOpenideDepWithSmallerOnes () throws Exception { java.io.File xml = PublicPackagesInProjectizedXMLTest.extractString ( "" + @@ -118,6 +232,118 @@ fail ("Spec version must be updated to 6.2: " + result); } } + + public void testReplaceOpenideUtilWithUtilAndLookup () throws Exception { + java.io.File xml = PublicPackagesInProjectizedXMLTest.extractString ( + "" + + "" + + " " + + " " + + " org.openide.util" + + " " + + " " + + " " + + " 7.28 " + + " " + + " " + + " " + + "" + ); + + java.io.File f = PublicPackagesInProjectizedXMLTest.extractString ( + "" + + "" + + " " + + "" + + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + "" + + "" + + "" + + ); + PublicPackagesInProjectizedXMLTest.execute (f, new String[] { }); + + String result = PublicPackagesInProjectizedXMLTest.readFile (xml); + + if (result.indexOf ("org.openide.util") == -1) { + fail ("org.openide.util should be there: " + result); + } + if (result.indexOf ("org.openide.util.lookup") == -1) { + fail ("org.openide.util.lookup should be there: " + result); + } + + int where; + if ((where = result.indexOf ("8.0")) == -1) { + fail ("Spec version must be updated to 8.0: " + result); + } + if (result.indexOf("8.0", where + 1) == -1) { + fail ("Snd Spec version must be updated to 8.0: " + result); + } + } + public void testDontReplaceNewerVersionOfItself() throws Exception { + doDontReplaceNewerVersionOfItself("8.1"); + } + public void testDontReplaceNewerVersionOfItself9() throws Exception { + doDontReplaceNewerVersionOfItself("9.0"); + } + + private void doDontReplaceNewerVersionOfItself(String version) throws Exception { + java.io.File xml = PublicPackagesInProjectizedXMLTest.extractString ( + "" + + "" + + " " + + " " + + " org.openide.util" + + " " + + " " + + " " + + " " + version + " " + + " " + + " " + + " " + + "" + ); + + java.io.File f = PublicPackagesInProjectizedXMLTest.extractString ( + "" + + "" + + " " + + "" + + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + "" + + "" + + "" + + ); + PublicPackagesInProjectizedXMLTest.execute (f, new String[] { }); + + String result = PublicPackagesInProjectizedXMLTest.readFile (xml); + + if (result.indexOf ("org.openide.util") == -1) { + fail ("org.openide.util should be there: " + result); + } + if (result.indexOf ("org.openide.util.lookup") >= 0) { + fail ("org.openide.util.lookup should not be there: " + result); + } + + if (result.indexOf ("" + version + "") == -1) { + fail ("Spec version stays at updated to kept: " + result); + } + } public void testVerificationOfRemovedDependencies () throws Exception { --- a/nbbuild/test/unit/src/org/netbeans/nbbuild/FixTestDependencies-o.apache.xml.resolver.xml +++ a/nbbuild/test/unit/src/org/netbeans/nbbuild/FixTestDependencies-o.apache.xml.resolver.xml @@ -0,0 +1,58 @@ + + + + org.netbeans.modules.apisupport.project + + + org.apache.xml.resolver + + + org.apache.xml.resolver + + + ext/resolver-1.2.jar + external/resolver-1.2.jar + + + + --- a/nbbuild/test/unit/src/org/netbeans/nbbuild/FixTestDependencies-openide.filesystems.xml +++ a/nbbuild/test/unit/src/org/netbeans/nbbuild/FixTestDependencies-openide.filesystems.xml @@ -0,0 +1,96 @@ + + + + org.netbeans.modules.apisupport.project + + + org.openide.filesystems + + + org.openide.util + + + + + + + + org.openide.util.lookup + + + + + + + + + + unit + + org.netbeans.libs.junit4 + + + + org.netbeans.modules.nbjunit + + + + + org.openide.filesystems + + + + + org.openide.util + + + + + + + org.openide.filesystems + org.openide.filesystems.annotations + + + + --- a/nbbuild/test/unit/src/org/netbeans/nbbuild/FixTestDependenciesProjectPass.xml +++ a/nbbuild/test/unit/src/org/netbeans/nbbuild/FixTestDependenciesProjectPass.xml @@ -348,6 +348,9 @@ org.openide.util + + org.openide.util.lookup + --- a/nbbuild/test/unit/src/org/netbeans/nbbuild/FixTestDependenciesProjectStandalonePass.xml +++ a/nbbuild/test/unit/src/org/netbeans/nbbuild/FixTestDependenciesProjectStandalonePass.xml @@ -349,6 +349,9 @@ org.openide.util + + org.openide.util.lookup + --- a/nbbuild/test/unit/src/org/netbeans/nbbuild/FixTestDependenciesTest.java +++ a/nbbuild/test/unit/src/org/netbeans/nbbuild/FixTestDependenciesTest.java @@ -63,6 +63,47 @@ super(testName); } + public void testOpenideUtilTestDepNeedsToBeRecursive() throws IOException, Exception { + File prjFile = copyFile("FixTestDependencies-openide.filesystems.xml"); + File propertiesFile = new File(getWorkDir(), "empty.properties"); + propertiesFile.createNewFile(); + FixTestDependencies ftd = newFixTestDependencies(); + ftd.setPropertiesFile(propertiesFile); + ftd.setProjectXml(prjFile); + ftd.cachedEntries = getEntries(); + ftd.execute(); + + String result = PublicPackagesInProjectizedXMLTest.readFile(prjFile); + int first = result.indexOf("test-dependencies"); + if (first == -1) { + fail("No test deps found in " + result); + } + result = result.substring(first); + + if (result.indexOf("org.openide.util") == -1) { + fail("org.openide.util should be there: " + result); + } + if (result.indexOf("org.openide.util.lookup") == -1) { + fail("org.openide.util.lookup should be there: " + result); + } + } + public void testNoChangeForProjectsWithoutTests() throws IOException, Exception { + File prjFile = copyFile("FixTestDependencies-o.apache.xml.resolver.xml"); + String before = PublicPackagesInProjectizedXMLTest.readFile(prjFile); + File propertiesFile = new File(getWorkDir(), "some.properties"); + Properties np = new Properties(); + np.put("is.autoload", "true"); + np.store(new FileOutputStream(propertiesFile), ""); + FixTestDependencies ftd = newFixTestDependencies(); + ftd.setPropertiesFile(propertiesFile); + ftd.setProjectXml(prjFile); + ftd.cachedEntries = getEntries(); + ftd.execute(); + + String result = PublicPackagesInProjectizedXMLTest.readFile(prjFile); + assertEquals("No change expected", before, result); + } + public void testSimple() throws IOException, Exception { File prjFile = copyFile("FixTestDependenciesProject.xml"); File propertiesFile = copyFile("FixTestDependencies.properties"); --- a/nbjunit/nbproject/project.xml +++ a/nbjunit/nbproject/project.xml @@ -63,7 +63,7 @@ - org.openide.util + org.openide.util.lookup --- a/openide.actions/nbproject/project.xml +++ a/openide.actions/nbproject/project.xml @@ -55,6 +55,14 @@ + org.openide.util.lookup + + + + + + + org.openide.nodes --- a/openide.awt/nbproject/project.xml +++ a/openide.awt/nbproject/project.xml @@ -54,6 +54,14 @@ + + org.openide.util.lookup + + + + + + --- a/openide.filesystems/nbproject/project.xml +++ a/openide.filesystems/nbproject/project.xml @@ -54,6 +54,14 @@ + + org.openide.util.lookup + + + + + + --- a/openide.nodes/nbproject/project.xml +++ a/openide.nodes/nbproject/project.xml @@ -70,6 +70,14 @@ + + org.openide.util.lookup + + + + + + --- a/openide.util.lookup/build.xml +++ a/openide.util.lookup/build.xml @@ -0,0 +1,5 @@ + + + Builds, tests, and runs the project org.openide.util.lookup + + --- a/openide.util.lookup/manifest.mf +++ a/openide.util.lookup/manifest.mf @@ -0,0 +1,5 @@ +Manifest-Version: 1.0 +OpenIDE-Module: org.openide.util.lookup +OpenIDE-Module-Implementation-Version: 1 +OpenIDE-Module-Localizing-Bundle: org/openide/util/lookup/Bundle.properties + --- a/openide.util.lookup/nbproject/project.properties +++ a/openide.util.lookup/nbproject/project.properties @@ -0,0 +1,43 @@ +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. +# +# Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved. +# +# The contents of this file are subject to the terms of either the GNU +# General Public License Version 2 only ("GPL") or the Common +# Development and Distribution License("CDDL") (collectively, the +# "License"). You may not use this file except in compliance with the +# License. You can obtain a copy of the License at +# http://www.netbeans.org/cddl-gplv2.html +# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the +# specific language governing permissions and limitations under the +# License. When distributing the software, include this License Header +# Notice in each file and include the License file at +# nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this +# particular file as subject to the "Classpath" exception as provided +# by Sun in the GPL Version 2 section of the License file that +# accompanied this code. If applicable, add the following below the +# License Header, with the fields enclosed by brackets [] replaced by +# your own identifying information: +# "Portions Copyrighted [year] [name of copyright owner]" +# +# Contributor(s): +# +# The Original Software is NetBeans. The Initial Developer of the Original +# Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun +# Microsystems, Inc. All Rights Reserved. +# +# If you wish your version of this file to be governed by only the CDDL +# or only the GPL Version 2, indicate your decision by adding +# "[Contributor] elects to include this software in this distribution +# under the [CDDL or GPL Version 2] license." If you do not indicate a +# single choice of license, a recipient has the option to distribute +# your version of this file under either the CDDL, the GPL Version 2 or +# to extend the choice of license to its licensees as provided above. +# However, if you add GPL Version 2 code and therefore, elected the GPL +# Version 2 license, then the option applies only if the new code is +# made subject to such option by the copyright holder. + +module.jar.dir=lib +javac.source=1.5 +javac.compilerargs=-Xlint -Xlint:-serial +spec.version.base=8.0.0 --- a/openide.util.lookup/nbproject/project.xml +++ a/openide.util.lookup/nbproject/project.xml @@ -0,0 +1,28 @@ + + + org.netbeans.modules.apisupport.project + + + org.openide.util.lookup + + + + unit + + org.netbeans.libs.junit4 + + + + org.netbeans.modules.nbjunit + + + + + + + org.openide.util + org.openide.util.lookup + + + + --- a/openide.util/src/META-INF/services/javax.annotation.processing.Processor +++ a/openide.util/src/META-INF/services/javax.annotation.processing.Processor @@ -1,2 +1,1 @@ org.netbeans.modules.openide.util.ServiceProviderProcessor -org.netbeans.modules.openide.util.URLStreamHandlerRegistrationProcessor --- a/openide.util.lookup/src/org/openide/util/lookup/Bundle.properties +++ a/openide.util.lookup/src/org/openide/util/lookup/Bundle.properties @@ -0,0 +1,1 @@ +OpenIDE-Module-Name=Lookup --- a/openide.util/src/org/openide/util/lookup/MetaInfServicesLookup.java +++ a/openide.util/src/org/openide/util/lookup/MetaInfServicesLookup.java @@ -57,10 +57,11 @@ import java.util.List; import java.util.Map; import java.util.WeakHashMap; +import java.util.concurrent.Executor; +import java.util.concurrent.Executors; import java.util.logging.Level; import java.util.logging.Logger; import org.openide.util.Lookup; -import org.openide.util.RequestProcessor; /** * @author Jaroslav Tulach, Jesse Glick @@ -70,7 +71,10 @@ final class MetaInfServicesLookup extends AbstractLookup { private static final Logger LOGGER = Logger.getLogger(MetaInfServicesLookup.class.getName()); - static final RequestProcessor RP = new RequestProcessor(MetaInfServicesLookup.class.getName(), 1); + static final Executor RP = Executors.newSingleThreadExecutor(); + /*TBD: Inject RequestProcessor somehow + new RequestProcessor(MetaInfServicesLookup.class.getName(), 1); + */ private static int knownInstancesCount; private static final List> knownInstances; static { --- a/openide.util.lookup/test/unit/src/org/netbeans/modules/openide/util/ActiveQueueTest.java +++ a/openide.util.lookup/test/unit/src/org/netbeans/modules/openide/util/ActiveQueueTest.java @@ -0,0 +1,132 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2009 Sun Microsystems, Inc. + */ + +package org.netbeans.modules.openide.util; + +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.WeakReference; +import java.net.URL; +import java.net.URLClassLoader; +import org.netbeans.junit.NbTestCase; + +/** + * + * @author Jaroslav Tulach + */ +public class ActiveQueueTest extends NbTestCase{ + + public ActiveQueueTest(String name) { + super(name); + } + + public void testMemoryLeak() throws Exception { + final Class u1 = ActiveQueue.class; + class L extends URLClassLoader { + public L() { + super(new URL[] {u1.getProtectionDomain().getCodeSource().getLocation()}, u1.getClassLoader().getParent()); + } + @Override + protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException { + if (name.equals(u1.getName()) || name.startsWith(u1.getName() + "$")) { + Class c = findLoadedClass(name); + if (c == null) { + c = findClass(name); + } + if (resolve) { + resolveClass(c); + } + return c; + } else { + return super.loadClass(name, resolve); + } + } + } + ClassLoader l = new L(); + Class u2 = l.loadClass(u1.getName()); + assertEquals(l, u2.getClassLoader()); + Object obj = new Object(); + @SuppressWarnings("unchecked") + ReferenceQueue q = (ReferenceQueue) u2.getMethod("queue").invoke(null); + RunnableRef ref = new RunnableRef(obj, q); + synchronized (ref) { + obj = null; + assertGC("Ref should be GC'ed as usual", ref); + ref.wait(); + assertTrue("Run method has been executed", ref.executed); + } + Reference r = new WeakReference(u2); + q = null; + u2 = null; + l = null; + assertGC("#86625: Utilities.class can also be collected now", r); + } + + + private static class RunnableRef extends WeakReference + implements Runnable { + public boolean wait; + public boolean entered; + public boolean executed; + + public RunnableRef (Object o) { + this(o, ActiveQueue.queue()); + } + + public RunnableRef(Object o, ReferenceQueue q) { + super(o, q); + } + + public synchronized void run () { + entered = true; + if (wait) { + // notify we are here + notify (); + try { + wait (); + } catch (InterruptedException ex) { + } + } + executed = true; + + notifyAll (); + } + } + +} --- a/openide.util/test/unit/src/org/openide/util/lookup/MetaInfServicesLookupTest.java +++ a/openide.util/test/unit/src/org/openide/util/lookup/MetaInfServicesLookupTest.java @@ -75,8 +75,6 @@ import org.bar.Comparator2; import org.netbeans.junit.MockServices; import org.netbeans.junit.NbTestCase; -import org.openide.util.Enumerations; -import org.openide.util.Exceptions; import org.openide.util.Lookup; import org.openide.util.LookupEvent; import org.openide.util.LookupListener; @@ -410,7 +408,22 @@ }); assertNotNull("Interface found", l.lookup(xface)); assertFalse(event.get()); - MetaInfServicesLookup.RP.post(new Runnable() {public void run() {}}).waitFinished(); + class W implements Runnable { + boolean ok; + public synchronized void run() { + ok = true; + notifyAll(); + } + + public synchronized void await() throws Exception { + while (!ok) { + wait(); + } + } + } + W w = new W(); + MetaInfServicesLookup.RP.execute(w); + w.await(); assertEquals("Now two", 2, res.allInstances().size()); } @@ -470,7 +483,7 @@ try { wait(); } catch (InterruptedException ex) { - Exceptions.printStackTrace(ex); + Logger.getLogger("global").log(Level.WARNING, "", ex); } } } @@ -503,7 +516,7 @@ assertNull(Lookups.metaInfServices(new ClassLoader() { protected @Override Enumeration findResources(String name) throws IOException { if (name.equals("META-INF/services/java.lang.Object")) { - return Enumerations.singleton(new URL(null, "dummy:stuff", new URLStreamHandler() { + return singleton(new URL(null, "dummy:stuff", new URLStreamHandler() { protected URLConnection openConnection(URL u) throws IOException { return new URLConnection(u) { public void connect() throws IOException {} @@ -514,9 +527,10 @@ } })); } else { - return Enumerations.empty(); + return Collections.enumeration(Collections.emptyList()); } } + }).lookup(Object.class)); } public static class Broken1 { @@ -532,4 +546,7 @@ } } + static Enumeration singleton(T t) { + return Collections.enumeration(Collections.singleton(t)); + } } --- a/openide.util/nbproject/project.properties +++ a/openide.util/nbproject/project.properties @@ -42,7 +42,7 @@ module.jar.dir=lib cp.extra=${nb_all}/apisupport.harness/external/openjdk-javac-6-b12.jar -spec.version.base=7.31.0 +spec.version.base=8.0 # For XMLSerializer, needed for XMLUtil.write to work w/ namespaces under JDK 1.4: --- a/openide.util/nbproject/project.xml +++ a/openide.util/nbproject/project.xml @@ -45,7 +45,16 @@ org.openide.util - + + + org.openide.util.lookup + + + + + + + unit @@ -58,6 +67,11 @@ + + org.openide.util.lookup + + + --- a/openide.util/src/META-INF/services/javax.annotation.processing.Processor +++ a/openide.util/src/META-INF/services/javax.annotation.processing.Processor @@ -1,2 +1,1 @@ -org.netbeans.modules.openide.util.ServiceProviderProcessor org.netbeans.modules.openide.util.URLStreamHandlerRegistrationProcessor --- a/openide.util/test/unit/src/org/openide/util/InitJobTest.java +++ a/openide.util/test/unit/src/org/openide/util/InitJobTest.java @@ -81,6 +81,11 @@ protected boolean runInEQ() { return true; } + + @Override + protected int timeOut() { + return 15000; + } /** Basic testing of Utilities.attachInitJob, if calls to AsyncGUIJob * impl conforms to the API behaviour described in javadoc * --- a/openide.util/test/unit/src/org/openide/util/UtilitiesActiveQueueTest.java +++ a/openide.util/test/unit/src/org/openide/util/UtilitiesActiveQueueTest.java @@ -114,48 +114,6 @@ } } - public void testMemoryLeak() throws Exception { - final Class u1 = Utilities.class; - class L extends URLClassLoader { - public L() { - super(new URL[] {u1.getProtectionDomain().getCodeSource().getLocation()}, u1.getClassLoader().getParent()); - } - protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException { - if (name.equals(u1.getName()) || name.startsWith(u1.getName() + "$")) { - Class c = findLoadedClass(name); - if (c == null) { - c = findClass(name); - } - if (resolve) { - resolveClass(c); - } - return c; - } else { - return super.loadClass(name, resolve); - } - } - } - ClassLoader l = new L(); - Class u2 = l.loadClass(u1.getName()); - assertEquals(l, u2.getClassLoader()); - Object obj = new Object(); - @SuppressWarnings("unchecked") - ReferenceQueue q = (ReferenceQueue) u2.getMethod("activeReferenceQueue").invoke(null); - RunnableRef ref = new RunnableRef(obj, q); - synchronized (ref) { - obj = null; - assertGC("Ref should be GC'ed as usual", ref); - ref.wait(); - assertTrue("Run method has been executed", ref.executed); - } - Reference r = new WeakReference(u2); - q = null; - u2 = null; - l = null; - assertGC("#86625: Utilities.class can also be collected now", r); - } - - private static class RunnableRef extends WeakReference implements Runnable { public boolean wait; --- a/profiler/nbproject/project.properties +++ a/profiler/nbproject/project.properties @@ -45,6 +45,7 @@ ${openide.filesystems.dir}/core/org-openide-filesystems.jar:\ ${java.platform.dir}/modules/org-netbeans-modules-java-platform.jar:\ ${openide.util.dir}/lib/org-openide-util.jar:\ + ${openide.util.lookup.dir}/lib/org-openide-util-lookup.jar:\ ${projectapi.dir}/modules/org-netbeans-modules-projectapi.jar:\ ${lib.profiler.common.dir}/modules/org-netbeans-lib-profiler-common.jar:\ ${lib.profiler.dir}/modules/org-netbeans-lib-profiler.jar --- a/ruby.rakeproject/nbproject/project.properties +++ a/ruby.rakeproject/nbproject/project.properties @@ -39,9 +39,5 @@ is.autoload=true -test.unit.cp.extra= -# For XMLSerializer, needed for XMLUtil.write to work w/ namespaces: -test.unit.run.cp.extra=${libs.xerces.dir}/modules/ext/xerces-2.8.0.jar:${libs.xerces.dir}/modules/ext/xml-commons-dom-ranges-1.0.b2.jar - javac.compilerargs=-Xlint:unchecked -Xlint -Xlint:-serial javac.source=1.5 --- a/settings/nbproject/project.xml +++ a/settings/nbproject/project.xml @@ -98,6 +98,14 @@ + 8.0 + + + + org.openide.util.lookup + + + --- a/xml.lexer/nbproject/project.xml +++ a/xml.lexer/nbproject/project.xml @@ -5,17 +5,6 @@ org.netbeans.modules.xml.lexer - org.netbeans.modules.lexer