### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/util/Util.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/Util.java,v retrieving revision 1.56.2.2 diff -u -r1.56.2.2 Util.java --- src/org/eclipse/jdt/core/tests/util/Util.java 5 Jul 2007 15:15:14 -0000 1.56.2.2 +++ src/org/eclipse/jdt/core/tests/util/Util.java 5 Jul 2007 17:27:40 -0000 @@ -639,47 +639,75 @@ * Example of use: [org.eclipse.jdt.core.tests.util.Util.getJavaClassLib()] */ public static String[] getJavaClassLibs() { - String jreDir = getJREDirectory(); - final String osName = System.getProperty("os.name"); - if (jreDir == null) { - return new String[] {}; - } - if (osName.startsWith("Mac")) { - return new String[] { - toNativePath(jreDir + "/../Classes/classes.jar") - }; - } - final String vmName = System.getProperty("java.vm.name"); - if ("J9".equals(vmName)) { - return new String[] { - toNativePath(jreDir + "/lib/jclMax/classes.zip") - }; - } - if ("DRLVM".equals(vmName)) { - FilenameFilter jarFilter = new FilenameFilter() { - public boolean accept(File dir, String name) { - return name.endsWith(".jar") & !name.endsWith("-src.jar"); + // check bootclasspath properties for Sun, JRockit and Harmony VMs + String bootclasspathProperty = System.getProperty("sun.boot.class.path"); //$NON-NLS-1$ + if ((bootclasspathProperty == null) || (bootclasspathProperty.length() == 0)) { + // IBM J9 VMs + bootclasspathProperty = System.getProperty("vm.boot.class.path"); //$NON-NLS-1$ + if ((bootclasspathProperty == null) || (bootclasspathProperty.length() == 0)) { + // Harmony using IBM VME + bootclasspathProperty = System.getProperty("org.apache.harmony.boot.class.path"); //$NON-NLS-1$ + } + } + String[] jars = null; + if ((bootclasspathProperty != null) && (bootclasspathProperty.length() != 0)) { + StringTokenizer tokenizer = new StringTokenizer(bootclasspathProperty, File.pathSeparator); + final int size = tokenizer.countTokens(); + jars = new String[size]; + int i = 0; + while (tokenizer.hasMoreTokens()) { + final String fileName = toNativePath(tokenizer.nextToken()); + if (new File(fileName).exists()) { + jars[i] = fileName; + i++; } - }; - String[] jars = new File(jreDir + "/lib/boot/").list(jarFilter); - for (int i = 0; i < jars.length; i++) { - jars[i] = toNativePath(jreDir + "/lib/boot/" + jars[i]); } - return jars; + if (size != i) { + // resize + System.arraycopy(jars, 0, (jars = new String[i]), 0, i); + } + } else { + String jreDir = getJREDirectory(); + final String osName = System.getProperty("os.name"); + if (jreDir == null) { + return new String[] {}; + } + if (osName.startsWith("Mac")) { + return new String[] { + toNativePath(jreDir + "/../Classes/classes.jar") + }; + } + final String vmName = System.getProperty("java.vm.name"); + if ("J9".equals(vmName)) { + return new String[] { + toNativePath(jreDir + "/lib/jclMax/classes.zip") + }; + } + String[] jarsNames = null; + ArrayList paths = new ArrayList(); + if ("DRLVM".equals(vmName)) { + FilenameFilter jarFilter = new FilenameFilter() { + public boolean accept(File dir, String name) { + return name.endsWith(".jar") & !name.endsWith("-src.jar"); + } + }; + jarsNames = new File(jreDir + "/lib/boot/").list(jarFilter); + addJarEntries(jreDir + "/lib/boot/", jarsNames, paths); + } else { + jarsNames = new String[] { + "/lib/vm.jar", + "/lib/rt.jar", + "/lib/core.jar", + "/lib/security.jar", + "/lib/xml.jar", + "/lib/graphics.jar" + }; + addJarEntries(jreDir, jarsNames, paths); + } + jars = new String[paths.size()]; + paths.toArray(jars); } - ArrayList paths = new ArrayList(); - String[] jarsNames = new String[] { - "/lib/vm.jar", - "/lib/rt.jar", - "/lib/core.jar", - "/lib/security.jar", - "/lib/xml.jar", - "/lib/graphics.jar" - }; - addJarEntries(jreDir, jarsNames, paths); - String[] result = new String[paths.size()]; - paths.toArray(result); - return result; + return jars; } private static void addJarEntries(String jreDir, String[] jarNames, ArrayList paths) { for (int i = 0, max = jarNames.length; i < max; i++) { @@ -691,15 +719,14 @@ } } public static String getJavaClassLibsAsString() { - String[] classLibs = getJavaClassLibs(); - StringBuffer buffer = new StringBuffer(); - for (int i = 0, max = classLibs.length; i < max; i++) { - buffer - .append(classLibs[i]) - .append(File.pathSeparatorChar); - - } - return buffer.toString(); + String[] classLibs = getJavaClassLibs(); + StringBuffer buffer = new StringBuffer(); + for (int i = 0, max = classLibs.length; i < max; i++) { + buffer + .append(classLibs[i]) + .append(File.pathSeparatorChar); + } + return buffer.toString(); } /** * Returns the JRE directory this tests are running on. #P org.eclipse.jdt.core.tests.builder Index: src/org/eclipse/jdt/core/tests/builder/BuildpathTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuildpathTests.java,v retrieving revision 1.38 diff -u -r1.38 BuildpathTests.java --- src/org/eclipse/jdt/core/tests/builder/BuildpathTests.java 8 May 2007 17:24:26 -0000 1.38 +++ src/org/eclipse/jdt/core/tests/builder/BuildpathTests.java 5 Jul 2007 17:27:42 -0000 @@ -77,7 +77,7 @@ //---------------------------- // Step 2 - //---------------------------- + //---------------------------- StringBuffer buffer = new StringBuffer("\n"); //$NON-NLS-1$ buffer.append("\n"); //$NON-NLS-1$ buffer.append(" \n"); //$NON-NLS-1$ @@ -100,7 +100,7 @@ } finally { env.setAutoBuilding(wasAutoBuilding); } -} +} public void testClosedProject() throws JavaModelException { IPath project1Path = env.addProject("CP1"); //$NON-NLS-1$ @@ -287,14 +287,14 @@ ); long lastModified = new java.io.File(externalJar).lastModified(); env.addExternalJar(projectPath, externalJar); - + // build -> expecting problems fullBuild(); expectingProblemsFor( classTest, "Problem : The method bar() is undefined for the type Y [ resource : range : <57,60> category : <50> severity : <2>]" ); - + try { Thread.sleep(1000); } catch(InterruptedException e) { @@ -312,14 +312,14 @@ new HashMap(), externalJar ); - + new java.io.File(externalJar).setLastModified(lastModified + 1000); // to be sure its different // refresh project and rebuild -> expecting no problems IJavaProject project = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot().getProject("Project")); //$NON-NLS-1$ project.getJavaModel().refreshExternalArchives(new IJavaElement[] {project}, null); incrementalBuild(); expectingNoProblems(); - + } public void testMissingBuilder() throws JavaModelException { @@ -426,7 +426,7 @@ //---------------------------- // Step 2 - //---------------------------- + //---------------------------- env.addExternalJars(projectPath, Util.getJavaClassLibs()); incrementalBuild(); @@ -459,7 +459,7 @@ expectingSpecificProblemFor( projectPath, new Problem("", "The project was not built since its build path is incomplete. Cannot find the class file for java.lang.Object. Fix the build path then try building this project", projectPath, -1, -1, CategorizedProblem.CAT_BUILDPATH, IMarker.SEVERITY_ERROR)); //$NON-NLS-1$ //$NON-NLS-2$ - + Problem[] prob1 = env.getProblemsFor(classTest1); Problem[] prob2 = env.getProblemsFor(classTest2); Problem[] prob3 = env.getProblemsFor(classTest3); @@ -474,7 +474,7 @@ //---------------------------- // Step 2 - //---------------------------- + //---------------------------- env.addExternalJars(projectPath, Util.getJavaClassLibs()); incrementalBuild(); @@ -516,7 +516,7 @@ new Problem("Build path", "Project 'Project' is missing required library: 'lib/dummy.jar'", projectPath, -1, -1, CategorizedProblem.CAT_BUILDPATH, IMarker.SEVERITY_ERROR)); env.removeProject(projectPath); } - + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=172345 public void testMissingLibrary4() throws JavaModelException { this.abortOnFailure = false; // this test is failing on some releng boxes => do not abort on failures @@ -543,38 +543,50 @@ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=172345 public void testIncompatibleJdkLEvelOnProject() throws JavaModelException { this.abortOnFailure = false; // NOT sure this test will pass on releng boxes => do not abort on failures - + // Create project IPath projectPath = env.addProject("Project"); IJavaProject project = env.getJavaProject(projectPath); String[] classlibs = Util.getJavaClassLibs(); env.addExternalJars(projectPath, classlibs); - + Arrays.sort(classlibs); + // Build it expecting no problem fullBuild(); expectingNoProblems(); // Build incompatible jdk level problem string - String jclPath = project.getPackageFragmentRoot(classlibs[0]).getPath().makeRelative().toString(); String projectRuntime = project.getOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, true); // Change project incompatible jdk level preferences to warning, perform incremental build and expect 1 problem project.setOption(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL, CompilerOptions.WARNING); incrementalBuild(); + StringBuffer buffer = new StringBuffer(); + for (int i = 0, max = classlibs.length; i < max; i++) { + if (i>0) buffer.append('\n'); + buffer.append(getJdkLevelProblem(projectRuntime, project.getPackageFragmentRoot(classlibs[i]).getPath().makeRelative().toString(), IMarker.SEVERITY_WARNING)); + } + expectingProblemsFor( projectPath, - getJdkLevelProblem(projectRuntime, jclPath, IMarker.SEVERITY_WARNING) + String.valueOf(buffer) ); // Change project incompatible jdk level preferences to error, perform incremental build and expect 2 problems project.setOption(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL, CompilerOptions.ERROR); incrementalBuild(); + + buffer = new StringBuffer(); + for (int i = 0, max = classlibs.length; i < max; i++) { + if (i>0) buffer.append('\n'); + buffer.append(getJdkLevelProblem(projectRuntime, project.getPackageFragmentRoot(classlibs[i]).getPath().makeRelative().toString(), IMarker.SEVERITY_ERROR)); + } expectingProblemsFor( projectPath, - "Problem : The project cannot be built until build path errors are resolved [ resource : range : <-1,-1> category : <10> severity : <2>]\n" + - getJdkLevelProblem(projectRuntime, jclPath, IMarker.SEVERITY_ERROR) + "Problem : The project cannot be built until build path errors are resolved [ resource : range : <-1,-1> category : <10> severity : <2>]\n" + + String.valueOf(buffer) ); - + // Remove project to avoid side effect on other tests env.removeProject(projectPath); } @@ -588,38 +600,52 @@ String incompatibleJdkLevel = preferences.get(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL, null); try { this.abortOnFailure = false; // NOT sure this test will pass on all releng boxes => do not abort on failures - + // Create project IPath projectPath = env.addProject("Project"); IJavaProject project = env.getJavaProject(projectPath); String[] classlibs = Util.getJavaClassLibs(); env.addExternalJars(projectPath, classlibs); - + // Build it expecting no problem fullBuild(); expectingNoProblems(); // Build incompatible jdk level problem string - String jclPath = project.getPackageFragmentRoot(classlibs[0]).getPath().makeRelative().toString(); String wkspRuntime = JavaCore.getOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM); - + // sort classlibs + Arrays.sort(classlibs); // Change workspace incompatible jdk level preferences to warning, perform incremental build and expect 1 problem preferences.put(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL, JavaCore.WARNING); incrementalBuild(); + + StringBuffer buffer = new StringBuffer(); + for (int i = 0, max = classlibs.length; i < max; i++) { + if (i>0) buffer.append('\n'); + buffer.append(getJdkLevelProblem(wkspRuntime, project.getPackageFragmentRoot(classlibs[i]).getPath().makeRelative().toString(), IMarker.SEVERITY_WARNING)); + } + expectingProblemsFor( projectPath, - getJdkLevelProblem(wkspRuntime, jclPath, IMarker.SEVERITY_WARNING) + String.valueOf(buffer) ); - + // Change workspace incompatible jdk level preferences to error, perform incremental build and expect 2 problems preferences.put(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL, JavaCore.ERROR); incrementalBuild(); + + buffer = new StringBuffer(); + for (int i = 0, max = classlibs.length; i < max; i++) { + if (i>0) buffer.append('\n'); + buffer.append(getJdkLevelProblem(wkspRuntime, project.getPackageFragmentRoot(classlibs[i]).getPath().makeRelative().toString(), IMarker.SEVERITY_ERROR)); + } + expectingProblemsFor( projectPath, - "Problem : The project cannot be built until build path errors are resolved [ resource : range : <-1,-1> category : <10> severity : <2>]\n" + - getJdkLevelProblem(wkspRuntime, jclPath, IMarker.SEVERITY_ERROR) + "Problem : The project cannot be built until build path errors are resolved [ resource : range : <-1,-1> category : <10> severity : <2>]\n" + + String.valueOf(buffer) ); - + // Remove project to avoid side effect on other tests env.removeProject(projectPath); } finally { @@ -753,12 +779,12 @@ ); fullBuild(); expectingNoProblems(); - env.addClass(defaultPackagePath, "Y", + env.addClass(defaultPackagePath, "Y", "public class Y implements X.Entry.Internal {\n" + " public Internal createEntry() {\n" + " return null;\n" + " }\n" + - "}"); + "}"); incrementalBuild(); expectingNoProblems(); }