Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 96606 Details for
Bug 182360
Only Jar and Zip files allowed for java.io.File in ClasspathContainers using
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix and regression tests
182360_v20.txt (text/plain), 153.56 KB, created by
Jerome Lanneluc
on 2008-04-18 10:41:14 EDT
(
hide
)
Description:
Proposed fix and regression tests
Filename:
MIME Type:
Creator:
Jerome Lanneluc
Created:
2008-04-18 10:41:14 EDT
Size:
153.56 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java,v >retrieving revision 1.160 >diff -u -r1.160 BatchCompilerTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 17 Apr 2008 14:11:42 -0000 1.160 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 18 Apr 2008 14:35:39 -0000 >@@ -1484,18 +1484,18 @@ > " with ''+''.\n" + > " \n" + > " Classpath options:\n" + >- " -cp -classpath <directories and zip/jar files separated by " + File.pathSeparator + ">\n" + >+ " -cp -classpath <directories and ZIP archives separated by " + File.pathSeparator + ">\n" + > " specify location for application classes and sources.\n" + > " Each directory or file can specify access rules for\n" + > " types between ''['' and '']'' (e.g. [-X] to forbid\n" + > " access to type X, [~X] to discourage access to type X,\n" + > " [+p/X" + File.pathSeparator + "-p/*] to forbid access to all types in package p\n" + > " but allow access to p/X)\n" + >- " -bootclasspath <directories and zip/jar files separated by " + File.pathSeparator + ">\n" + >+ " -bootclasspath <directories and ZIP archives separated by " + File.pathSeparator + ">\n" + > " specify location for system classes. Each directory or\n" + > " file can specify access rules for types between ''[''\n" + > " and '']''\n" + >- " -sourcepath <directories and zip/jar files separated by " + File.pathSeparator + ">\n" + >+ " -sourcepath <directories and ZIP archives separated by " + File.pathSeparator + ">\n" + > " specify location for application sources. Each directory\n" + > " or file can specify access rules for types between ''[''\n" + > " and '']''. Each directory can further specify a specific\n" + >@@ -1503,12 +1503,12 @@ > " and '']''; this overrides the general ''-d'' option.\n" + > " .class files created from source files contained in a\n" + > " jar file are put in the user.dir folder in case no\n" + >- " general ''-d'' option is specified. zip/jar files cannot\n" + >+ " general ''-d'' option is specified. ZIP archives cannot\n" + > " override the general ''-d'' option\n" + > " -extdirs <directories separated by " + File.pathSeparator + ">\n" + >- " specify location for extension zip/jar files\n" + >+ " specify location for extension ZIP archives\n" + > " -endorseddirs <directories separated by " + File.pathSeparator + ">\n" + >- " specify location for endorsed zip/jar files\n" + >+ " specify location for endorsed ZIP archives\n" + > " -d <dir> destination directory (if omitted, no directory is\n" + > " created); this option can be overridden per source\n" + > " directory\n" + >@@ -1544,7 +1544,7 @@ > " Annotation processing options:\n" + > " These options are meaningful only in a 1.6 environment.\n" + > " -Akey[=value] options that are passed to annotation processors\n" + >- " -processorpath <directories and zip/jar files separated by " + File.pathSeparator + ">\n" + >+ " -processorpath <directories and ZIP archives separated by " + File.pathSeparator + ">\n" + > " specify locations where to find annotation processors.\n" + > " If this option is not used, the classpath will be\n" + > " searched for processors\n" + >@@ -10798,4 +10798,60 @@ > this.verifier.execute("Y", new String[] {OUTPUT_DIR }); > assertTrue(this.verifier.getExecutionOutput().startsWith("1")); // skip trailing newline > } >+ >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=182360 >+public void test281_classpath() { >+ runConformTest( >+ new String[] { >+ "src1/X.java", >+ "public class X {\n" + >+ "}", >+ }, >+ "\"" + OUTPUT_DIR + File.separator + "src1/X.java\" -cp Y.java", >+ "" /* expectedOutOutputString */, >+ "incorrect classpath: Y.java\n", >+ false/*shouldFlushOutput*/); >+} >+ >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=182360 >+public void test282_classpath() { >+ runConformTest( >+ new String[] { >+ "src1/X.java", >+ "public class X {\n" + >+ "}", >+ }, >+ "\"" + OUTPUT_DIR + File.separator + "src1/X.java\" -cp p/Y.java", >+ "" /* expectedOutOutputString */, >+ "incorrect classpath: p/Y.java\n", >+ false/*shouldFlushOutput*/); >+} >+ >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=182360 >+public void test283_classpath() { >+ runConformTest( >+ new String[] { >+ "src1/X.java", >+ "public class X {\n" + >+ "}", >+ }, >+ "\"" + OUTPUT_DIR + File.separator + "src1/X.java\" -cp Y.class", >+ "" /* expectedOutOutputString */, >+ "incorrect classpath: Y.class\n", >+ false/*shouldFlushOutput*/); >+} >+ >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=182360 >+public void test284_classpath() { >+ runConformTest( >+ new String[] { >+ "src1/X.java", >+ "public class X {\n" + >+ "}", >+ }, >+ "\"" + OUTPUT_DIR + File.separator + "src1/X.java\" -cp p/Y.class", >+ "" /* expectedOutOutputString */, >+ "incorrect classpath: p/Y.class\n", >+ false/*shouldFlushOutput*/); >+} > } >#P org.eclipse.jdt.core >Index: model/org/eclipse/jdt/core/WorkingCopyOwner.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/WorkingCopyOwner.java,v >retrieving revision 1.23 >diff -u -r1.23 WorkingCopyOwner.java >--- model/org/eclipse/jdt/core/WorkingCopyOwner.java 14 Mar 2007 08:18:47 -0000 1.23 >+++ model/org/eclipse/jdt/core/WorkingCopyOwner.java 18 Apr 2008 14:35:42 -0000 >@@ -11,7 +11,6 @@ > package org.eclipse.jdt.core; > > import org.eclipse.core.runtime.IProgressMonitor; >-import org.eclipse.core.runtime.Path; > import org.eclipse.jdt.internal.core.BufferManager; > import org.eclipse.jdt.internal.core.CompilationUnit; > import org.eclipse.jdt.internal.core.DefaultWorkingCopyOwner; >@@ -135,7 +134,7 @@ > */ > public final ICompilationUnit newWorkingCopy(String name, IClasspathEntry[] classpath, IProblemRequestor problemRequestor, IProgressMonitor monitor) throws JavaModelException { > ExternalJavaProject project = new ExternalJavaProject(classpath); >- IPackageFragment parent = project.getPackageFragmentRoot(Path.EMPTY).getPackageFragment(IPackageFragment.DEFAULT_PACKAGE_NAME); >+ IPackageFragment parent = project.getPackageFragmentRoot(project.getProject()).getPackageFragment(IPackageFragment.DEFAULT_PACKAGE_NAME); > CompilationUnit result = new CompilationUnit((PackageFragment) parent, name, this); > result.becomeWorkingCopy(problemRequestor, monitor); > return result; >@@ -182,7 +181,7 @@ > */ > public final ICompilationUnit newWorkingCopy(String name, IClasspathEntry[] classpath, IProgressMonitor monitor) throws JavaModelException { > ExternalJavaProject project = new ExternalJavaProject(classpath); >- IPackageFragment parent = project.getPackageFragmentRoot(Path.EMPTY).getPackageFragment(IPackageFragment.DEFAULT_PACKAGE_NAME); >+ IPackageFragment parent = project.getPackageFragmentRoot(project.getProject()).getPackageFragment(IPackageFragment.DEFAULT_PACKAGE_NAME); > CompilationUnit result = new CompilationUnit((PackageFragment) parent, name, this); > result.becomeWorkingCopy(getProblemRequestor(result), monitor); > return result; >Index: model/org/eclipse/jdt/core/IJavaProject.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaProject.java,v >retrieving revision 1.97 >diff -u -r1.97 IJavaProject.java >--- model/org/eclipse/jdt/core/IJavaProject.java 29 Feb 2008 10:56:51 -0000 1.97 >+++ model/org/eclipse/jdt/core/IJavaProject.java 18 Apr 2008 14:35:41 -0000 >@@ -473,8 +473,9 @@ > IPath getOutputLocation() throws JavaModelException; > > /** >- * Returns a package fragment root for an external library (a JAR or - since 3.4 - a class folder) >- * at the specified file system path. >+ * Returns a package fragment root for an external library >+ * (a ZIP archive - e.g. a <code>.jar</code>, a <code>.zip</code> file, etc. - >+ * or - since 3.4 - a class folder) at the specified file system path. > * This is a handle-only method. The underlying <code>java.io.File</code> > * may or may not exist. No resource is associated with this local library > * package fragment root. >@@ -487,13 +488,13 @@ > /** > * Returns a package fragment root for the given resource, which > * must either be a folder representing the top of a package hierarchy, >- * or a <code>.jar</code> or <code>.zip</code> file. >+ * or a ZIP archive (e.g. a <code>.jar</code>, a <code>.zip</code> file, etc.) > * This is a handle-only method. The underlying resource may or may not exist. > * > * @param resource the given resource > * @return a package fragment root for the given resource, which > * must either be a folder representing the top of a package hierarchy, >- * or a <code>.jar</code> or <code>.zip</code> file >+ * or a ZIP archive (e.g. a <code>.jar</code>, a <code>.zip</code> file, etc.) > */ > IPackageFragmentRoot getPackageFragmentRoot(IResource resource); > >Index: model/org/eclipse/jdt/core/JavaCore.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java,v >retrieving revision 1.612 >diff -u -r1.612 JavaCore.java >--- model/org/eclipse/jdt/core/JavaCore.java 25 Mar 2008 12:14:56 -0000 1.612 >+++ model/org/eclipse/jdt/core/JavaCore.java 18 Apr 2008 14:35:42 -0000 >@@ -127,7 +127,6 @@ > import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; > import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; > import org.eclipse.jdt.internal.compiler.problem.ProblemReporter; >-import org.eclipse.jdt.internal.compiler.util.SuffixConstants; > import org.eclipse.jdt.internal.core.*; > import org.eclipse.jdt.internal.core.builder.JavaBuilder; > import org.eclipse.jdt.internal.core.builder.State; >@@ -2363,7 +2362,7 @@ > * <li>a file with one of the {@link JavaCore#getJavaLikeExtensions() > * Java-like extensions} - the element returned is the corresponding <code>ICompilationUnit</code></li> > * <li>a <code>.class</code> file - the element returned is the corresponding <code>IClassFile</code></li> >- * <li>a <code>.jar</code> file - the element returned is the corresponding <code>IPackageFragmentRoot</code></li> >+ * <li>a ZIP archive (e.g. a <code>.jar</code>, a <code>.zip</code> file, etc.) - the element returned is the corresponding <code>IPackageFragmentRoot</code></li> > * </ul> > * <p> > * Creating a Java element has the side effect of creating and opening all of the >@@ -2421,7 +2420,7 @@ > * <li>a file with one of the {@link JavaCore#getJavaLikeExtensions() > * Java-like extensions} - the element returned is the corresponding <code>ICompilationUnit</code></li> > * <li>a <code>.class</code> file - the element returned is the corresponding <code>IClassFile</code></li> >- * <li>a <code>.jar</code> file - the element returned is the corresponding <code>IPackageFragmentRoot</code></li> >+ * <li>a ZIP archive (e.g. a <code>.jar</code>, a <code>.zip</code> file, etc.) - the element returned is the corresponding <code>IPackageFragmentRoot</code></li> > * <li>a folder - the element returned is the corresponding <code>IPackageFragmentRoot</code> > * or <code>IPackageFragment</code></li> > * <li>the workspace root resource - the element returned is the <code>IJavaModel</code></li> >@@ -2448,7 +2447,7 @@ > * <li>a file with one of the {@link JavaCore#getJavaLikeExtensions() > * Java-like extensions} - the element returned is the corresponding <code>ICompilationUnit</code></li> > * <li>a <code>.class</code> file - the element returned is the corresponding <code>IClassFile</code></li> >- * <li>a <code>.jar</code> file - the element returned is the corresponding <code>IPackageFragmentRoot</code></li> >+ * <li>a ZIP archive (e.g. a <code>.jar</code>, a <code>.zip</code> file, etc.) - the element returned is the corresponding <code>IPackageFragmentRoot</code></li> > * <li>a folder - the element returned is the corresponding <code>IPackageFragmentRoot</code> > * or <code>IPackageFragment</code></li> > * <li>the workspace root resource - the element returned is the <code>IJavaModel</code></li> >@@ -3231,20 +3230,7 @@ > entry.getExtraAttributes(), > entry.isExported()); > case IResource.FILE : >- if (org.eclipse.jdt.internal.compiler.util.Util.isArchiveFileName(resolvedResource.getName())) { >- // internal binary archive >- return JavaCore.newLibraryEntry( >- resolvedPath, >- getResolvedVariablePath(entry.getSourceAttachmentPath()), >- getResolvedVariablePath(entry.getSourceAttachmentRootPath()), >- entry.getAccessRules(), >- entry.getExtraAttributes(), >- entry.isExported()); >- } >- break; >- >- case IResource.FOLDER : >- // internal binary folder >+ // internal binary archive > return JavaCore.newLibraryEntry( > resolvedPath, > getResolvedVariablePath(entry.getSourceAttachmentPath()), >@@ -3252,15 +3238,8 @@ > entry.getAccessRules(), > entry.getExtraAttributes(), > entry.isExported()); >- } >- } >- if (target instanceof File) { >- File externalFile = JavaModel.getFile(target); >- if (externalFile != null) { >- // outside the workspace >- String fileName = externalFile.getName().toLowerCase(); >- if (fileName.endsWith(SuffixConstants.SUFFIX_STRING_jar) || fileName.endsWith(SuffixConstants.SUFFIX_STRING_zip)) { >- // external binary archive >+ case IResource.FOLDER : >+ // internal binary folder > return JavaCore.newLibraryEntry( > resolvedPath, > getResolvedVariablePath(entry.getSourceAttachmentPath()), >@@ -3268,7 +3247,19 @@ > entry.getAccessRules(), > entry.getExtraAttributes(), > entry.isExported()); >- } >+ } >+ } >+ if (target instanceof File) { >+ File externalFile = JavaModel.getFile(target); >+ if (externalFile != null) { >+ // external binary archive >+ return JavaCore.newLibraryEntry( >+ resolvedPath, >+ getResolvedVariablePath(entry.getSourceAttachmentPath()), >+ getResolvedVariablePath(entry.getSourceAttachmentRootPath()), >+ entry.getAccessRules(), >+ entry.getExtraAttributes(), >+ entry.isExported()); > } else { > // non-existing file > if (resolvedPath.isAbsolute()){ >Index: model/org/eclipse/jdt/core/JavaConventions.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaConventions.java,v >retrieving revision 1.116 >diff -u -r1.116 JavaConventions.java >--- model/org/eclipse/jdt/core/JavaConventions.java 6 Nov 2006 21:47:54 -0000 1.116 >+++ model/org/eclipse/jdt/core/JavaConventions.java 18 Apr 2008 14:35:41 -0000 >@@ -25,7 +25,6 @@ > import org.eclipse.jdt.internal.compiler.parser.Scanner; > import org.eclipse.jdt.internal.compiler.parser.ScannerHelper; > import org.eclipse.jdt.internal.compiler.parser.TerminalTokens; >-import org.eclipse.jdt.internal.compiler.util.SuffixConstants; > import org.eclipse.jdt.internal.core.*; > import org.eclipse.jdt.internal.core.util.Messages; > >@@ -62,14 +61,6 @@ > if (rootPath1 == null || rootPath2 == null) { > return false; > } >- String extension1 = rootPath1.getFileExtension(); >- String extension2 = rootPath2.getFileExtension(); >- if (extension1 != null && (extension1.equalsIgnoreCase(SuffixConstants.EXTENSION_JAR) || extension1.equalsIgnoreCase(SuffixConstants.EXTENSION_ZIP))) { >- return false; >- } >- if (extension2 != null && (extension2.equalsIgnoreCase(SuffixConstants.EXTENSION_JAR) || extension2.equalsIgnoreCase(SuffixConstants.EXTENSION_ZIP))) { >- return false; >- } > return rootPath1.isPrefixOf(rootPath2) || rootPath2.isPrefixOf(rootPath1); > } > >Index: model/org/eclipse/jdt/internal/core/util/HandleFactory.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/HandleFactory.java,v >retrieving revision 1.45 >diff -u -r1.45 HandleFactory.java >--- model/org/eclipse/jdt/internal/core/util/HandleFactory.java 10 Apr 2008 14:38:23 -0000 1.45 >+++ model/org/eclipse/jdt/internal/core/util/HandleFactory.java 18 Apr 2008 14:35:44 -0000 >@@ -270,7 +270,7 @@ > int index = 0; > for (int i = 0; i < length; i++) { > IPath path = enclosingProjectsAndJars[i]; >- if (!org.eclipse.jdt.internal.compiler.util.Util.isArchiveFileName(path.lastSegment())) { >+ if (path.segmentCount() == 1) { > projects[index++] = this.javaModel.getJavaProject(path.segment(0)); > } > } >Index: model/org/eclipse/jdt/internal/core/ExternalPackageFragmentRoot.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ExternalPackageFragmentRoot.java,v >retrieving revision 1.6 >diff -u -r1.6 ExternalPackageFragmentRoot.java >--- model/org/eclipse/jdt/internal/core/ExternalPackageFragmentRoot.java 2 Apr 2008 14:26:20 -0000 1.6 >+++ model/org/eclipse/jdt/internal/core/ExternalPackageFragmentRoot.java 18 Apr 2008 14:35:43 -0000 >@@ -107,7 +107,7 @@ > > public IResource resource(PackageFragmentRoot root) { > if (this.resource == null) >- return (IResource) (this.resource = JavaModelManager.getExternalManager().getFolder(this.externalPath)); >+ return this.resource = JavaModelManager.getExternalManager().getFolder(this.externalPath); > return super.resource(root); > } > >Index: model/org/eclipse/jdt/internal/core/ExternalFoldersManager.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ExternalFoldersManager.java,v >retrieving revision 1.6 >diff -u -r1.6 ExternalFoldersManager.java >--- model/org/eclipse/jdt/internal/core/ExternalFoldersManager.java 19 Mar 2008 16:20:43 -0000 1.6 >+++ model/org/eclipse/jdt/internal/core/ExternalFoldersManager.java 18 Apr 2008 14:35:42 -0000 >@@ -77,7 +77,7 @@ > File externalFolder = externalPath.toFile(); > if (externalFolder.isFile()) > return false; >- if (org.eclipse.jdt.internal.compiler.util.Util.isArchiveFileName(externalPath.lastSegment()) && !externalFolder.exists()) >+ if (externalPath.getFileExtension() != null/*likely a .jar, .zip, .rar or other file*/ && !externalFolder.exists()) > return false; > return true; > } >Index: model/org/eclipse/jdt/internal/core/JavaModel.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModel.java,v >retrieving revision 1.93 >diff -u -r1.93 JavaModel.java >--- model/org/eclipse/jdt/internal/core/JavaModel.java 6 Mar 2008 14:24:01 -0000 1.93 >+++ model/org/eclipse/jdt/internal/core/JavaModel.java 18 Apr 2008 14:35:43 -0000 >@@ -318,7 +318,7 @@ > return target; > return getExternalTarget(path, checkResourceExistence); > } >-public static Object getWorkspaceTarget(IPath path) { >+public static IResource getWorkspaceTarget(IPath path) { > if (path == null || path.getDevice() != null) > return null; > IWorkspace workspace = ResourcesPlugin.getWorkspace(); >Index: model/org/eclipse/jdt/internal/core/SourceMapper.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceMapper.java,v >retrieving revision 1.132 >diff -u -r1.132 SourceMapper.java >--- model/org/eclipse/jdt/internal/core/SourceMapper.java 26 Feb 2008 10:11:46 -0000 1.132 >+++ model/org/eclipse/jdt/internal/core/SourceMapper.java 18 Apr 2008 14:35:44 -0000 >@@ -412,7 +412,10 @@ > } > } > >- if (Util.isArchiveFileName(this.sourcePath.lastSegment())) { >+ Object target = JavaModel.getTarget(this.sourcePath, true); >+ if (target instanceof IContainer) { >+ computeRootPath((IContainer)target, firstLevelPackageNames, containsADefaultPackage, tempRoots); >+ } else { > JavaModelManager manager = JavaModelManager.getJavaModelManager(); > ZipFile zip = null; > try { >@@ -443,11 +446,6 @@ > } finally { > manager.closeZipFile(zip); // handle null case > } >- } else { >- Object target = JavaModel.getTarget(this.sourcePath, true); >- if (target instanceof IContainer) { >- computeRootPath((IContainer)target, firstLevelPackageNames, containsADefaultPackage, tempRoots); >- } > } > int size = tempRoots.size(); > if (this.rootPaths != null) { >@@ -884,7 +882,17 @@ > > public char[] findSource(String fullName) { > char[] source = null; >- if (Util.isArchiveFileName(this.sourcePath.lastSegment())) { >+ Object target = JavaModel.getTarget(this.sourcePath, true); >+ if (target instanceof IContainer) { >+ IResource res = ((IContainer)target).findMember(fullName); >+ if (res instanceof IFile) { >+ try { >+ source = org.eclipse.jdt.internal.core.util.Util.getResourceContentsAsCharArray((IFile)res); >+ } catch (JavaModelException e) { >+ // ignore >+ } >+ } >+ } else { > // try to get the entry > ZipEntry entry = null; > ZipFile zip = null; >@@ -901,18 +909,6 @@ > } finally { > manager.closeZipFile(zip); // handle null case > } >- } else { >- Object target = JavaModel.getTarget(this.sourcePath, true); >- if (target instanceof IContainer) { >- IResource res = ((IContainer)target).findMember(fullName); >- if (res instanceof IFile) { >- try { >- source = org.eclipse.jdt.internal.core.util.Util.getResourceContentsAsCharArray((IFile)res); >- } catch (JavaModelException e) { >- // ignore >- } >- } >- } > } > return source; > } >Index: model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java,v >retrieving revision 1.129 >diff -u -r1.129 PackageFragmentRoot.java >--- model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java 13 Mar 2008 10:05:21 -0000 1.129 >+++ model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java 18 Apr 2008 14:35:44 -0000 >@@ -38,10 +38,9 @@ > public final static String NO_SOURCE_ATTACHMENT = ""; //$NON-NLS-1$ > > /** >- * The resource associated with this root. >- * (an IResource or a java.io.File (for external jar only)) >+ * The resource associated with this root (null for external jar) > */ >- protected Object resource; >+ protected IResource resource; > > /** > * Constructs a package fragment root which is the root of the java package >@@ -335,27 +334,10 @@ > JavaProject parentProject = (JavaProject) getJavaProject(); > try { > entry = parentProject.getClasspathEntryFor(rootPath); >- if (entry != null){ >+ if (entry != null) { > Object target = JavaModel.getTarget(entry.getSourceAttachmentPath(), true); >- if (target instanceof IResource) { >- if (target instanceof IFile) { >- IFile file = (IFile) target; >- if (org.eclipse.jdt.internal.compiler.util.Util.isArchiveFileName(file.getName())){ >- return entry; >- } >- } else if (target instanceof IContainer) { >- return entry; >- } >- } else if (target instanceof java.io.File){ >- java.io.File file = JavaModel.getFile(target); >- if (file != null) { >- if (org.eclipse.jdt.internal.compiler.util.Util.isArchiveFileName(file.getName())){ >- return entry; >- } >- } else { >- // external directory >- return entry; >- } >+ if (target != null) { >+ return entry; > } > } > } catch(JavaModelException e){ >@@ -372,20 +354,8 @@ > entry = jProject.getClasspathEntryFor(rootPath); > if (entry != null){ > Object target = JavaModel.getTarget(entry.getSourceAttachmentPath(), true); >- if (target instanceof IResource) { >- if (target instanceof IFile){ >- IFile file = (IFile) target; >- if (org.eclipse.jdt.internal.compiler.util.Util.isArchiveFileName(file.getName())){ >- return entry; >- } >- } else if (target instanceof IContainer) { >- return entry; >- } >- } else if (target instanceof java.io.File){ >- java.io.File file = (java.io.File) target; >- if (org.eclipse.jdt.internal.compiler.util.Util.isArchiveFileName(file.getName())){ >- return entry; >- } >+ if (target != null) { >+ return entry; > } > } > } catch(JavaModelException e){ >@@ -587,15 +557,15 @@ > > > public IResource resource() { >- if (this.resource instanceof IResource) // perf improvement to avoid message send in resource() >- return (IResource) this.resource; >+ if (this.resource != null) // perf improvement to avoid message send in resource() >+ return this.resource; > return super.resource(); > } > /* > * @see IJavaElement > */ > public IResource resource(PackageFragmentRoot root) { >- return (IResource)this.resource; >+ return this.resource; > } > > /** >@@ -776,18 +746,16 @@ > protected void toStringInfo(int tab, StringBuffer buffer, Object info, boolean showResolvedInfo) { > buffer.append(this.tabString(tab)); > IPath path = getPath(); >- if (getJavaProject().getElementName().equals(path.segment(0))) { >+ if (isExternal()) { >+ buffer.append(path.toOSString()); >+ } else if (getJavaProject().getElementName().equals(path.segment(0))) { > if (path.segmentCount() == 1) { > buffer.append("<project root>"); //$NON-NLS-1$ > } else { > buffer.append(path.removeFirstSegments(1).makeRelative()); > } > } else { >- if (isExternal()) { >- buffer.append(path.toOSString()); >- } else { >- buffer.append(path); >- } >+ buffer.append(path); > } > if (info == null) { > buffer.append(" (not open)"); //$NON-NLS-1$ >Index: model/org/eclipse/jdt/internal/core/JavaProjectElementInfo.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProjectElementInfo.java,v >retrieving revision 1.52 >diff -u -r1.52 JavaProjectElementInfo.java >--- model/org/eclipse/jdt/internal/core/JavaProjectElementInfo.java 26 Feb 2008 10:11:46 -0000 1.52 >+++ model/org/eclipse/jdt/internal/core/JavaProjectElementInfo.java 18 Apr 2008 14:35:44 -0000 >@@ -134,7 +134,7 @@ > String resName = res.getName(); > > // ignore a jar file on the classpath >- if (isClasspathResolved && org.eclipse.jdt.internal.compiler.util.Util.isArchiveFileName(resName) && this.isClasspathEntryOrOutputLocation(resFullPath, classpath, projectOutput)) { >+ if (isClasspathResolved && isClasspathEntryOrOutputLocation(resFullPath, classpath, projectOutput)) { > break; > } > // ignore .java file if src == project >Index: model/org/eclipse/jdt/internal/core/JavaProject.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java,v >retrieving revision 1.398 >diff -u -r1.398 JavaProject.java >--- model/org/eclipse/jdt/internal/core/JavaProject.java 17 Mar 2008 07:57:16 -0000 1.398 >+++ model/org/eclipse/jdt/internal/core/JavaProject.java 18 Apr 2008 14:35:44 -0000 >@@ -479,7 +479,6 @@ > * @param accumulatedRoots ObjectVector > * @param rootIDs HashSet > * @param referringEntry the CP entry (project) referring to this entry, or null if initial project >- * @param checkExistency boolean > * @param retrieveExportedRoots boolean > * @throws JavaModelException > */ >@@ -488,7 +487,6 @@ > ObjectVector accumulatedRoots, > HashSet rootIDs, > IClasspathEntry referringEntry, >- boolean checkExistency, > boolean retrieveExportedRoots, > Map rootToResolvedEntries) throws JavaModelException { > >@@ -506,41 +504,33 @@ > case IClasspathEntry.CPE_SOURCE : > > if (projectPath.isPrefixOf(entryPath)){ >- if (checkExistency) { >- Object target = JavaModel.getTarget(entryPath, checkExistency); >- if (target == null) return; >- >- if (target instanceof IFolder || target instanceof IProject){ >- root = getPackageFragmentRoot((IResource)target); >- } >- } else { >- root = getFolderPackageFragmentRoot(entryPath); >+ Object target = JavaModel.getTarget(entryPath, true/*check existency*/); >+ if (target == null) return; >+ >+ if (target instanceof IFolder || target instanceof IProject){ >+ root = getPackageFragmentRoot((IResource)target); > } > } > break; > > // internal/external JAR or folder > case IClasspathEntry.CPE_LIBRARY : >- >- if (referringEntry != null && !resolvedEntry.isExported()) return; >- >- if (checkExistency) { >- Object target = JavaModel.getTarget(entryPath, checkExistency); >- if (target == null) return; >- >- if (target instanceof IResource){ >- // internal target >- root = getPackageFragmentRoot((IResource) target, entryPath); >- } else if (target instanceof File) { >- // external target >- if (JavaModel.isFile(target) && (org.eclipse.jdt.internal.compiler.util.Util.isArchiveFileName(entryPath.lastSegment()))) { >- root = new JarPackageFragmentRoot(entryPath, this); >- } else if (((File) target).isDirectory()) { >- root = new ExternalPackageFragmentRoot(entryPath, this); >- } >+ if (referringEntry != null && !resolvedEntry.isExported()) >+ return; >+ Object target = JavaModel.getTarget(entryPath, true/*check existency*/); >+ if (target == null) >+ return; >+ >+ if (target instanceof IResource){ >+ // internal target >+ root = getPackageFragmentRoot((IResource) target, entryPath); >+ } else if (target instanceof File) { >+ // external target >+ if (JavaModel.isFile(target)) { >+ root = new JarPackageFragmentRoot(entryPath, this); >+ } else if (((File) target).isDirectory()) { >+ root = new ExternalPackageFragmentRoot(entryPath, this); > } >- } else { >- root = getPackageFragmentRoot(entryPath); > } > break; > >@@ -561,7 +551,6 @@ > accumulatedRoots, > rootIDs, > rootToResolvedEntries == null ? resolvedEntry : ((ClasspathEntry)resolvedEntry).combineWith((ClasspathEntry) referringEntry), // only combine if need to build the reverse map >- checkExistency, > retrieveExportedRoots, > rootToResolvedEntries); > } >@@ -596,7 +585,6 @@ > accumulatedRoots, > new HashSet(5), // rootIDs > null, // inside original project >- true, // check existency > retrieveExportedRoots, > rootToResolvedEntries); > IPackageFragmentRoot[] rootArray = new IPackageFragmentRoot[accumulatedRoots.size()]; >@@ -613,7 +601,6 @@ > * @param accumulatedRoots ObjectVector > * @param rootIDs HashSet > * @param referringEntry project entry referring to this CP or null if initial project >- * @param checkExistency boolean > * @param retrieveExportedRoots boolean > * @throws JavaModelException > */ >@@ -622,7 +609,6 @@ > ObjectVector accumulatedRoots, > HashSet rootIDs, > IClasspathEntry referringEntry, >- boolean checkExistency, > boolean retrieveExportedRoots, > Map rootToResolvedEntries) throws JavaModelException { > >@@ -635,7 +621,6 @@ > accumulatedRoots, > rootIDs, > referringEntry, >- checkExistency, > retrieveExportedRoots, > rootToResolvedEntries); > } >@@ -1622,31 +1607,36 @@ > path = getPath().append(path); > } > int segmentCount = path.segmentCount(); >- switch (segmentCount) { >- case 0: >- return null; >- case 1: >- if (path.equals(getPath())) { // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=75814 >- // default root >- return getPackageFragmentRoot(this.project); >- } >- default: >- // a path ending with .jar/.zip is still ambiguous and could still resolve to a source/lib folder >- // thus will try to guess based on existing resource >- if (org.eclipse.jdt.internal.compiler.util.Util.isArchiveFileName(path.lastSegment())) { >- IResource resource = this.project.getWorkspace().getRoot().findMember(path); >- if (resource != null && resource.getType() == IResource.FOLDER){ >- return getPackageFragmentRoot(resource); >- } >- return getPackageFragmentRoot0(path); >- } else if (segmentCount == 1) { >- // lib being another project >- return getPackageFragmentRoot(this.project.getWorkspace().getRoot().getProject(path.lastSegment())); >- } else { >- // lib being a folder >- return getPackageFragmentRoot(this.project.getWorkspace().getRoot().getFolder(path)); >- } >+ if (segmentCount == 0) { >+ return null; >+ } >+ if (path.getDevice() != null || JavaModel.getExternalTarget(path, true/*check existence*/) != null) { >+ // external path >+ return getPackageFragmentRoot0(path); >+ } >+ IWorkspaceRoot workspaceRoot = this.project.getWorkspace().getRoot(); >+ if (segmentCount == 1) { >+ String projectName = path.segment(0); >+ if (getElementName().equals(projectName)) { // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=75814 >+ // default root >+ return getPackageFragmentRoot(this.project); >+ } else { >+ // lib being another project >+ return getPackageFragmentRoot(workspaceRoot.getProject(projectName)); >+ } >+ } >+ IResource resource = workspaceRoot.findMember(path); >+ if (resource == null) { >+ // resource doesn't exist in workspace >+ if (path.getFileExtension() != null) { >+ // assume it is a file >+ resource = workspaceRoot.getFile(path); >+ } else { >+ // assume it is a folder >+ resource = workspaceRoot.getFolder(path); >+ } > } >+ return getPackageFragmentRoot(resource); > } > > /** >@@ -1659,11 +1649,7 @@ > private IPackageFragmentRoot getPackageFragmentRoot(IResource resource, IPath entryPath) { > switch (resource.getType()) { > case IResource.FILE: >- if (org.eclipse.jdt.internal.compiler.util.Util.isArchiveFileName(resource.getName())) { >- return new JarPackageFragmentRoot(resource, this); >- } else { >- return null; >- } >+ return new JarPackageFragmentRoot(resource, this); > case IResource.FOLDER: > if (ExternalFoldersManager.isInternalPathForExternalFolder(resource.getFullPath())) > return new ExternalPackageFragmentRoot(resource, entryPath, this); >@@ -1679,7 +1665,6 @@ > * @see IJavaProject > */ > public IPackageFragmentRoot getPackageFragmentRoot(String libraryPath) { >- > return getPackageFragmentRoot0(JavaProject.canonicalizedPath(new Path(libraryPath))); > } > >@@ -1687,10 +1672,10 @@ > * no path canonicalization > */ > public IPackageFragmentRoot getPackageFragmentRoot0(IPath libraryPath) { >- if (!org.eclipse.jdt.internal.compiler.util.Util.isArchiveFileName(libraryPath.lastSegment())) >- return new ExternalPackageFragmentRoot(libraryPath, this); >+ IFolder linkedFolder = JavaModelManager.getExternalManager().getFolder(libraryPath); >+ if (linkedFolder != null) >+ return new ExternalPackageFragmentRoot(linkedFolder, libraryPath, this); > return new JarPackageFragmentRoot(libraryPath, this); >- > } > > /** >Index: model/org/eclipse/jdt/internal/core/ClasspathEntry.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathEntry.java,v >retrieving revision 1.99 >diff -u -r1.99 ClasspathEntry.java >--- model/org/eclipse/jdt/internal/core/ClasspathEntry.java 26 Feb 2008 10:11:46 -0000 1.99 >+++ model/org/eclipse/jdt/internal/core/ClasspathEntry.java 18 Apr 2008 14:35:42 -0000 >@@ -19,6 +19,7 @@ > import java.util.HashSet; > import java.util.Map; > >+import org.eclipse.core.resources.IContainer; > import org.eclipse.core.resources.IProject; > import org.eclipse.core.resources.IResource; > import org.eclipse.core.resources.IWorkspaceRoot; >@@ -1375,7 +1376,8 @@ > break; > > case IClasspathEntry.CPE_LIBRARY: >- hasLibFolder |= !org.eclipse.jdt.internal.compiler.util.Util.isArchiveFileName(path.lastSegment()); >+ Object target = JavaModel.getTarget(path, false/*don't check resource existence*/); >+ hasLibFolder |= target instanceof IContainer; > if ((index = Util.indexOfMatchingPath(path, outputLocations, outputCount)) != -1){ > allowNestingInOutputLocations[index] = true; > } >@@ -1415,7 +1417,7 @@ > > // allow nesting source entries in each other as long as the outer entry excludes the inner one > if (kind == IClasspathEntry.CPE_SOURCE >- || (kind == IClasspathEntry.CPE_LIBRARY && !org.eclipse.jdt.internal.compiler.util.Util.isArchiveFileName(entryPath.lastSegment()))){ >+ || (kind == IClasspathEntry.CPE_LIBRARY && (JavaModel.getTarget(entryPath, false/*don't check existence*/) instanceof IContainer))) { > for (int j = 0; j < classpath.length; j++){ > IClasspathEntry otherEntry = classpath[j]; > if (otherEntry == null) continue; >@@ -1424,7 +1426,7 @@ > if (entry != otherEntry > && (otherKind == IClasspathEntry.CPE_SOURCE > || (otherKind == IClasspathEntry.CPE_LIBRARY >- && !org.eclipse.jdt.internal.compiler.util.Util.isArchiveFileName(otherPath.lastSegment())))){ >+ && (JavaModel.getTarget(otherPath, false/*don't check existence*/) instanceof IContainer)))) { > char[][] inclusionPatterns, exclusionPatterns; > if (otherPath.isPrefixOf(entryPath) > && !otherPath.equals(entryPath) >@@ -1636,15 +1638,11 @@ > IResource resolvedResource = (IResource) target; > switch(resolvedResource.getType()){ > case IResource.FILE : >- if (org.eclipse.jdt.internal.compiler.util.Util.isArchiveFileName(resolvedResource.getName())) { >- if (checkSourceAttachment >- && sourceAttachment != null >- && !sourceAttachment.isEmpty() >- && JavaModel.getTarget(sourceAttachment, true) == null){ >- return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundSourceAttachment, new String [] {sourceAttachment.toString(), path.toString(), projectName})); >- } >- } else { >- return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_illegalLibraryArchive, new String[] {entryPathMsg, projectName})); >+ if (checkSourceAttachment >+ && sourceAttachment != null >+ && !sourceAttachment.isEmpty() >+ && JavaModel.getTarget(sourceAttachment, true) == null){ >+ return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundSourceAttachment, new String [] {sourceAttachment.toString(), path.toString(), projectName})); > } > break; > case IResource.FOLDER : // internal binary folder >@@ -1659,8 +1657,6 @@ > File file = JavaModel.getFile(target); > if (file == null) { > return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_illegalExternalFolder, new String[] {path.toOSString(), projectName})); >- } else if (!org.eclipse.jdt.internal.compiler.util.Util.isArchiveFileName(file.getName())) { >- return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_illegalLibraryArchive, (new String[] {path.toOSString(), projectName}))); > } else if (checkSourceAttachment > && sourceAttachment != null > && !sourceAttachment.isEmpty() >Index: model/org/eclipse/jdt/internal/core/JarPackageFragmentRoot.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JarPackageFragmentRoot.java,v >retrieving revision 1.69 >diff -u -r1.69 JarPackageFragmentRoot.java >--- model/org/eclipse/jdt/internal/core/JarPackageFragmentRoot.java 2 Apr 2008 14:26:20 -0000 1.69 >+++ model/org/eclipse/jdt/internal/core/JarPackageFragmentRoot.java 18 Apr 2008 14:35:43 -0000 >@@ -12,6 +12,7 @@ > > import java.util.*; > import java.util.zip.ZipEntry; >+import java.util.zip.ZipException; > import java.util.zip.ZipFile; > > import org.eclipse.core.resources.IResource; >@@ -71,19 +72,20 @@ > IJavaElement[] children; > ZipFile jar = null; > try { >- // always create the default package >- rawPackageInfo.put(CharOperation.NO_STRINGS, new ArrayList[] { EMPTY_LIST, EMPTY_LIST }); >- > IJavaProject project = getJavaProject(); > String sourceLevel = project.getOption(JavaCore.COMPILER_SOURCE, true); > String compliance = project.getOption(JavaCore.COMPILER_COMPLIANCE, true); > jar = getJar(); >+ >+ // always create the default package >+ rawPackageInfo.put(CharOperation.NO_STRINGS, new ArrayList[] { EMPTY_LIST, EMPTY_LIST }); >+ > for (Enumeration e= jar.entries(); e.hasMoreElements();) { > ZipEntry member= (ZipEntry) e.nextElement(); > initRawPackageInfo(rawPackageInfo, member.getName(), member.isDirectory(), sourceLevel, compliance); > } > >- //l oop through all of referenced packages, creating package fragments if necessary >+ // loop through all of referenced packages, creating package fragments if necessary > // and cache the entry names in the rawPackageInfo table > children = new IJavaElement[rawPackageInfo.size()]; > int index = 0; >@@ -93,8 +95,15 @@ > children[index++] = getPackageFragment(pkgName); > } > } catch (CoreException e) { >- if (e instanceof JavaModelException) throw (JavaModelException)e; >- throw new JavaModelException(e); >+ if (e.getCause() instanceof ZipException) { >+ // not a ZIP archive, leave the children empty >+ Util.log(e, "Invalid ZIP archive: " + toStringWithAncestors()); //$NON-NLS-1$ >+ children = NO_ELEMENTS; >+ } else if (e instanceof JavaModelException) { >+ throw (JavaModelException)e; >+ } else { >+ throw new JavaModelException(e); >+ } > } finally { > JavaModelManager.getJavaModelManager().closeZipFile(jar); > } >@@ -178,15 +187,11 @@ > } > } > public IResource resource(PackageFragmentRoot root) { >- if (this.resource == null && org.eclipse.jdt.internal.compiler.util.Util.isArchiveFileName(this.jarPath.lastSegment())) { >- this.resource = JavaModel.getTarget(this.jarPath, false); >- } >- if (this.resource instanceof IResource) { >- return super.resource(root); >- } else { >+ if (this.resource == null) { > // external jar > return null; > } >+ return super.resource(root); > } > > >@@ -266,23 +271,24 @@ > } > > /** >- * Returns whether the corresponding resource or associated file exists >- */ >-protected boolean resourceExists(IResource underlyingResource) { >- if (underlyingResource == null) { >- return >- JavaModel.getTarget( >- getPath(), // don't make the path relative as this is an external archive >- true) != null; >- } else { >- return super.resourceExists(underlyingResource); >+ * Returns whether the corresponding resource or associated file exists >+ */ >+ protected boolean resourceExists(IResource underlyingResource) { >+ if (underlyingResource == null) { >+ return >+ JavaModel.getExternalTarget( >+ getPath()/*don't make the path relative as this is an external archive*/, >+ true/*check existence*/) != null; >+ } else { >+ return super.resourceExists(underlyingResource); >+ } >+ } >+ >+ protected void toStringAncestors(StringBuffer buffer) { >+ if (isExternal()) >+ // don't show project as it is irrelevant for external jar files. >+ // also see https://bugs.eclipse.org/bugs/show_bug.cgi?id=146615 >+ return; >+ super.toStringAncestors(buffer); > } >-} >-protected void toStringAncestors(StringBuffer buffer) { >- if (isExternal()) >- // don't show project as it is irrelevant for external jar files. >- // also see https://bugs.eclipse.org/bugs/show_bug.cgi?id=146615 >- return; >- super.toStringAncestors(buffer); >-} > } >Index: model/org/eclipse/jdt/internal/core/JavaModelManager.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java,v >retrieving revision 1.389 >diff -u -r1.389 JavaModelManager.java >--- model/org/eclipse/jdt/internal/core/JavaModelManager.java 7 Apr 2008 09:37:57 -0000 1.389 >+++ model/org/eclipse/jdt/internal/core/JavaModelManager.java 18 Apr 2008 14:35:43 -0000 >@@ -720,7 +720,7 @@ > * <li>a project - the element returned is the corresponding <code>IJavaProject</code></li> > * <li>a <code>.java</code> file - the element returned is the corresponding <code>ICompilationUnit</code></li> > * <li>a <code>.class</code> file - the element returned is the corresponding <code>IClassFile</code></li> >- * <li>a <code>.jar</code> file - the element returned is the corresponding <code>IPackageFragmentRoot</code></li> >+ * <li>a ZIP archive (e.g. a <code>.jar</code>, a <code>.zip</code> file, etc.) - the element returned is the corresponding <code>IPackageFragmentRoot</code></li> > * <li>a folder - the element returned is the corresponding <code>IPackageFragmentRoot</code> > * or <code>IPackageFragment</code></li> > * <li>the workspace root resource - the element returned is the <code>IJavaModel</code></li> >@@ -757,7 +757,7 @@ > * <p>The file must be one of:<ul> > * <li>a <code>.java</code> file - the element returned is the corresponding <code>ICompilationUnit</code></li> > * <li>a <code>.class</code> file - the element returned is the corresponding <code>IClassFile</code></li> >- * <li>a <code>.jar</code> file - the element returned is the corresponding <code>IPackageFragmentRoot</code></li> >+ * <li>a ZIP archive (e.g. a <code>.jar</code>, a <code>.zip</code> file, etc.) - the element returned is the corresponding <code>IPackageFragmentRoot</code></li> > * </ul> > * <p> > * Creating a Java element has the side effect of creating and opening all of the >@@ -777,8 +777,7 @@ > return createCompilationUnitFrom(file, project); > if (org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(name)) > return createClassFileFrom(file, project); >- if (org.eclipse.jdt.internal.compiler.util.Util.isArchiveFileName(name)) >- return createJarPackageFragmentRootFrom(file, project); >+ return createJarPackageFragmentRootFrom(file, project); > } > return null; > } >Index: model/org/eclipse/jdt/internal/core/PackageFragmentRootInfo.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRootInfo.java,v >retrieving revision 1.41 >diff -u -r1.41 PackageFragmentRootInfo.java >--- model/org/eclipse/jdt/internal/core/PackageFragmentRootInfo.java 6 Mar 2008 14:24:01 -0000 1.41 >+++ model/org/eclipse/jdt/internal/core/PackageFragmentRootInfo.java 18 Apr 2008 14:35:44 -0000 >@@ -77,7 +77,7 @@ > if (Util.isValidClassFileName(fileName, sourceLevel, complianceLevel)) > continue nextResource; > // ignore .zip or .jar file on classpath >- if (org.eclipse.jdt.internal.compiler.util.Util.isArchiveFileName(fileName) && isClasspathEntry(member.getFullPath(), classpath)) >+ if (isClasspathEntry(member.getFullPath(), classpath)) > continue nextResource; > break; > >Index: model/org/eclipse/jdt/internal/core/ClasspathChange.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathChange.java,v >retrieving revision 1.12 >diff -u -r1.12 ClasspathChange.java >--- model/org/eclipse/jdt/internal/core/ClasspathChange.java 26 Feb 2008 10:11:46 -0000 1.12 >+++ model/org/eclipse/jdt/internal/core/ClasspathChange.java 18 Apr 2008 14:35:42 -0000 >@@ -324,7 +324,6 @@ > accumulatedRoots, > rootIDs, > null, // inside original project >- true, // check existency > false, // don't retrieve exported roots > null); /*no reverse map*/ > pkgFragmentRoots = new PackageFragmentRoot[accumulatedRoots.size()]; >Index: batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java,v >retrieving revision 1.50 >diff -u -r1.50 FileSystem.java >--- batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java 20 Mar 2008 08:57:49 -0000 1.50 >+++ batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java 18 Apr 2008 14:35:40 -0000 >@@ -164,9 +164,7 @@ > convertPathSeparators(destinationPath)); > } > } else { >- String lowercaseClasspathName = classpathName.toLowerCase(); >- if (lowercaseClasspathName.endsWith(SUFFIX_STRING_jar) >- || lowercaseClasspathName.endsWith(SUFFIX_STRING_zip)) { >+ if (Util.isPotentialZipArchive(classpathName)) { > if (isSourceOnly) { > // source only mode > result = new ClasspathSourceJar(file, true, accessRuleSet, >Index: batch/org/eclipse/jdt/internal/compiler/batch/Main.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java,v >retrieving revision 1.325 >diff -u -r1.325 Main.java >--- batch/org/eclipse/jdt/internal/compiler/batch/Main.java 14 Apr 2008 19:41:33 -0000 1.325 >+++ batch/org/eclipse/jdt/internal/compiler/batch/Main.java 18 Apr 2008 14:35:41 -0000 >@@ -472,7 +472,7 @@ > File f = new File(classpath); > String id = null; > if (f.isFile()) { >- if (Util.isArchiveFileName(classpath)) { >+ if (Util.isPotentialZipArchive(classpath)) { > id = Logger.CLASSPATH_JAR; > } else { > id = Logger.CLASSPATH_FILE; >@@ -1333,11 +1333,7 @@ > public static File[][] getLibrariesFiles(File[] files) { > FilenameFilter filter = new FilenameFilter() { > public boolean accept(File dir, String name) { >- String lowerCaseName = name.toLowerCase(); >- if (lowerCaseName.endsWith(SuffixConstants.SUFFIX_STRING_jar) || lowerCaseName.endsWith(SuffixConstants.SUFFIX_STRING_zip)) { >- return true; >- } >- return false; >+ return Util.isPotentialZipArchive(name); > } > }; > final int filesLength = files.length; >@@ -1494,8 +1490,7 @@ > destPath = NONE; // keep == comparison valid > } > if (rejectDestinationPathOnJars && destPath != null && >- (currentClasspathName.endsWith(".jar") || //$NON-NLS-1$ >- currentClasspathName.endsWith(".zip"))) { //$NON-NLS-1$ >+ Util.isPotentialZipArchive(currentClasspathName)) { > throw new InvalidInputException( > this.bind("configure.unexpectedDestinationPathEntryFile", //$NON-NLS-1$ > currentClasspathName)); >Index: batch/org/eclipse/jdt/internal/compiler/batch/messages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties,v >retrieving revision 1.719 >diff -u -r1.719 messages.properties >--- batch/org/eclipse/jdt/internal/compiler/batch/messages.properties 15 Apr 2008 17:59:53 -0000 1.719 >+++ batch/org/eclipse/jdt/internal/compiler/batch/messages.properties 18 Apr 2008 14:35:41 -0000 >@@ -115,18 +115,18 @@ > \ with ''+''.\n\ > \ \n\ > \ Classpath options:\n\ >-\ -cp -classpath <directories and zip/jar files separated by {0}>\n\ >+\ -cp -classpath <directories and ZIP archives separated by {0}>\n\ > \ specify location for application classes and sources.\n\ > \ Each directory or file can specify access rules for\n\ > \ types between ''['' and '']'' (e.g. [-X] to forbid\n\ > \ access to type X, [~X] to discourage access to type X,\n\ > \ [+p/X{0}-p/*] to forbid access to all types in package p\n\ > \ but allow access to p/X)\n\ >-\ -bootclasspath <directories and zip/jar files separated by {0}>\n\ >+\ -bootclasspath <directories and ZIP archives separated by {0}>\n\ > \ specify location for system classes. Each directory or\n\ > \ file can specify access rules for types between ''[''\n\ > \ and '']''\n\ >-\ -sourcepath <directories and zip/jar files separated by {0}>\n\ >+\ -sourcepath <directories and ZIP archives separated by {0}>\n\ > \ specify location for application sources. Each directory\n\ > \ or file can specify access rules for types between ''[''\n\ > \ and '']''. Each directory can further specify a specific\n\ >@@ -134,12 +134,12 @@ > \ and '']''; this overrides the general ''-d'' option.\n\ > \ .class files created from source files contained in a\n\ > \ jar file are put in the user.dir folder in case no\n\ >-\ general ''-d'' option is specified. zip/jar files cannot\n\ >+\ general ''-d'' option is specified. ZIP archives cannot\n\ > \ override the general ''-d'' option\n\ > \ -extdirs <directories separated by {0}>\n\ >-\ specify location for extension zip/jar files\n\ >+\ specify location for extension ZIP archives\n\ > \ -endorseddirs <directories separated by {0}>\n\ >-\ specify location for endorsed zip/jar files\n\ >+\ specify location for endorsed ZIP archives\n\ > \ -d <dir> destination directory (if omitted, no directory is\n\ > \ created); this option can be overridden per source\n\ > \ directory\n\ >@@ -175,7 +175,7 @@ > \ Annotation processing options:\n\ > \ These options are meaningful only in a 1.6 environment.\n\ > \ -Akey[=value] options that are passed to annotation processors\n\ >-\ -processorpath <directories and zip/jar files separated by {0}>\n\ >+\ -processorpath <directories and ZIP archives separated by {0}>\n\ > \ specify locations where to find annotation processors.\n\ > \ If this option is not used, the classpath will be\n\ > \ searched for processors\n\ >Index: compiler/org/eclipse/jdt/internal/compiler/util/SuffixConstants.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/SuffixConstants.java,v >retrieving revision 1.6 >diff -u -r1.6 SuffixConstants.java >--- compiler/org/eclipse/jdt/internal/compiler/util/SuffixConstants.java 10 May 2006 18:03:51 -0000 1.6 >+++ compiler/org/eclipse/jdt/internal/compiler/util/SuffixConstants.java 18 Apr 2008 14:35:41 -0000 >@@ -25,19 +25,4 @@ > public final static char[] SUFFIX_CLASS = SUFFIX_STRING_CLASS.toCharArray(); > public final static char[] SUFFIX_java = SUFFIX_STRING_java.toCharArray(); > public final static char[] SUFFIX_JAVA = SUFFIX_STRING_JAVA.toCharArray(); >- >- public final static String EXTENSION_jar = "jar"; //$NON-NLS-1$ >- public final static String EXTENSION_JAR = "JAR"; //$NON-NLS-1$ >- public final static String EXTENSION_zip = "zip"; //$NON-NLS-1$ >- public final static String EXTENSION_ZIP = "ZIP"; //$NON-NLS-1$ >- >- public final static String SUFFIX_STRING_jar = "." + EXTENSION_jar; //$NON-NLS-1$ >- public final static String SUFFIX_STRING_JAR = "." + EXTENSION_JAR; //$NON-NLS-1$ >- public final static String SUFFIX_STRING_zip = "." + EXTENSION_zip; //$NON-NLS-1$ >- public final static String SUFFIX_STRING_ZIP = "." + EXTENSION_ZIP; //$NON-NLS-1$ >- >- public final static char[] SUFFIX_jar = SUFFIX_STRING_jar.toCharArray(); >- public final static char[] SUFFIX_JAR = SUFFIX_STRING_JAR.toCharArray(); >- public final static char[] SUFFIX_zip = SUFFIX_STRING_zip.toCharArray(); >- public final static char[] SUFFIX_ZIP = SUFFIX_STRING_ZIP.toCharArray(); > } >Index: compiler/org/eclipse/jdt/internal/compiler/util/Util.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/Util.java,v >retrieving revision 1.65 >diff -u -r1.65 Util.java >--- compiler/org/eclipse/jdt/internal/compiler/util/Util.java 7 Mar 2008 16:09:59 -0000 1.65 >+++ compiler/org/eclipse/jdt/internal/compiler/util/Util.java 18 Apr 2008 14:35:41 -0000 >@@ -470,34 +470,40 @@ > } > } > } >+ > /** >- * Returns true iff str.toLowerCase().endsWith(".jar") || str.toLowerCase().endsWith(".zip") >- * implementation is not creating extra strings. >+ * Returns whether the given name is potentially a zip archive file name >+ * (it has a file extension and it is not ".java" nor ".class") > */ >- public final static boolean isArchiveFileName(String name) { >- int nameLength = name == null ? 0 : name.length(); >- int suffixLength = SUFFIX_JAR.length; >- if (nameLength < suffixLength) return false; >- >- // try to match as JAR file >- for (int i = 0; i < suffixLength; i++) { >- char c = name.charAt(nameLength - i - 1); >- int suffixIndex = suffixLength - i - 1; >- if (c != SUFFIX_jar[suffixIndex] && c != SUFFIX_JAR[suffixIndex]) { >- >- // try to match as ZIP file >- suffixLength = SUFFIX_ZIP.length; >- if (nameLength < suffixLength) return false; >- for (int j = 0; j < suffixLength; j++) { >- c = name.charAt(nameLength - j - 1); >- suffixIndex = suffixLength - j - 1; >- if (c != SUFFIX_zip[suffixIndex] && c != SUFFIX_ZIP[suffixIndex]) return false; >+ public final static boolean isPotentialZipArchive(String name) { >+ int lastDot = name.lastIndexOf('.'); >+ if (lastDot == -1) >+ return false; // no file extension, it cannot be a zip archive name >+ if (name.lastIndexOf(File.separatorChar) > lastDot) >+ return false; // dot was before the last file separator, it cannot be a zip archive name >+ int length = name.length(); >+ int extensionLength = length - lastDot - 1; >+ if (extensionLength == EXTENSION_java.length()) { >+ for (int i = extensionLength-1; i >=0; i--) { >+ if (Character.toLowerCase(name.charAt(length - extensionLength + i)) != EXTENSION_java.charAt(i)) { >+ break; // not a ".java" file, check ".class" file case below >+ } >+ if (i == 0) { >+ return false; // it is a ".java" file, it cannot be a zip archive name > } >- return true; > } > } >- return true; >- } >+ if (extensionLength == EXTENSION_class.length()) { >+ for (int i = extensionLength-1; i >=0; i--) { >+ if (Character.toLowerCase(name.charAt(length - extensionLength + i)) != EXTENSION_class.charAt(i)) { >+ return true; // not a ".class" file, so this is a potential archive name >+ } >+ } >+ return false; // it is a ".class" file, it cannot be a zip archive name >+ } >+ return true; // it is neither a ".java" file nor a ".class" file, so this is a potential archive name >+ } >+ > /** > * Returns true iff str.toLowerCase().endsWith(".class") > * implementation is not creating extra strings. >Index: antadapter/org/eclipse/jdt/core/CheckDebugAttributes.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/antadapter/org/eclipse/jdt/core/CheckDebugAttributes.java,v >retrieving revision 1.9 >diff -u -r1.9 CheckDebugAttributes.java >--- antadapter/org/eclipse/jdt/core/CheckDebugAttributes.java 10 May 2006 18:03:50 -0000 1.9 >+++ antadapter/org/eclipse/jdt/core/CheckDebugAttributes.java 18 Apr 2008 14:35:40 -0000 >@@ -13,6 +13,7 @@ > import java.io.IOException; > import java.util.Enumeration; > import java.util.zip.ZipEntry; >+import java.util.zip.ZipException; > import java.util.zip.ZipFile; > > import org.apache.tools.ant.BuildException; >@@ -50,8 +51,16 @@ > } > try { > boolean hasDebugAttributes = false; >- if (org.eclipse.jdt.internal.compiler.util.Util.isArchiveFileName(this.file)) { >- ZipFile jarFile = new ZipFile(this.file); >+ if (org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(this.file)) { >+ IClassFileReader classFileReader = ToolFactory.createDefaultClassFileReader(this.file, IClassFileReader.ALL); >+ hasDebugAttributes = checkClassFile(classFileReader); >+ } else { >+ ZipFile jarFile = null; >+ try { >+ jarFile = new ZipFile(this.file); >+ } catch (ZipException e) { >+ throw new BuildException(AntAdapterMessages.getString("checkDebugAttributes.file.argument.must.be.a.classfile.or.a.jarfile")); //$NON-NLS-1$ >+ } > for (Enumeration entries = jarFile.entries(); !hasDebugAttributes && entries.hasMoreElements(); ) { > ZipEntry entry = (ZipEntry) entries.nextElement(); > if (org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(entry.getName())) { >@@ -59,11 +68,6 @@ > hasDebugAttributes = checkClassFile(classFileReader); > } > } >- } else if (org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(this.file)) { >- IClassFileReader classFileReader = ToolFactory.createDefaultClassFileReader(this.file, IClassFileReader.ALL); >- hasDebugAttributes = checkClassFile(classFileReader); >- } else { >- throw new BuildException(AntAdapterMessages.getString("checkDebugAttributes.file.argument.must.be.a.classfile.or.a.jarfile")); //$NON-NLS-1$ > } > if (hasDebugAttributes) { > getProject().setUserProperty(this.property, "has debug"); //$NON-NLS-1$ >Index: model/org/eclipse/jdt/internal/core/builder/NameEnvironment.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/NameEnvironment.java,v >retrieving revision 1.61 >diff -u -r1.61 NameEnvironment.java >--- model/org/eclipse/jdt/internal/core/builder/NameEnvironment.java 26 Feb 2008 10:11:47 -0000 1.61 >+++ model/org/eclipse/jdt/internal/core/builder/NameEnvironment.java 18 Apr 2008 14:35:44 -0000 >@@ -161,8 +161,6 @@ > IResource resource = (IResource) target; > ClasspathLocation bLocation = null; > if (resource instanceof IFile) { >- if (!(org.eclipse.jdt.internal.compiler.util.Util.isArchiveFileName(path.lastSegment()))) >- continue nextEntry; > AccessRuleSet accessRuleSet = > (JavaCore.IGNORE.equals(javaProject.getOption(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE, true)) > && JavaCore.IGNORE.equals(javaProject.getOption(JavaCore.COMPILER_PB_DISCOURAGED_REFERENCE, true))) >@@ -191,8 +189,6 @@ > binaryLocationsPerProject.put(p, existingLocations); > } > } else if (target instanceof File) { >- if (!(org.eclipse.jdt.internal.compiler.util.Util.isArchiveFileName(path.lastSegment()))) >- continue nextEntry; > AccessRuleSet accessRuleSet = > (JavaCore.IGNORE.equals(javaProject.getOption(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE, true)) > && JavaCore.IGNORE.equals(javaProject.getOption(JavaCore.COMPILER_PB_DISCOURAGED_REFERENCE, true))) >#P org.eclipse.jdt.core.tests >Index: Eclipse Java Tests Model/src/org/eclipse/jdt/tests/core/JarTests.java >=================================================================== >RCS file: /home/cvs/numbat/org.eclipse.jdt.core.tests/Eclipse Java Tests Model/src/org/eclipse/jdt/tests/core/JarTests.java,v >retrieving revision 1.23 >diff -u -r1.23 JarTests.java >--- Eclipse Java Tests Model/src/org/eclipse/jdt/tests/core/JarTests.java 21 Sep 2007 13:16:34 -0000 1.23 >+++ Eclipse Java Tests Model/src/org/eclipse/jdt/tests/core/JarTests.java 18 Apr 2008 14:35:47 -0000 >@@ -362,7 +362,7 @@ > > > IPackageFragmentRoot wrongRoot = jProject1.getPackageFragmentRoot(jarPath); >- IPackageFragmentRoot rightRoot = jProject2.getPackageFragmentRoot(jarPath); >+ IPackageFragmentRoot rightRoot = jProject2.getPackageFragmentRoot(workspaceRoot.getFile(new Path(jarPath))); > > assertTrue("Wrong PackageFragmentRoot exists", !wrongRoot.exists()); > assertTrue("Right PackageFragmentRoot does not exists", rightRoot.exists()); >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/model/ClasspathInitializerTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClasspathInitializerTests.java,v >retrieving revision 1.56 >diff -u -r1.56 ClasspathInitializerTests.java >--- src/org/eclipse/jdt/core/tests/model/ClasspathInitializerTests.java 26 Feb 2008 10:11:57 -0000 1.56 >+++ src/org/eclipse/jdt/core/tests/model/ClasspathInitializerTests.java 18 Apr 2008 14:35:47 -0000 >@@ -490,7 +490,7 @@ > ContainerInitializer.setInitializer(new DefaultContainerInitializer(new String[] {"P3", "/P1"}) { > public void initialize(IPath containerPath, IJavaProject project) throws CoreException { > super.initialize(containerPath, project); >- getJavaModel().refreshExternalArchives(new IJavaElement[] {p1}, null); >+ refreshExternalArchives(p1); > } > }); > getWorkspace().run(new IWorkspaceRunnable() { >@@ -894,17 +894,57 @@ > try { > createProject("P1"); > createExternalFolder("externalLib"); >- ContainerInitializer.setInitializer(new DefaultContainerInitializer(new String[] {"P2", getExternalFolderPath("externalLib")})); >+ ContainerInitializer.setInitializer(new DefaultContainerInitializer(new String[] {"P2", getExternalResourcePath("externalLib")})); > IJavaProject p2 = createJavaProject( > "P2", > new String[] {}, > new String[] {"org.eclipse.jdt.core.tests.model.TEST_CONTAINER"}, > ""); >- IPackageFragmentRoot root = p2.getPackageFragmentRoot(getExternalFolderPath("externalLib")); >- assertTrue(getExternalFolderPath("externalLib") + " should exist", root.exists()); >+ IPackageFragmentRoot root = p2.getPackageFragmentRoot(getExternalResourcePath("externalLib")); >+ assertTrue(getExternalResourcePath("externalLib") + " should exist", root.exists()); > } finally { > stopDeltas(); >- deleteExternalFolder("externalLib"); >+ deleteExternalResource("externalLib"); >+ deleteProject("P1"); >+ deleteProject("P2"); >+ } >+} >+ >+public void testContainerInitializer22() throws CoreException { >+ try { >+ createProject("P1"); >+ createExternalFile("externalLib.abc", ""); >+ ContainerInitializer.setInitializer(new DefaultContainerInitializer(new String[] {"P2", getExternalResourcePath("externalLib.abc")})); >+ IJavaProject p2 = createJavaProject( >+ "P2", >+ new String[] {}, >+ new String[] {"org.eclipse.jdt.core.tests.model.TEST_CONTAINER"}, >+ ""); >+ IPackageFragmentRoot root = p2.getPackageFragmentRoot(getExternalResourcePath("externalLib.abc")); >+ assertTrue(getExternalResourcePath("externalLib.abc") + " should exist", root.exists()); >+ } finally { >+ stopDeltas(); >+ deleteAndRefreshExternalZIPArchive("externalLib.abc", "P2"); >+ deleteProject("P1"); >+ deleteProject("P2"); >+ } >+} >+ >+public void testContainerInitializer23() throws CoreException { >+ try { >+ createProject("P1"); >+ IFile lib = createFile("/P1/internalLib.abc", ""); >+ ContainerInitializer.setInitializer(new DefaultContainerInitializer(new String[] {"P2", "/P1/internalLib.abc"})); >+ IJavaProject p2 = createJavaProject( >+ "P2", >+ new String[] {}, >+ new String[] {"org.eclipse.jdt.core.tests.model.TEST_CONTAINER"}, >+ ""); >+ IPackageFragmentRoot root = p2.getPackageFragmentRoot(lib); >+ assertTrue("/P1/internalLib.abc should exist", root.exists()); >+ } finally { >+ stopDeltas(); >+ deleteAndRefreshExternalZIPArchive("externalLib.abc", "P2"); > deleteProject("P1"); > deleteProject("P2"); > } >Index: src/org/eclipse/jdt/core/tests/model/ExternalJarDeltaTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ExternalJarDeltaTests.java,v >retrieving revision 1.34 >diff -u -r1.34 ExternalJarDeltaTests.java >--- src/org/eclipse/jdt/core/tests/model/ExternalJarDeltaTests.java 26 Feb 2008 10:11:58 -0000 1.34 >+++ src/org/eclipse/jdt/core/tests/model/ExternalJarDeltaTests.java 18 Apr 2008 14:35:48 -0000 >@@ -84,7 +84,7 @@ > ); > } finally { > if(f != null) { >- deleteFile(f); >+ deleteResource(f); > } > this.deleteProject("P"); > this.stopDeltas(); >@@ -118,7 +118,7 @@ > ); > } finally { > if(f != null) { >- deleteFile(f); >+ deleteResource(f); > } > this.deleteProject("P"); > this.stopDeltas(); >@@ -151,7 +151,7 @@ > ); > } finally { > if(f != null) { >- deleteFile(f); >+ deleteResource(f); > } > this.deleteProject("P"); > this.stopDeltas(); >@@ -185,7 +185,7 @@ > ); > } finally { > if(f != null) { >- deleteFile(f); >+ deleteResource(f); > } > this.deleteProject("P"); > this.stopDeltas(); >@@ -223,7 +223,7 @@ > ); > } finally { > if(f != null) { >- deleteFile(f); >+ deleteResource(f); > } > this.deleteProject("P"); > this.stopDeltas(); >@@ -261,7 +261,7 @@ > ); > } finally { > if(f != null) { >- deleteFile(f); >+ deleteResource(f); > } > this.deleteProject("P"); > this.stopDeltas(); >@@ -297,7 +297,7 @@ > ); > } finally { > if(f != null) { >- deleteFile(f); >+ deleteResource(f); > } > this.deleteProject("P"); > this.stopDeltas(); >@@ -329,7 +329,7 @@ > ); > } finally { > if(f != null) { >- deleteFile(f); >+ deleteResource(f); > } > this.deleteProject("P"); > this.stopDeltas(); >@@ -361,7 +361,7 @@ > ); > } finally { > if(f != null) { >- deleteFile(f); >+ deleteResource(f); > } > this.deleteProject("P"); > this.stopDeltas(); >@@ -394,7 +394,7 @@ > ); > } finally { > if(f != null) { >- deleteFile(f); >+ deleteResource(f); > } > this.deleteProject("P"); > this.stopDeltas(); >@@ -417,7 +417,7 @@ > waitUntilIndexesReady(); > startDeltas(); > >- deleteFile(f); >+ deleteResource(f); > getJavaModel().refreshExternalArchives(null,null); > > assertDeltas( >@@ -427,7 +427,7 @@ > ); > } finally { > if(f != null) { >- deleteFile(f); >+ deleteResource(f); > } > this.deleteProject("P"); > this.stopDeltas(); >@@ -450,7 +450,7 @@ > waitUntilIndexesReady(); > startDeltas(); > >- deleteFile(f); >+ deleteResource(f); > getJavaModel().refreshExternalArchives(new IJavaElement[]{project},null); > > assertDeltas( >@@ -460,7 +460,7 @@ > ); > } finally { > if(f != null) { >- deleteFile(f); >+ deleteResource(f); > } > this.deleteProject("P"); > this.stopDeltas(); >@@ -483,7 +483,7 @@ > waitUntilIndexesReady(); > startDeltas(); > >- deleteFile(f); >+ deleteResource(f); > IPackageFragmentRoot root = project.getPackageFragmentRoot(pPath); > getJavaModel().refreshExternalArchives(new IJavaElement[]{root},null); > >@@ -494,7 +494,7 @@ > ); > } finally { > if(f != null) { >- deleteFile(f); >+ deleteResource(f); > } > this.deleteProject("P"); > this.stopDeltas(); >@@ -541,7 +541,7 @@ > ); > } finally { > if(f != null) { >- deleteFile(f); >+ deleteResource(f); > } > this.deleteProject("P"); > this.stopDeltas(); >Index: src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java,v >retrieving revision 1.93 >diff -u -r1.93 JavaProjectTests.java >--- src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java 6 Mar 2008 14:23:06 -0000 1.93 >+++ src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java 18 Apr 2008 14:35:49 -0000 >@@ -62,7 +62,7 @@ > try { > IJavaProject p = createJavaProject("P"); > createExternalFolder("externalLib"); >- setClasspath(p, new IClasspathEntry[] {JavaCore.newLibraryEntry(new Path(getExternalFolderPath("externalLib")), null, null)}); >+ setClasspath(p, new IClasspathEntry[] {JavaCore.newLibraryEntry(new Path(getExternalResourcePath("externalLib")), null, null)}); > assertElementDescendants( > "Unexpected project content", > "P\n" + >@@ -71,7 +71,7 @@ > p > ); > } finally { >- deleteExternalFolder("externalLib"); >+ deleteExternalResource("externalLib"); > deleteProject("P"); > } > } >@@ -82,7 +82,7 @@ > public void testAddExternalLibFolder2() throws CoreException { > try { > IJavaProject p = createJavaProject("P"); >- IPath path = new Path(getExternalFolderPath("externalLib")); >+ IPath path = new Path(getExternalResourcePath("externalLib")); > setClasspath(p, new IClasspathEntry[] {JavaCore.newLibraryEntry(path, null, null)}); > assertElementDescendants( > "Unexpected project content", >@@ -102,7 +102,7 @@ > IJavaProject p = createJavaProject("P"); > createExternalFolder("externalLib/p"); > createExternalFile("externalLib/p/X.class", ""); >- setClasspath(p, new IClasspathEntry[] {JavaCore.newLibraryEntry(new Path(getExternalFolderPath("externalLib")), null, null)}); >+ setClasspath(p, new IClasspathEntry[] {JavaCore.newLibraryEntry(new Path(getExternalResourcePath("externalLib")), null, null)}); > assertElementDescendants( > "Unexpected project content", > "P\n" + >@@ -113,7 +113,7 @@ > p > ); > } finally { >- deleteExternalFolder("externalLib"); >+ deleteExternalResource("externalLib"); > deleteProject("P"); > } > } >@@ -123,7 +123,7 @@ > */ > public void testAddExternalLibFolder4() throws CoreException { > try { >- IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalFolderPath("externalLib")}, ""); >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib")}, ""); > expandAll(p); > createExternalFolder("externalLib"); > refresh(p); >@@ -135,7 +135,7 @@ > p > ); > } finally { >- deleteExternalFolder("externalLib"); >+ deleteExternalResource("externalLib"); > deleteProject("P"); > } > } >@@ -149,7 +149,7 @@ > simulateExitRestart(); > createExternalFolder("externalLib/p"); > createExternalFile("externalLib/p/X.class", ""); >- IJavaProject p = importJavaProject("P", new String[0], new String[] {getExternalFolderPath("externalLib")}, ""); >+ IJavaProject p = importJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib")}, ""); > waitForAutoBuild(); // since the project is imported, the linked folder can only be created by auto-build > assertElementDescendants( > "Unexpected project content", >@@ -161,7 +161,152 @@ > p > ); > } finally { >- deleteExternalFolder("externalLib"); >+ deleteExternalResource("externalLib"); >+ deleteProject("P"); >+ } >+} >+ >+/* >+ * Ensures that adding a library entry for an existing empty external ZIP archive updates the model >+ */ >+public void testAddZIPArchive1() throws Exception { >+ try { >+ IJavaProject p = createJavaProject("P"); >+ createExternalFile("externalLib.abc", ""); >+ setClasspath(p, new IClasspathEntry[] {JavaCore.newLibraryEntry(new Path(getExternalResourcePath("externalLib.abc")), null, null)}); >+ assertElementDescendants( >+ "Unexpected project content", >+ "P\n" + >+ " "+ getExternalPath() + "externalLib.abc", >+ p >+ ); >+ } finally { >+ deleteAndRefreshExternalZIPArchive("externalLib.abc", "P"); >+ deleteProject("P"); >+ } >+} >+ >+/* >+ * Ensures that adding a library entry for an non-existing external ZIP archive updates the model >+ */ >+public void testAddZIPArchive2() throws CoreException { >+ try { >+ IJavaProject p = createJavaProject("P"); >+ IPath path = new Path(getExternalResourcePath("externalLib.abc")); >+ setClasspath(p, new IClasspathEntry[] {JavaCore.newLibraryEntry(path, null, null)}); >+ assertElementDescendants( >+ "Unexpected project content", >+ "P", >+ p >+ ); >+ } finally { >+ deleteProject("P"); >+ } >+} >+ >+/* >+ * Ensures that adding a library entry for an existing non-empty external ZIP archive updates the model >+ */ >+public void testAddZIPArchive3() throws CoreException, IOException { >+ try { >+ IJavaProject p = createJavaProject("P"); >+ org.eclipse.jdt.core.tests.util.Util.createJar( >+ new String[] { >+ "p/X.java", >+ "package p;\n" + >+ "public class X {\n" + >+ "}" >+ }, >+ getExternalResourcePath("externalLib.abc"), >+ "1.4"); >+ setClasspath(p, new IClasspathEntry[] {JavaCore.newLibraryEntry(new Path(getExternalResourcePath("externalLib.abc")), null, null)}); >+ assertElementDescendants( >+ "Unexpected project content", >+ "P\n" + >+ " "+ getExternalPath() + "externalLib.abc\n" + >+ " <default> (...)\n" + >+ " p (...)\n" + >+ " X.class\n" + >+ " class X\n" + >+ " X()", >+ p >+ ); >+ } finally { >+ deleteAndRefreshExternalZIPArchive("externalLib.abc", "P"); >+ deleteProject("P"); >+ } >+} >+ >+/* >+ * Ensures that creating an external ZIP archive referenced by a library entry and refreshing updates the model >+ */ >+public void testAddZIPArchive4() throws Exception { >+ try { >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, ""); >+ expandAll(p); >+ createExternalFile("externalLib.abc", ""); >+ refreshExternalArchives(p); >+ assertElementDescendants( >+ "Unexpected project content", >+ "P\n" + >+ " "+ getExternalPath() + "externalLib.abc", >+ p >+ ); >+ } finally { >+ deleteAndRefreshExternalZIPArchive("externalLib.abc", "P"); >+ deleteProject("P"); >+ } >+} >+ >+/* >+ * Ensures that importing a Java project with a library entry for an existing empty external ZIP archive after restart >+ * updates the model >+ */ >+public void testAddZIPArchive5() throws Exception { >+ try { >+ simulateExitRestart(); >+ org.eclipse.jdt.core.tests.util.Util.createJar( >+ new String[] { >+ "p/X.java", >+ "package p;\n" + >+ "public class X {\n" + >+ "}" >+ }, >+ getExternalResourcePath("externalLib.abc"), >+ "1.4"); >+ IJavaProject p = importJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, ""); >+ assertElementDescendants( >+ "Unexpected project content", >+ "P\n" + >+ " "+ getExternalPath() + "externalLib.abc\n" + >+ " <default> (...)\n" + >+ " p (...)\n" + >+ " X.class\n" + >+ " class X\n" + >+ " X()", >+ p >+ ); >+ } finally { >+ deleteAndRefreshExternalZIPArchive("externalLib.abc", "P"); >+ deleteProject("P"); >+ } >+} >+ >+/* >+ * Ensures that adding a library entry for an existing empty internal ZIP archive updates the model >+ */ >+public void testAddZIPArchive6() throws Exception { >+ try { >+ IJavaProject p = createJavaProject("P"); >+ createFile("/P/internalLib.abc", ""); >+ setClasspath(p, new IClasspathEntry[] {JavaCore.newLibraryEntry(new Path("/P/internalLib.abc"), null, null)}); >+ assertElementDescendants( >+ "Unexpected project content", >+ "P\n" + >+ " internalLib.abc", >+ p >+ ); >+ } finally { > deleteProject("P"); > } > } >@@ -257,7 +402,7 @@ > public void testChangeExternalLibFolder1() throws CoreException, IOException { > try { > createExternalFolder("externalLib"); >- IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalFolderPath("externalLib")}, "bin"); >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib")}, "bin"); > expandAll(p); > > createExternalFolder("externalLib/p"); >@@ -273,7 +418,7 @@ > p > ); > } finally { >- deleteExternalFolder("externalLib"); >+ deleteExternalResource("externalLib"); > deleteProject("P"); > } > } >@@ -285,10 +430,10 @@ > try { > createExternalFolder("externalLib/p"); > createExternalFile("externalLib/p/X.class", ""); >- IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalFolderPath("externalLib")}, "bin"); >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib")}, "bin"); > expandAll(p); > >- deleteExternalFolder("externalLib/p"); >+ deleteExternalResource("externalLib/p"); > refresh(p); > assertElementDescendants( > "Unexpected project content", >@@ -298,7 +443,122 @@ > p > ); > } finally { >- deleteExternalFolder("externalLib"); >+ deleteExternalResource("externalLib"); >+ deleteProject("P"); >+ } >+} >+ >+/* >+ * Ensures that changing the content of an external ZIP archive and refreshing updates the model >+ */ >+public void testChangeZIPArchive1() throws CoreException, IOException { >+ try { >+ createExternalFile("externalLib.abc", ""); >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, "bin"); >+ expandAll(p); >+ >+ org.eclipse.jdt.core.tests.util.Util.createJar( >+ new String[] { >+ "p/X.java", >+ "package p;\n" + >+ "public class X {\n" + >+ "}" >+ }, >+ getExternalResourcePath("externalLib.abc"), >+ "1.4"); >+ refreshExternalArchives(p); >+ assertElementDescendants( >+ "Unexpected project content", >+ "P\n" + >+ " "+ getExternalPath() + "externalLib.abc\n" + >+ " <default> (...)\n" + >+ " p (...)\n" + >+ " X.class\n" + >+ " class X\n" + >+ " X()", >+ p >+ ); >+ } finally { >+ deleteAndRefreshExternalZIPArchive("externalLib.abc", "P"); >+ deleteProject("P"); >+ } >+} >+ >+/* >+ * Ensures that changing the content of an external ZIP archive and refreshing updates the model >+ */ >+public void testChangeZIPArchive2() throws CoreException, IOException { >+ try { >+ org.eclipse.jdt.core.tests.util.Util.createJar( >+ new String[] { >+ "p/X.java", >+ "package p;\n" + >+ "public class X {\n" + >+ "}" >+ }, >+ getExternalResourcePath("externalLib.abc"), >+ "1.4"); >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, "bin"); >+ expandAll(p); >+ >+ org.eclipse.jdt.core.tests.util.Util.createJar( >+ new String[] { >+ "p2/X.java", >+ "package p2;\n" + >+ "public class X {\n" + >+ "}" >+ }, >+ getExternalResourcePath("externalLib.abc"), >+ "1.4"); >+ refreshExternalArchives(p); >+ assertElementDescendants( >+ "Unexpected project content", >+ "P\n" + >+ " "+ getExternalPath() + "externalLib.abc\n" + >+ " <default> (...)\n" + >+ " p2 (...)\n" + >+ " X.class\n" + >+ " class X\n" + >+ " X()", >+ p >+ ); >+ } finally { >+ deleteAndRefreshExternalZIPArchive("externalLib.abc", "P"); >+ deleteProject("P"); >+ } >+} >+ >+/* >+ * Ensures that changing the content of an internal ZIP archive and refreshing updates the model >+ */ >+public void testChangeZIPArchive3() throws CoreException, IOException { >+ try { >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {"/P/internalLib.abc"}, "bin"); >+ IFile lib = createFile("/P/internalLib.abc", ""); >+ expandAll(p); >+ >+ org.eclipse.jdt.core.tests.util.Util.createJar( >+ new String[] { >+ "p/X.java", >+ "package p;\n" + >+ "public class X {\n" + >+ "}" >+ }, >+ lib.getLocation().toOSString(), >+ "1.4"); >+ p.getProject().refreshLocal(IResource.DEPTH_INFINITE, null); >+ assertElementDescendants( >+ "Unexpected project content", >+ "P\n" + >+ " internalLib.abc\n" + >+ " <default> (...)\n" + >+ " p (...)\n" + >+ " X.class\n" + >+ " class X\n" + >+ " X()", >+ p >+ ); >+ } finally { > deleteProject("P"); > } > } >@@ -1025,8 +1285,8 @@ > try { > createExternalFolder("externalLib/p/META-INF"); > createExternalFile("externalLib/p/test.txt", "test"); >- createJavaProject("P", new String[0], new String[] {getExternalFolderPath("externalLib")}, ""); >- IPackageFragment pkg = getPackageFragmentRoot("P", getExternalFolderPath("externalLib")).getPackageFragment("p"); >+ createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib")}, ""); >+ IPackageFragment pkg = getPackageFragmentRoot("P", getExternalResourcePath("externalLib")).getPackageFragment("p"); > Object[] resources = pkg.getNonJavaResources(); > assertResourceTreeEquals( > "unexpected non java resources", >@@ -1035,7 +1295,7 @@ > resources); > } finally { > deleteProject("P"); >- deleteExternalFolder("externalLib"); >+ deleteExternalResource("externalLib"); > } > } > >@@ -1188,8 +1448,8 @@ > try { > createExternalFolder("externalLib/META-INF"); > createExternalFile("externalLib/test.txt", "test"); >- createJavaProject("P", new String[0], new String[] {getExternalFolderPath("externalLib")}, ""); >- IPackageFragmentRoot root = getPackageFragmentRoot("P", getExternalFolderPath("externalLib")); >+ createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib")}, ""); >+ IPackageFragmentRoot root = getPackageFragmentRoot("P", getExternalResourcePath("externalLib")); > Object[] resources = root.getNonJavaResources(); > assertResourceTreeEquals( > "unexpected non java resources", >@@ -1198,7 +1458,7 @@ > resources); > } finally { > deleteProject("P"); >- deleteExternalFolder("externalLib"); >+ deleteExternalResource("externalLib"); > } > } > /** >@@ -1605,7 +1865,7 @@ > public void testRemoveExternalLibFolder1() throws CoreException { > try { > createExternalFolder("externalLib"); >- IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalFolderPath("externalLib")}, ""); >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib")}, ""); > expandAll(p); > setClasspath(p, new IClasspathEntry[] {}); > assertElementDescendants( >@@ -1614,7 +1874,7 @@ > p > ); > } finally { >- deleteExternalFolder("externalLib"); >+ deleteExternalResource("externalLib"); > deleteProject("P"); > } > } >@@ -1624,7 +1884,7 @@ > */ > public void testRemoveExternalLibFolder2() throws CoreException { > try { >- IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalFolderPath("externalLib")}, ""); >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib")}, ""); > expandAll(p); > setClasspath(p, new IClasspathEntry[] {}); > assertElementDescendants( >@@ -1644,9 +1904,9 @@ > public void testRemoveExternalLibFolder3() throws CoreException { > try { > createExternalFolder("externalLib"); >- IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalFolderPath("externalLib")}, ""); >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib")}, ""); > expandAll(p); >- deleteExternalFolder("externalLib"); >+ deleteExternalResource("externalLib"); > refresh(p); > assertElementDescendants( > "Unexpected project content", >@@ -1654,7 +1914,85 @@ > p > ); > } finally { >- deleteExternalFolder("externalLib"); >+ deleteExternalResource("externalLib"); >+ deleteProject("P"); >+ } >+} >+ >+/* >+ * Ensures that removing a library entry for an existing external ZIP archive updates the model >+ */ >+public void testRemoveZIPArchive1() throws CoreException { >+ try { >+ createExternalFile("externalLib.abc", ""); >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, ""); >+ expandAll(p); >+ setClasspath(p, new IClasspathEntry[] {}); >+ assertElementDescendants( >+ "Unexpected project content", >+ "P", >+ p >+ ); >+ } finally { >+ deleteAndRefreshExternalZIPArchive("externalLib.abc", "P"); >+ deleteProject("P"); >+ } >+} >+ >+/* >+ * Ensures that removing a library entry for a non-existing external ZIP archive updates the model >+ */ >+public void testRemoveZIPArchive2() throws CoreException { >+ try { >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, ""); >+ expandAll(p); >+ setClasspath(p, new IClasspathEntry[] {}); >+ assertElementDescendants( >+ "Unexpected project content", >+ "P", >+ p >+ ); >+ } finally { >+ deleteProject("P"); >+ } >+} >+ >+ >+/* >+ * Ensures that removing an external ZIP archive referenced by a library entry and refreshing updates the model >+ */ >+public void testRemoveZIPArchive3() throws CoreException { >+ try { >+ createExternalFile("externalLib.abc", ""); >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, ""); >+ expandAll(p); >+ deleteAndRefreshExternalZIPArchive("externalLib.abc", "P"); >+ assertElementDescendants( >+ "Unexpected project content", >+ "P", >+ p >+ ); >+ } finally { >+ deleteAndRefreshExternalZIPArchive("externalLib.abc", "P"); >+ deleteProject("P"); >+ } >+} >+ >+/* >+ * Ensures that removing a library entry for an existing internal ZIP archive updates the model >+ */ >+public void testRemoveZIPArchive4() throws CoreException { >+ try { >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {"/P/internalLib.abc"}, ""); >+ createFile("/P/internalLib.abc", ""); >+ expandAll(p); >+ setClasspath(p, new IClasspathEntry[] {}); >+ assertElementDescendants( >+ "Unexpected project content", >+ "P", >+ p >+ ); >+ } finally { > deleteProject("P"); > } > } >Index: src/org/eclipse/jdt/core/tests/model/AttachSourceTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AttachSourceTests.java,v >retrieving revision 1.52 >diff -u -r1.52 AttachSourceTests.java >--- src/org/eclipse/jdt/core/tests/model/AttachSourceTests.java 27 Feb 2008 15:15:55 -0000 1.52 >+++ src/org/eclipse/jdt/core/tests/model/AttachSourceTests.java 18 Apr 2008 14:35:47 -0000 >@@ -56,7 +56,7 @@ > super(name); > } > protected String getExternalFolder() { >- return getExternalFolderPath("externalFolder"); >+ return getExternalResourcePath("externalFolder"); > } > public ASTNode runConversion(IClassFile classFile, boolean resolveBindings) { > ASTParser parser = ASTParser.newParser(AST_INTERNAL_JLS2); >@@ -93,6 +93,9 @@ > }; > org.eclipse.jdt.core.tests.util.Util.createClassFolder(pathsAndContents, externalFolder + "/lib", "1.4"); > org.eclipse.jdt.core.tests.util.Util.createSourceDir(pathsAndContents, externalFolder + "/src"); >+ >+ org.eclipse.jdt.core.tests.util.Util.createJar(pathsAndContents, externalFolder + "/lib.abc", "1.4"); >+ org.eclipse.jdt.core.tests.util.Util.createSourceZip(pathsAndContents, externalFolder + "/src.abc"); > } > private void setUpGenericJar() throws IOException, CoreException { > String[] pathAndContents = new String[] { >@@ -407,6 +410,94 @@ > } > } > /* >+ * Ensures that one can attach an external ZIP archive containing sources to a library folder. >+ */ >+public void testZIPArchive1() throws CoreException { >+ try { >+ IProject p = createProject("P1"); >+ IFolder lib = p.getFolder("lib"); >+ lib.createLink(new Path(getExternalFolder() + "/lib"), IResource.NONE, null); >+ IJavaProject javaProject = createJavaProject("P2", new String[0], new String[] {"/P1/lib"}, ""); >+ IPackageFragmentRoot root = javaProject.getPackageFragmentRoot(lib); >+ attachSource(root, getExternalFolder() + "/src.abc", ""); >+ IType type = root.getPackageFragment("p").getClassFile("X.class").getType(); >+ assertSourceEquals( >+ "Unexpected source", >+ "public class X {\n" + >+ "}", >+ type.getSource()); >+ } finally { >+ deleteProject("P1"); >+ deleteProject("P2"); >+ } >+} >+/* >+ * Ensures that one can attach a source folder to an external ZIP archive. >+ */ >+public void testZIPArchive2() throws CoreException { >+ try { >+ IProject p = createProject("P1"); >+ IFolder src = p.getFolder("src"); >+ src.createLink(new Path(getExternalFolder() + "/src"), IResource.NONE, null); >+ String externalLib = getExternalFolder() + "/lib.abc"; >+ IJavaProject javaProject = createJavaProject("P2", new String[0], new String[] {externalLib}, ""); >+ IPackageFragmentRoot root = javaProject.getPackageFragmentRoot(externalLib); >+ attachSource(root, "/P1/src", ""); >+ IType type = root.getPackageFragment("p").getClassFile("X.class").getType(); >+ assertSourceEquals( >+ "Unexpected source", >+ "public class X {\n" + >+ "}", >+ type.getSource()); >+ } finally { >+ deleteProject("P1"); >+ deleteProject("P2"); >+ } >+} >+/* >+ * Ensures that one can attach an external ZIP archive containing sources to an external ZIP archive. >+ */ >+public void testZIPArchive3() throws CoreException { >+ try { >+ String externalLib = getExternalFolder() + "/lib.abc"; >+ IJavaProject javaProject = createJavaProject("P", new String[0], new String[] {externalLib}, ""); >+ IPackageFragmentRoot root = javaProject.getPackageFragmentRoot(externalLib); >+ attachSource(root, getExternalFolder() + "/src.abc", ""); >+ IType type = root.getPackageFragment("p").getClassFile("X.class").getType(); >+ assertSourceEquals( >+ "Unexpected source", >+ "public class X {\n" + >+ "}", >+ type.getSource()); >+ } finally { >+ deleteProject("P"); >+ } >+} >+/* >+ * Ensures that one can attach an internal ZIP archive containing sources to an internal ZIP archive. >+ */ >+public void testZIPArchive4() throws CoreException { >+ try { >+ IProject p = createProject("P1"); >+ IFile lib = p.getFile("lib.abc"); >+ lib.createLink(new Path(getExternalFolder() + "/lib.abc"), IResource.NONE, null); >+ IFile src = p.getFile("src.abc"); >+ src.createLink(new Path(getExternalFolder() + "/src.abc"), IResource.NONE, null); >+ IJavaProject javaProject = createJavaProject("P2", new String[0], new String[] {"/P1/lib.abc"}, ""); >+ IPackageFragmentRoot root = javaProject.getPackageFragmentRoot(lib); >+ attachSource(root, "/P1/src.abc", ""); >+ IType type = root.getPackageFragment("p").getClassFile("X.class").getType(); >+ assertSourceEquals( >+ "Unexpected source", >+ "public class X {\n" + >+ "}", >+ type.getSource()); >+ } finally { >+ deleteProject("P1"); >+ deleteProject("P2"); >+ } >+} >+/* > * Ensures that the source of a generic method can be retrieved. > */ > public void testGeneric1() throws JavaModelException { >Index: src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java,v >retrieving revision 1.83 >diff -u -r1.83 TypeHierarchyTests.java >--- src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java 28 Feb 2008 13:00:46 -0000 1.83 >+++ src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java 18 Apr 2008 14:35:51 -0000 >@@ -715,9 +715,9 @@ > "}", > }, > new HashMap(), >- getExternalFolderPath("externalLib")); >- createJavaProject("P", new String[0], new String[] {getExternalFolderPath("externalLib")}, ""); >- IClassFile classFile = getClassFile("P", getExternalFolderPath("externalLib"), "p", "X.class"); >+ getExternalResourcePath("externalLib")); >+ createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib")}, ""); >+ IClassFile classFile = getClassFile("P", getExternalResourcePath("externalLib"), "p", "X.class"); > ITypeHierarchy hierarchy = classFile.getType().newTypeHierarchy(null); > assertHierarchyEquals( > "Focus: X [in X.class [in p [in "+ getExternalPath() + "externalLib]]]\n" + >@@ -727,7 +727,39 @@ > hierarchy); > } finally { > deleteProject("P"); >- deleteExternalFolder("externalLib"); >+ deleteExternalResource("externalLib"); >+ } >+} >+/* >+ * Ensures that subtypes are found in an external ZIP archive >+ */ >+public void testZIPArchive() throws CoreException, IOException { >+ try { >+ org.eclipse.jdt.core.tests.util.Util.createJar( >+ new String[] { >+ "p/X.java", >+ "package p;\n" + >+ "public class X {\n" + >+ "}", >+ "p/Y.java", >+ "package p;\n" + >+ "public class Y extends X {\n" + >+ "}", >+ }, >+ getExternalResourcePath("externalLib.abc"), >+ "1.4"); >+ createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, ""); >+ IClassFile classFile = getClassFile("P", getExternalResourcePath("externalLib.abc"), "p", "X.class"); >+ ITypeHierarchy hierarchy = classFile.getType().newTypeHierarchy(null); >+ assertHierarchyEquals( >+ "Focus: X [in X.class [in p [in "+ getExternalPath() + "externalLib.abc]]]\n" + >+ "Super types:\n" + >+ "Sub types:\n" + >+ " Y [in Y.class [in p [in "+ getExternalPath() + "externalLib.abc]]]\n", >+ hierarchy); >+ } finally { >+ deleteAndRefreshExternalZIPArchive("externalLib.abc", "P"); >+ deleteProject("P"); > } > } > /* >Index: src/org/eclipse/jdt/core/tests/model/CompletionTests2.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests2.java,v >retrieving revision 1.36 >diff -u -r1.36 CompletionTests2.java >--- src/org/eclipse/jdt/core/tests/model/CompletionTests2.java 8 Aug 2007 15:28:12 -0000 1.36 >+++ src/org/eclipse/jdt/core/tests/model/CompletionTests2.java 18 Apr 2008 14:35:48 -0000 >@@ -2332,7 +2332,7 @@ > requestor.getResults()); > } finally { > removeClasspathEntry(this.currentProject, new Path(jarName)); >- deleteFile(new File(jarName)); >+ deleteResource(new File(jarName)); > } > } > } >Index: src/org/eclipse/jdt/core/tests/model/ClasspathTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClasspathTests.java,v >retrieving revision 1.170 >diff -u -r1.170 ClasspathTests.java >--- src/org/eclipse/jdt/core/tests/model/ClasspathTests.java 27 Feb 2008 18:08:55 -0000 1.170 >+++ src/org/eclipse/jdt/core/tests/model/ClasspathTests.java 18 Apr 2008 14:35:48 -0000 >@@ -44,7 +44,6 @@ > import org.eclipse.jdt.core.IClasspathContainer; > import org.eclipse.jdt.core.IClasspathEntry; > import org.eclipse.jdt.core.ICompilationUnit; >-import org.eclipse.jdt.core.IJavaElement; > import org.eclipse.jdt.core.IJavaElementDelta; > import org.eclipse.jdt.core.IJavaModelMarker; > import org.eclipse.jdt.core.IJavaModelStatus; >@@ -162,10 +161,10 @@ > try { > IJavaProject p = createJavaProject("P"); > createExternalFolder("externalLib"); >- setClasspath(p, new IClasspathEntry[] {JavaCore.newLibraryEntry(new Path(getExternalFolderPath("externalLib")), null, null)}); >+ setClasspath(p, new IClasspathEntry[] {JavaCore.newLibraryEntry(new Path(getExternalResourcePath("externalLib")), null, null)}); > assertMarkers("Unexpected markers", "", p); > } finally { >- deleteExternalFolder("externalLib"); >+ deleteExternalResource("externalLib"); > deleteProject("P"); > } > } >@@ -176,10 +175,10 @@ > public void testAddExternalLibFolder2() throws CoreException { > try { > createExternalFolder("externalLib"); >- IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalFolderPath("externalLib")}, ""); >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib")}, ""); > assertMarkers("Unexpected markers", "", p); > } finally { >- deleteExternalFolder("externalLib"); >+ deleteExternalResource("externalLib"); > deleteProject("P"); > } > } >@@ -191,7 +190,7 @@ > try { > waitForAutoBuild(); > IJavaProject p = createJavaProject("P"); >- IPath path = new Path(getExternalFolderPath("externalLib")); >+ IPath path = new Path(getExternalResourcePath("externalLib")); > setClasspath(p, new IClasspathEntry[] {JavaCore.newLibraryEntry(path, null, null)}); > assertMarkers( > "Unexpected markers", >@@ -208,7 +207,7 @@ > public void testAddExternalLibFolder4() throws CoreException { > try { > waitForAutoBuild(); >- IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalFolderPath("externalLib")}, ""); >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib")}, ""); > assertMarkers( > "Unexpected markers", > "Project \'P\' is missing required library: \'"+ getExternalPath() + "externalLib\'", >@@ -223,13 +222,13 @@ > */ > public void testAddExternalLibFolder5() throws CoreException { > try { >- IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalFolderPath("externalLib")}, ""); >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib")}, ""); > waitForAutoBuild(); > createExternalFolder("externalLib"); > refresh(p); > assertMarkers("Unexpected markers", "", p); > } finally { >- deleteExternalFolder("externalLib"); >+ deleteExternalResource("externalLib"); > deleteProject("P"); > } > } >@@ -241,13 +240,124 @@ > public void testAddExternalLibFolder6() throws CoreException { > try { > simulateExitRestart(); >- IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalFolderPath("externalLib")}, ""); >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib")}, ""); > waitForAutoBuild(); > createExternalFolder("externalLib"); > refresh(p); > assertMarkers("Unexpected markers", "", p); > } finally { >- deleteExternalFolder("externalLib"); >+ deleteExternalResource("externalLib"); >+ deleteProject("P"); >+ } >+} >+ >+/* >+ * Ensures that adding a library entry for an existing external ZIP archive doesn't generate a marker >+ */ >+public void testAddZIPArchive1() throws CoreException { >+ try { >+ IJavaProject p = createJavaProject("P"); >+ createExternalFile("externalLib.abc", ""); >+ setClasspath(p, new IClasspathEntry[] {JavaCore.newLibraryEntry(new Path(getExternalResourcePath("externalLib.abc")), null, null)}); >+ assertMarkers("Unexpected markers", "", p); >+ } finally { >+ deleteAndRefreshExternalZIPArchive("externalLib.abc", "P"); >+ deleteProject("P"); >+ } >+} >+ >+/* >+ * Ensures that creating a project with a library entry for an existing external ZIP archive doesn't generate a marker >+ */ >+public void testAddZIPArchive2() throws CoreException { >+ try { >+ createExternalFile("externalLib.abc", ""); >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, ""); >+ assertMarkers("Unexpected markers", "", p); >+ } finally { >+ deleteAndRefreshExternalZIPArchive("externalLib.abc", "P"); >+ deleteProject("P"); >+ } >+} >+ >+/* >+ * Ensures that adding a library entry for a non-existing external ZIP archive generates a marker >+ */ >+public void testAddZIPArchive3() throws CoreException { >+ try { >+ waitForAutoBuild(); >+ IJavaProject p = createJavaProject("P"); >+ IPath path = new Path(getExternalResourcePath("externalLib.abc")); >+ setClasspath(p, new IClasspathEntry[] {JavaCore.newLibraryEntry(path, null, null)}); >+ assertMarkers( >+ "Unexpected markers", >+ "Project \'P\' is missing required library: \'"+ getExternalPath() + "externalLib.abc\'", >+ p); >+ } finally { >+ deleteProject("P"); >+ } >+} >+ >+/* >+ * Ensures that creating a project with a library entry for a non-existing external ZIP archive generates a marker >+ */ >+public void testAddZIPArchive4() throws CoreException { >+ try { >+ waitForAutoBuild(); >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, ""); >+ assertMarkers( >+ "Unexpected markers", >+ "Project \'P\' is missing required library: \'"+ getExternalPath() + "externalLib.abc\'", >+ p); >+ } finally { >+ deleteProject("P"); >+ } >+} >+ >+/* >+ * Ensures that creating an external ZIP archive referenced by a library entry and refreshing removes the marker >+ */ >+public void testAddZIPArchive5() throws CoreException { >+ try { >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, ""); >+ waitForAutoBuild(); >+ createExternalFile("externalLib.abc", ""); >+ refreshExternalArchives(p); >+ assertMarkers("Unexpected markers", "", p); >+ } finally { >+ deleteAndRefreshExternalZIPArchive("externalLib.abc", "P"); >+ deleteProject("P"); >+ } >+} >+ >+/* >+ * Ensures that creating an external ZIP archive referenced by a library entry and refreshing after a restart >+ * removes the marker >+ */ >+public void testAddZIPArchive6() throws CoreException { >+ try { >+ simulateExitRestart(); >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, ""); >+ waitForAutoBuild(); >+ createExternalFile("externalLib.abc", ""); >+ refreshExternalArchives(p); >+ assertMarkers("Unexpected markers", "", p); >+ } finally { >+ deleteAndRefreshExternalZIPArchive("externalLib.abc", "P"); >+ deleteProject("P"); >+ } >+} >+ >+/* >+ * Ensures that adding a library entry for an existing internal ZIP archive doesn't generate a marker >+ */ >+public void testAddZIPArchive7() throws CoreException { >+ try { >+ IJavaProject p = createJavaProject("P"); >+ createFile("/P/internalLib.abc", ""); >+ setClasspath(p, new IClasspathEntry[] {JavaCore.newLibraryEntry(new Path("/P/internalLib.abc"), null, null)}); >+ assertMarkers("Unexpected markers", "", p); >+ } finally { > deleteProject("P"); > } > } >@@ -730,7 +840,7 @@ > * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=220542 ) > */ > public void testExternalize2() throws CoreException { >- String externalLibPath = getExternalFolderPath("externalLib") + File.separator; >+ String externalLibPath = getExternalResourcePath("externalLib") + File.separator; > IClasspathEntry entry = JavaCore.newLibraryEntry(new Path(externalLibPath), null, null); > assertEquals("Unexpected external path", externalLibPath, entry.getPath().toOSString()); > } >@@ -902,6 +1012,7 @@ > IClasspathEntry[] newCP = new IClasspathEntry[originalCP.length+1]; > System.arraycopy(originalCP, 0, newCP, 0, originalCP.length); > newCP[originalCP.length] = JavaCore.newLibraryEntry(new Path("/P/src/lib"), null, null); >+ createFolder("/P/src/lib"); > > IJavaModelStatus status = JavaConventions.validateClasspath(proj, newCP, proj.getOutputLocation()); > >@@ -2370,13 +2481,13 @@ > // at this point, a marker indicates that test185733.jar has been created: "Project 'P' is missing required library: '[...]\test185733.jar'" > > createFile(new File(getExternalPath()), "test185733.jar", ""); >- getJavaModel().refreshExternalArchives(new IJavaElement[] {p}, null); >+ refreshExternalArchives(p); > assertMarkers( > "Unexpected markers", > "", > p); > } finally { >- deleteFile(new File(externalJarPath)); >+ deleteResource(new File(externalJarPath)); > deleteProject("P"); > } > } >@@ -2393,8 +2504,8 @@ > waitForAutoBuild(); > // at this point, the project has no markers > >- deleteFile(externalJar); >- getJavaModel().refreshExternalArchives(new IJavaElement[] {p}, null); >+ deleteResource(externalJar); >+ refreshExternalArchives(p); > assertMarkers( > "Unexpected markers", > "Project \'P\' is missing required library: \'" + externalJar.getPath() + "\'", >@@ -2677,7 +2788,8 @@ > } > } > /* >- * Ensures that a file not ending with .jar or .zip cannot be put on the classpath. >+ * Ensures that a file not ending with .jar or .zip can be put on the classpath. >+ * (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=182360 ) > */ > public void testInvalidInternalJar2() throws CoreException { > try { >@@ -2686,7 +2798,7 @@ > IJavaProject proj = createJavaProject("P2", new String[] {}, new String[] {"/P1/existing.txt"}, "bin"); > assertMarkers( > "Unexpected markers", >- "Illegal type of archive for required library: \'/P1/existing.txt\' in project 'P2'", >+ "", > proj); > } finally { > deleteProject("P1"); >@@ -2721,7 +2833,7 @@ > IJavaProject javaProject = createJavaProject("P"); > IProject project = javaProject.getProject(); > project.close(null); >- deleteFile(new File(project.getLocation().toOSString(), ".classpath")); >+ deleteResource(new File(project.getLocation().toOSString(), ".classpath")); > waitForAutoBuild(); > project.open(null); > waitForAutoBuild(); >@@ -3949,12 +4061,12 @@ > public void testRemoveExternalLibFolder1() throws CoreException { > try { > createExternalFolder("externalLib"); >- IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalFolderPath("externalLib")}, ""); >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib")}, ""); > waitForAutoBuild(); > setClasspath(p, new IClasspathEntry[] {}); > assertMarkers("Unexpected markers", "", p); > } finally { >- deleteExternalFolder("externalLib"); >+ deleteExternalResource("externalLib"); > deleteProject("P"); > } > } >@@ -3964,7 +4076,7 @@ > */ > public void testRemoveExternalLibFolder2() throws CoreException { > try { >- IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalFolderPath("externalLib")}, ""); >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib")}, ""); > waitForAutoBuild(); > setClasspath(p, new IClasspathEntry[] {}); > assertMarkers( >@@ -3982,16 +4094,16 @@ > public void testRemoveExternalLibFolder3() throws CoreException { > try { > createExternalFolder("externalLib"); >- IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalFolderPath("externalLib")}, ""); >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib")}, ""); > waitForAutoBuild(); >- deleteExternalFolder("externalLib"); >+ deleteExternalResource("externalLib"); > refresh(p); > assertMarkers( > "Unexpected markers", > "Project \'P\' is missing required library: \'"+ getExternalPath() + "externalLib\'", > p); > } finally { >- deleteExternalFolder("externalLib"); >+ deleteExternalResource("externalLib"); > deleteProject("P"); > } > } >@@ -4004,16 +4116,122 @@ > try { > simulateExitRestart(); > createExternalFolder("externalLib"); >- IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalFolderPath("externalLib")}, ""); >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib")}, ""); > waitForAutoBuild(); >- deleteExternalFolder("externalLib"); >+ deleteExternalResource("externalLib"); > refresh(p); > assertMarkers( > "Unexpected markers", > "Project \'P\' is missing required library: \'"+ getExternalPath() + "externalLib\'", > p); > } finally { >- deleteExternalFolder("externalLib"); >+ deleteExternalResource("externalLib"); >+ deleteProject("P"); >+ } >+} >+ >+/* >+ * Ensures that removing a library entry for an existing external ZIP archive doesn't generate a marker >+ */ >+public void testRemoveZIPArchive1() throws CoreException { >+ try { >+ createExternalFile("externalLib.abc", ""); >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, ""); >+ waitForAutoBuild(); >+ setClasspath(p, new IClasspathEntry[] {}); >+ assertMarkers("Unexpected markers", "", p); >+ } finally { >+ deleteAndRefreshExternalZIPArchive("externalLib.abc", "P"); >+ deleteProject("P"); >+ } >+} >+ >+/* >+ * Ensures that removing a library entry for a non-existing external ZIP archive removes the marker >+ */ >+public void testRemoveZIPArchive2() throws CoreException { >+ try { >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, ""); >+ waitForAutoBuild(); >+ setClasspath(p, new IClasspathEntry[] {}); >+ assertMarkers( >+ "Unexpected markers", >+ "", >+ p); >+ } finally { >+ deleteProject("P"); >+ } >+} >+ >+/* >+ * Ensures that removing an external ZIP archive referenced by a library entry creates a marker >+ */ >+public void testRemoveZIPArchive3() throws CoreException { >+ try { >+ createExternalFile("externalLib.abc", ""); >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, ""); >+ waitForAutoBuild(); >+ deleteAndRefreshExternalZIPArchive("externalLib.abc", "P"); >+ assertMarkers( >+ "Unexpected markers", >+ "Project \'P\' is missing required library: \'"+ getExternalPath() + "externalLib.abc\'", >+ p); >+ } finally { >+ deleteAndRefreshExternalZIPArchive("externalLib.abc", "P"); >+ deleteProject("P"); >+ } >+} >+ >+/* >+ * Ensures that removing an external ZIP archive referenced by a library entry and refreshing after a restart >+ * creates a marker >+ */ >+public void testRemoveZIPArchive4() throws CoreException { >+ try { >+ simulateExitRestart(); >+ createExternalFile("externalLib.abc", ""); >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, ""); >+ waitForAutoBuild(); >+ deleteAndRefreshExternalZIPArchive("externalLib.abc", "P"); >+ assertMarkers( >+ "Unexpected markers", >+ "Project \'P\' is missing required library: \'"+ getExternalPath() + "externalLib.abc\'", >+ p); >+ } finally { >+ deleteAndRefreshExternalZIPArchive("externalLib.abc", "P"); >+ deleteProject("P"); >+ } >+} >+ >+/* >+ * Ensures that removing a library entry for an existing internal ZIP archive doesn't generate a marker >+ */ >+public void testRemoveZIPArchive5() throws CoreException { >+ try { >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {"/P/internalLib.abc"}, ""); >+ createFile("/P/internalLib.abc", ""); >+ waitForAutoBuild(); >+ setClasspath(p, new IClasspathEntry[] {}); >+ assertMarkers("Unexpected markers", "", p); >+ } finally { >+ deleteProject("P"); >+ } >+} >+ >+/* >+ * Ensures that removing an internal ZIP archive referenced by a library entry creates a marker >+ */ >+public void testRemoveZIPArchive6() throws CoreException { >+ try { >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {"/P/internalLib.abc"}, ""); >+ createFile("/P/internalLib.abc", ""); >+ waitForAutoBuild(); >+ deleteFile("/P/internalLib.abc"); >+ assertMarkers( >+ "Unexpected markers", >+ "Project \'P\' is missing required library: \'internalLib.abc\'", >+ p); >+ } finally { > deleteProject("P"); > } > } >Index: src/org/eclipse/jdt/core/tests/model/ModifyingResourceTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModifyingResourceTests.java,v >retrieving revision 1.49 >diff -u -r1.49 ModifyingResourceTests.java >--- src/org/eclipse/jdt/core/tests/model/ModifyingResourceTests.java 21 Mar 2008 16:59:42 -0000 1.49 >+++ src/org/eclipse/jdt/core/tests/model/ModifyingResourceTests.java 18 Apr 2008 14:35:50 -0000 >@@ -123,8 +123,12 @@ > protected IFolder createFolder(String path) throws CoreException { > return createFolder(new Path(path)); > } >-protected void deleteExternalFolder(String relativePath) { >- deleteFile(new File(getExternalPath() + relativePath)); >+protected void deleteExternalResource(String relativePath) { >+ deleteResource(new File(getExternalPath() + relativePath)); >+} >+protected void deleteAndRefreshExternalZIPArchive(String relativePath, String referringProject) throws JavaModelException { >+ deleteExternalResource(relativePath); >+ refreshExternalArchives(getJavaProject(referringProject)); > } > protected void deleteFile(String filePath) throws CoreException { > deleteResource(this.getFile(filePath)); >Index: src/org/eclipse/jdt/core/tests/model/EncodingTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/EncodingTests.java,v >retrieving revision 1.44 >diff -u -r1.44 EncodingTests.java >--- src/org/eclipse/jdt/core/tests/model/EncodingTests.java 4 Feb 2008 16:03:47 -0000 1.44 >+++ src/org/eclipse/jdt/core/tests/model/EncodingTests.java 18 Apr 2008 14:35:48 -0000 >@@ -847,7 +847,7 @@ > assertEquals("We should not get any character!", "", new String(ifileContents)); > > // Delete empty file >- deleteFile(file); >+ deleteResource(file); > } > > /** >Index: src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java,v >retrieving revision 1.128 >diff -u -r1.128 ReconcilerTests.java >--- src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java 20 Mar 2008 14:02:14 -0000 1.128 >+++ src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java 18 Apr 2008 14:35:50 -0000 >@@ -1191,7 +1191,7 @@ > ); > } finally { > removeClasspathEntry(project, new Path(jarPath)); >- deleteFile(new File(jarPath)); >+ deleteResource(new File(jarPath)); > } > } > /** >@@ -1284,7 +1284,7 @@ > ); > } finally { > removeClasspathEntry(project, new Path(jarName)); >- deleteFile(new File(jarName)); >+ deleteResource(new File(jarName)); > } > } > /** >Index: src/org/eclipse/jdt/core/tests/model/SearchParticipantTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SearchParticipantTests.java,v >retrieving revision 1.15 >diff -u -r1.15 SearchParticipantTests.java >--- src/org/eclipse/jdt/core/tests/model/SearchParticipantTests.java 14 Jun 2006 17:21:29 -0000 1.15 >+++ src/org/eclipse/jdt/core/tests/model/SearchParticipantTests.java 18 Apr 2008 14:35:51 -0000 >@@ -138,7 +138,7 @@ > > public void setUpSuite() throws Exception { > super.setUpSuite(); >- deleteFile(getIndexLocation().toFile()); >+ deleteResource(getIndexLocation().toFile()); > } > > public void tearDownSuite() throws Exception { >Index: src/org/eclipse/jdt/core/tests/model/ResolveTests_1_5.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests_1_5.java,v >retrieving revision 1.58 >diff -u -r1.58 ResolveTests_1_5.java >--- src/org/eclipse/jdt/core/tests/model/ResolveTests_1_5.java 14 Mar 2008 16:43:25 -0000 1.58 >+++ src/org/eclipse/jdt/core/tests/model/ResolveTests_1_5.java 18 Apr 2008 14:35:51 -0000 >@@ -2607,7 +2607,7 @@ > "Member"); > assertEquals("test0114.Test.Member<java.lang.String>", ((IType)elements[0]).getFullyQualifiedParameterizedName()); > } finally { >- deleteFile(rootLocation.append("test0114").toFile()); >+ deleteResource(rootLocation.append("test0114").toFile()); > } > } > } >Index: src/org/eclipse/jdt/core/tests/model/ExistenceTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ExistenceTests.java,v >retrieving revision 1.28 >diff -u -r1.28 ExistenceTests.java >--- src/org/eclipse/jdt/core/tests/model/ExistenceTests.java 29 Feb 2008 10:56:49 -0000 1.28 >+++ src/org/eclipse/jdt/core/tests/model/ExistenceTests.java 18 Apr 2008 14:35:48 -0000 >@@ -316,8 +316,8 @@ > */ > public void testNonExistingExternalPackageFragmentRoot2() throws CoreException { > try { >- IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalFolderPath("nonExisting")}, ""); >- IPackageFragmentRoot root = p.getPackageFragmentRoot(getExternalFolderPath("nonExisting")); >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("nonExisting")}, ""); >+ IPackageFragmentRoot root = p.getPackageFragmentRoot(getExternalResourcePath("nonExisting")); > assertFalse("root should not exist", root.exists()); > } finally { > deleteProject("P"); >Index: src/org/eclipse/jdt/core/tests/model/JavaElementDeltaTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaElementDeltaTests.java,v >retrieving revision 1.83 >diff -u -r1.83 JavaElementDeltaTests.java >--- src/org/eclipse/jdt/core/tests/model/JavaElementDeltaTests.java 6 Mar 2008 14:22:42 -0000 1.83 >+++ src/org/eclipse/jdt/core/tests/model/JavaElementDeltaTests.java 18 Apr 2008 14:35:49 -0000 >@@ -271,7 +271,7 @@ > createExternalFolder("externalLib"); > refresh(p); > startDeltas(); >- setClasspath(p, new IClasspathEntry[] {JavaCore.newLibraryEntry(new Path(getExternalFolderPath("externalLib")), null, null)}); >+ setClasspath(p, new IClasspathEntry[] {JavaCore.newLibraryEntry(new Path(getExternalResourcePath("externalLib")), null, null)}); > assertDeltas( > "Unexpected delta", > "P[*]: {CHILDREN | CONTENT | RAW CLASSPATH CHANGED | RESOLVED CLASSPATH CHANGED}\n" + >@@ -282,7 +282,7 @@ > ); > } finally { > stopDeltas(); >- deleteExternalFolder("externalLib"); >+ deleteExternalResource("externalLib"); > deleteProject("P"); > } > } >@@ -294,7 +294,7 @@ > try { > IJavaProject p = createJavaProject("P"); > refresh(p); >- IPath path = new Path(getExternalFolderPath("externalLib")); >+ IPath path = new Path(getExternalResourcePath("externalLib")); > startDeltas(); > setClasspath(p, new IClasspathEntry[] {JavaCore.newLibraryEntry(path, null, null)}); > assertDeltas( >@@ -315,7 +315,7 @@ > */ > public void testAddExternalLibFolder3() throws CoreException { > try { >- IJavaProject p =createJavaProject("P", new String[0], new String[] {getExternalFolderPath("externalLib")}, ""); >+ IJavaProject p =createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib")}, ""); > startDeltas(); > createExternalFolder("externalLib"); > refresh(p); >@@ -326,7 +326,7 @@ > ); > } finally { > stopDeltas(); >- deleteExternalFolder("externalLib"); >+ deleteExternalResource("externalLib"); > deleteProject("P"); > } > } >@@ -337,7 +337,7 @@ > public void testAddExternalLibFolder4() throws CoreException { > try { > simulateExitRestart(); >- IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalFolderPath("externalLib")}, ""); >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib")}, ""); > startDeltas(); > createExternalFolder("externalLib"); > refresh(p); >@@ -348,7 +348,119 @@ > ); > } finally { > stopDeltas(); >- deleteExternalFolder("externalLib"); >+ deleteExternalResource("externalLib"); >+ deleteProject("P"); >+ } >+} >+ >+/* >+ * Ensures that adding a library entry for an existing external ZIP archive triggers the correct delta >+ */ >+public void testAddZIPArchive1() throws CoreException { >+ try { >+ IJavaProject p = createJavaProject("P"); >+ createExternalFile("externalLib.abc", ""); >+ startDeltas(); >+ setClasspath(p, new IClasspathEntry[] {JavaCore.newLibraryEntry(new Path(getExternalResourcePath("externalLib.abc")), null, null)}); >+ assertDeltas( >+ "Unexpected delta", >+ "P[*]: {CHILDREN | CONTENT | RAW CLASSPATH CHANGED | RESOLVED CLASSPATH CHANGED}\n" + >+ " <project root>[*]: {REMOVED FROM CLASSPATH}\n" + >+ " "+ getExternalPath() + "externalLib.abc[+]: {}\n" + >+ " "+ getExternalJCLPathString() + "[*]: {REMOVED FROM CLASSPATH}\n" + >+ " ResourceDelta(/P/.classpath)[*]" >+ ); >+ } finally { >+ stopDeltas(); >+ deleteAndRefreshExternalZIPArchive("externalLib.abc", "P"); >+ deleteProject("P"); >+ } >+} >+ >+/* >+ * Ensures that adding a library entry for a non-existing external ZIP archive triggers the correct delta >+ */ >+public void testAddZIPArchive2() throws CoreException { >+ try { >+ IJavaProject p = createJavaProject("P"); >+ IPath path = new Path(getExternalResourcePath("externalLib.abc")); >+ startDeltas(); >+ setClasspath(p, new IClasspathEntry[] {JavaCore.newLibraryEntry(path, null, null)}); >+ assertDeltas( >+ "Unexpected delta", >+ "P[*]: {CHILDREN | CONTENT | RAW CLASSPATH CHANGED | RESOLVED CLASSPATH CHANGED}\n" + >+ " <project root>[*]: {REMOVED FROM CLASSPATH}\n" + >+ " "+ getExternalJCLPathString() + "[*]: {REMOVED FROM CLASSPATH}\n" + >+ " ResourceDelta(/P/.classpath)[*]" >+ ); >+ } finally { >+ stopDeltas(); >+ deleteProject("P"); >+ } >+} >+ >+/* >+ * Ensures that creating an external ZIP archive referenced by a library entry and refreshing triggers the correct delta >+ */ >+public void testAddZIPArchive3() throws CoreException { >+ try { >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, ""); >+ startDeltas(); >+ createExternalFile("externalLib.abc", ""); >+ refreshExternalArchives(p); >+ assertDeltas( >+ "Unexpected delta", >+ "P[*]: {CHILDREN}\n" + >+ " "+ getExternalPath() + "externalLib.abc[+]: {}" >+ ); >+ } finally { >+ stopDeltas(); >+ deleteAndRefreshExternalZIPArchive("externalLib.abc", "P"); >+ deleteProject("P"); >+ } >+} >+ >+/* >+ * Ensures that creating an external ZIP archive referenced by a library entry and refreshing after a restart triggers the correct delta >+ */ >+public void testAddZIPArchive4() throws CoreException { >+ try { >+ simulateExitRestart(); >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, ""); >+ startDeltas(); >+ createExternalFile("externalLib.abc", ""); >+ refreshExternalArchives(p); >+ assertDeltas( >+ "Unexpected delta", >+ "P[*]: {CHILDREN}\n" + >+ " "+ getExternalPath() + "externalLib.abc[+]: {}" >+ ); >+ } finally { >+ stopDeltas(); >+ deleteAndRefreshExternalZIPArchive("externalLib.abc", "P"); >+ deleteProject("P"); >+ } >+} >+ >+/* >+ * Ensures that adding a library entry for an existing internal ZIP archive triggers the correct delta >+ */ >+public void testAddZIPArchive5() throws CoreException { >+ try { >+ IJavaProject p = createJavaProject("P"); >+ createFile("/P/internalLib.abc", ""); >+ startDeltas(); >+ setClasspath(p, new IClasspathEntry[] {JavaCore.newLibraryEntry(new Path("/P/internalLib.abc"), null, null)}); >+ assertDeltas( >+ "Unexpected delta", >+ "P[*]: {CHILDREN | CONTENT | RAW CLASSPATH CHANGED | RESOLVED CLASSPATH CHANGED}\n" + >+ " <project root>[*]: {REMOVED FROM CLASSPATH}\n" + >+ " internalLib.abc[*]: {ADDED TO CLASSPATH}\n" + >+ " "+ getExternalJCLPathString() + "[*]: {REMOVED FROM CLASSPATH}\n" + >+ " ResourceDelta(/P/.classpath)[*]" >+ ); >+ } finally { >+ stopDeltas(); > deleteProject("P"); > } > } >@@ -782,7 +894,7 @@ > public void testChangeExternalLibFolder1() throws CoreException { > try { > createExternalFolder("externalLib"); >- IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalFolderPath("externalLib")}, ""); >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib")}, ""); > startDeltas(); > createExternalFolder("externalLib/p"); > refresh(p); >@@ -794,7 +906,7 @@ > ); > } finally { > stopDeltas(); >- deleteExternalFolder("externalLib"); >+ deleteExternalResource("externalLib"); > deleteProject("P"); > } > } >@@ -805,7 +917,7 @@ > public void testChangeExternalLibFolder2() throws CoreException { > try { > createExternalFolder("externalLib/p"); >- IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalFolderPath("externalLib")}, ""); >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib")}, ""); > startDeltas(); > createExternalFile("externalLib/p/X.class", ""); > refresh(p); >@@ -818,7 +930,7 @@ > ); > } finally { > stopDeltas(); >- deleteExternalFolder("externalLib"); >+ deleteExternalResource("externalLib"); > deleteProject("P"); > } > } >@@ -830,7 +942,7 @@ > try { > createExternalFolder("externalLib/p"); > createExternalFile("externalLib/p/X.class", ""); >- IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalFolderPath("externalLib")}, ""); >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib")}, ""); > startDeltas(); > touch(getExternalFile("externalLib/p/X.class")); > refresh(p); >@@ -843,7 +955,7 @@ > ); > } finally { > stopDeltas(); >- deleteExternalFolder("externalLib"); >+ deleteExternalResource("externalLib"); > deleteProject("P"); > } > } >@@ -854,7 +966,7 @@ > public void testChangeExternalLibFolder4() throws CoreException { > try { > createExternalFolder("externalLib"); >- IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalFolderPath("externalLib")}, ""); >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib")}, ""); > startDeltas(); > createExternalFile("externalLib/test.txt", "test"); > refresh(p); >@@ -865,7 +977,7 @@ > ); > } finally { > stopDeltas(); >- deleteExternalFolder("externalLib"); >+ deleteExternalResource("externalLib"); > deleteProject("P"); > } > } >@@ -876,7 +988,7 @@ > public void testChangeExternalLibFolder5() throws CoreException { > try { > createExternalFolder("externalLib/p"); >- IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalFolderPath("externalLib")}, ""); >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib")}, ""); > startDeltas(); > createExternalFile("externalLib/p/test.txt", "test"); > refresh(p); >@@ -888,7 +1000,50 @@ > ); > } finally { > stopDeltas(); >- deleteExternalFolder("externalLib"); >+ deleteExternalResource("externalLib"); >+ deleteProject("P"); >+ } >+} >+ >+/* >+ * Ensures that changing an external ZIP archive referenced by a library entry and refreshing triggers the correct delta >+ */ >+public void testChangeZIPArchive1() throws CoreException { >+ try { >+ createExternalFile("externalLib.abc", ""); >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, ""); >+ refreshExternalArchives(p); >+ startDeltas(); >+ touch(getExternalFile("externalLib.abc")); >+ refreshExternalArchives(p); >+ assertDeltas( >+ "Unexpected delta", >+ "P[*]: {CHILDREN}\n" + >+ " "+ getExternalPath() + "externalLib.abc[*]: {CONTENT | ARCHIVE CONTENT CHANGED}" >+ ); >+ } finally { >+ stopDeltas(); >+ deleteAndRefreshExternalZIPArchive("externalLib.abc", "P"); >+ deleteProject("P"); >+ } >+} >+ >+/* >+ * Ensures that changing an internal ZIP archive referenced by a library entry triggers the correct delta >+ */ >+public void testChangeZIPArchive2() throws CoreException { >+ try { >+ createJavaProject("P", new String[0], new String[] {"/P/internalLib.abc"}, ""); >+ createFile("/P/internalLib.abc", ""); >+ startDeltas(); >+ editFile("/P/internalLib.abc", ""); >+ assertDeltas( >+ "Unexpected delta", >+ "P[*]: {CHILDREN}\n" + >+ " internalLib.abc[*]: {CONTENT | ARCHIVE CONTENT CHANGED}" >+ ); >+ } finally { >+ stopDeltas(); > deleteProject("P"); > } > } >@@ -901,7 +1056,7 @@ > createExternalFolder("externalLib"); > createExternalFolder("externalSrc"); > IJavaProject project = createJavaProject("P"); >- addLibraryEntry(project, getExternalFolderPath("externalLib"), getExternalFolderPath("externalSrc")); >+ addLibraryEntry(project, getExternalResourcePath("externalLib"), getExternalResourcePath("externalSrc")); > startDeltas(); > createExternalFile("externalSrc/X.java", "public class X {}"); > refresh(project); >@@ -912,8 +1067,8 @@ > ); > } finally { > stopDeltas(); >- deleteExternalFolder("externalLib"); >- deleteExternalFolder("externalSrc"); >+ deleteExternalResource("externalLib"); >+ deleteExternalResource("externalSrc"); > deleteProject("P"); > } > } >@@ -2286,7 +2441,7 @@ > public void testRemoveExternalLibFolder1() throws CoreException { > try { > createExternalFolder("externalLib"); >- IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalFolderPath("externalLib")}, ""); >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib")}, ""); > startDeltas(); > setClasspath(p, new IClasspathEntry[] {}); > assertDeltas( >@@ -2297,7 +2452,7 @@ > ); > } finally { > stopDeltas(); >- deleteExternalFolder("externalLib"); >+ deleteExternalResource("externalLib"); > deleteProject("P"); > } > } >@@ -2307,7 +2462,7 @@ > */ > public void testRemoveExternalLibFolder2() throws CoreException { > try { >- IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalFolderPath("externalLib")}, ""); >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib")}, ""); > startDeltas(); > setClasspath(p, new IClasspathEntry[] {}); > assertDeltas( >@@ -2327,9 +2482,9 @@ > public void testRemoveExternalLibFolder3() throws CoreException { > try { > createExternalFolder("externalLib"); >- IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalFolderPath("externalLib")}, ""); >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib")}, ""); > startDeltas(); >- deleteExternalFolder("externalLib"); >+ deleteExternalResource("externalLib"); > refresh(p); > assertDeltas( > "Unexpected delta", >@@ -2338,7 +2493,7 @@ > ); > } finally { > stopDeltas(); >- deleteExternalFolder("externalLib"); >+ deleteExternalResource("externalLib"); > deleteProject("P"); > } > } >@@ -2351,9 +2506,9 @@ > try { > simulateExitRestart(); > createExternalFolder("externalLib"); >- IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalFolderPath("externalLib")}, ""); >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib")}, ""); > startDeltas(); >- deleteExternalFolder("externalLib"); >+ deleteExternalResource("externalLib"); > refresh(p); > assertDeltas( > "Unexpected delta", >@@ -2362,7 +2517,113 @@ > ); > } finally { > stopDeltas(); >- deleteExternalFolder("externalLib"); >+ deleteExternalResource("externalLib"); >+ deleteProject("P"); >+ } >+} >+ >+/* >+ * Ensures that removing a library entry for an existing external ZIP archive triggers the correct delta >+ */ >+public void testRemoveZIPArchive1() throws CoreException { >+ try { >+ createExternalFile("externalLib.abc", ""); >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, ""); >+ startDeltas(); >+ setClasspath(p, new IClasspathEntry[] {}); >+ assertDeltas( >+ "Unexpected delta", >+ "P[*]: {CHILDREN | CONTENT | RAW CLASSPATH CHANGED | RESOLVED CLASSPATH CHANGED}\n" + >+ " "+ getExternalPath() + "externalLib.abc[*]: {REMOVED FROM CLASSPATH}\n" + >+ " ResourceDelta(/P/.classpath)[*]" >+ ); >+ } finally { >+ stopDeltas(); >+ deleteAndRefreshExternalZIPArchive("externalLib.abc", "P"); >+ deleteProject("P"); >+ } >+} >+ >+/* >+ * Ensures that removing a library entry for a non-existing external ZIP archive triggers the correct delta >+ */ >+public void testRemoveZIPArchive2() throws CoreException { >+ try { >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, ""); >+ startDeltas(); >+ setClasspath(p, new IClasspathEntry[] {}); >+ assertDeltas( >+ "Unexpected delta", >+ "P[*]: {CHILDREN | CONTENT | RAW CLASSPATH CHANGED | RESOLVED CLASSPATH CHANGED}\n" + >+ " "+ getExternalPath() + "externalLib.abc[*]: {REMOVED FROM CLASSPATH}\n" + >+ " ResourceDelta(/P/.classpath)[*]" ); >+ } finally { >+ stopDeltas(); >+ deleteProject("P"); >+ } >+} >+ >+/* >+ * Ensures that removing an external ZIP archive referenced by a library entry triggers the correct delta >+ */ >+public void testRemoveZIPArchive3() throws CoreException { >+ try { >+ createExternalFile("externalLib.abc", ""); >+ createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, ""); >+ startDeltas(); >+ deleteAndRefreshExternalZIPArchive("externalLib.abc", "P"); >+ assertDeltas( >+ "Unexpected delta", >+ "P[*]: {CHILDREN}\n" + >+ " "+ getExternalPath() + "externalLib.abc[-]: {}" >+ ); >+ } finally { >+ stopDeltas(); >+ deleteAndRefreshExternalZIPArchive("externalLib.abc", "P"); >+ deleteProject("P"); >+ } >+} >+ >+/* >+ * Ensures that removing an external ZIP archive referenced by a library entry after a restart >+ * triggers the correct delta >+ */ >+public void testRemoveZIPArchive4() throws CoreException { >+ try { >+ simulateExitRestart(); >+ createExternalFile("externalLib.abc", ""); >+ createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, ""); >+ startDeltas(); >+ deleteAndRefreshExternalZIPArchive("externalLib.abc", "P"); >+ assertDeltas( >+ "Unexpected delta", >+ "P[*]: {CHILDREN}\n" + >+ " "+ getExternalPath() + "externalLib.abc[-]: {}" >+ ); >+ } finally { >+ stopDeltas(); >+ deleteAndRefreshExternalZIPArchive("externalLib.abc", "P"); >+ deleteProject("P"); >+ } >+} >+ >+/* >+ * Ensures that removing a library entry for an existing internal ZIP archive triggers the correct delta >+ */ >+public void testRemoveZIPArchive5() throws CoreException { >+ try { >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {"/P/internalLib.abc"}, ""); >+ createFile("/P/internalLib.abc", ""); >+ startDeltas(); >+ setClasspath(p, new IClasspathEntry[] {}); >+ assertDeltas( >+ "Unexpected delta", >+ "P[*]: {CHILDREN | CONTENT | RAW CLASSPATH CHANGED | RESOLVED CLASSPATH CHANGED}\n" + >+ " internalLib.abc[*]: {REMOVED FROM CLASSPATH}\n" + >+ " ResourceDelta(/P/.classpath)[*]" >+ ); >+ } finally { >+ stopDeltas(); > deleteProject("P"); > } > } >Index: src/org/eclipse/jdt/core/tests/model/JavaSearchTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchTests.java,v >retrieving revision 1.171 >diff -u -r1.171 JavaSearchTests.java >--- src/org/eclipse/jdt/core/tests/model/JavaSearchTests.java 26 Feb 2008 10:11:57 -0000 1.171 >+++ src/org/eclipse/jdt/core/tests/model/JavaSearchTests.java 18 Apr 2008 14:35:50 -0000 >@@ -528,6 +528,7 @@ > "", > this.resultCollector); > } >+ > /* > * Ensures that a method declaration in an external library folder can be found > */ >@@ -544,9 +545,9 @@ > "}" > }, > new HashMap(), >- getExternalFolderPath("externalLib") >+ getExternalResourcePath("externalLib") > ); >- createJavaProject("P", new String[0], new String[] {getExternalFolderPath("externalLib")}, ""); >+ createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib")}, ""); > IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaProject[] {getJavaProject("P")}); > search("foo", METHOD, DECLARATIONS, scope); > assertSearchResults( >@@ -554,7 +555,7 @@ > this.resultCollector); > } finally { > deleteProject("P"); >- deleteExternalFolder("externalLib"); >+ deleteExternalResource("externalLib"); > } > } > >@@ -572,9 +573,9 @@ > "}" > }, > new HashMap(), >- getExternalFolderPath("externalLib") >+ getExternalResourcePath("externalLib") > ); >- createJavaProject("P", new String[0], new String[] {getExternalFolderPath("externalLib")}, ""); >+ createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib")}, ""); > > TypeNameMatchCollector collector = new TypeNameMatchCollector(); > new SearchEngine(this.workingCopies).searchAllTypeNames( >@@ -594,10 +595,79 @@ > ); > } finally { > deleteProject("P"); >- deleteExternalFolder("externalLib"); >+ deleteExternalResource("externalLib"); > } > > } >+ >+/* >+ * Ensures that a method declaration in an external ZIP archive can be found >+ */ >+public void testZIPArchive1() throws Exception { >+ try { >+ org.eclipse.jdt.core.tests.util.Util.createJar( >+ new String[] { >+ "p/X.java", >+ "package p;\n" + >+ "public class X {\n" + >+ " public void foo() {\n" + >+ " }\n" + >+ "}" >+ }, >+ getExternalResourcePath("externalLib.abc"), >+ "1.4"); >+ createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, ""); >+ IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaProject[] {getJavaProject("P")}); >+ search("foo", METHOD, DECLARATIONS, scope); >+ assertSearchResults( >+ getExternalPath() + "externalLib.abc void p.X.foo()", >+ this.resultCollector); >+ } finally { >+ deleteAndRefreshExternalZIPArchive("externalLib.abc", "P"); >+ deleteProject("P"); >+ } >+} >+ >+/* >+ * Ensures that search all type names returns the types in an external ZIP archive >+ */ >+public void testZIPArchive2() throws Exception { >+ try { >+ IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, ""); >+ org.eclipse.jdt.core.tests.util.Util.createJar( >+ new String[] { >+ "p/ExternalType.java", >+ "package p;\n" + >+ "public class ExternalType {\n" + >+ "}" >+ }, >+ getExternalResourcePath("externalLib.abc"), >+ "1.4"); >+ refreshExternalArchives(p); >+ >+ TypeNameMatchCollector collector = new TypeNameMatchCollector(); >+ new SearchEngine(this.workingCopies).searchAllTypeNames( >+ null, >+ SearchPattern.R_EXACT_MATCH, >+ "ExternalType".toCharArray(), >+ SearchPattern.R_EXACT_MATCH, >+ TYPE, >+ SearchEngine.createJavaSearchScope(new IJavaProject[] {getJavaProject("P")}), >+ collector, >+ IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, >+ null >+ ); >+ assertSearchResults( >+ "ExternalType (not open) [in ExternalType.class [in p [in "+ getExternalPath() + "externalLib.abc]]]", >+ collector >+ ); >+ } finally { >+ deleteAndRefreshExternalZIPArchive("externalLib.abc", "P"); >+ deleteProject("P"); >+ } >+ >+} >+ > /** > * Simple field declaration test. > */ >Index: src/org/eclipse/jdt/core/tests/model/ClassFileTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClassFileTests.java,v >retrieving revision 1.36 >diff -u -r1.36 ClassFileTests.java >--- src/org/eclipse/jdt/core/tests/model/ClassFileTests.java 6 Apr 2008 17:15:58 -0000 1.36 >+++ src/org/eclipse/jdt/core/tests/model/ClassFileTests.java 18 Apr 2008 14:35:47 -0000 >@@ -16,6 +16,7 @@ > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IPath; > import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.Path; > import org.eclipse.jdt.core.*; > import org.eclipse.jdt.core.search.IJavaSearchConstants; > import org.eclipse.jdt.core.search.IJavaSearchScope; >@@ -790,14 +791,14 @@ > try { > createExternalFolder("externalLib/p"); > createExternalFile("externalLib/p/X.class", ""); >- createJavaProject("P1", new String[0], new String[] {getExternalFolderPath("externalLib")}, ""); >- IClassFile classFile1 = getClassFile("P1", getExternalFolderPath("externalLib"), "p", "X.class"); >+ createJavaProject("P1", new String[0], new String[] {getExternalResourcePath("externalLib")}, ""); >+ IClassFile classFile1 = getClassFile("P1", getExternalResourcePath("externalLib"), "p", "X.class"); > assertResourceEquals( > "Unexpected resource", > "<null>", > classFile1.getResource()); > } finally { >- deleteExternalFolder("externalLib"); >+ deleteExternalResource("externalLib"); > deleteProject("P1"); > } > } >@@ -852,7 +853,7 @@ > } catch (JavaModelException e) { > expected = e; > } >- assertExceptionEquals("Unexpected exception", "classFolder.jar [in P1] does not exist", expected); >+ assertExceptionEquals("Unexpected exception", new Path("/P1/classFolder.jar").toOSString() + " does not exist", expected); > } finally { > deleteProject("P1"); > } >Index: src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java,v >retrieving revision 1.207 >diff -u -r1.207 AbstractJavaModelTests.java >--- src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java 5 Apr 2008 08:45:19 -0000 1.207 >+++ src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java 18 Apr 2008 14:35:47 -0000 >@@ -1467,10 +1467,10 @@ > getWorkspace().run(create, null); > return project; > } >- public void deleteFile(File file) { >+ public void deleteResource(File resource) { > int retryCount = 0; > while (++retryCount <= 60) { // wait 1 minute at most >- if (org.eclipse.jdt.core.tests.util.Util.delete(file)) { >+ if (org.eclipse.jdt.core.tests.util.Util.delete(resource)) { > break; > } > } >@@ -1649,7 +1649,7 @@ > return new File(getExternalPath(), relativePath); > } > >- protected String getExternalFolderPath(String name) { >+ protected String getExternalResourcePath(String name) { > return getExternalPath() + name; > } > >@@ -2029,6 +2029,10 @@ > waitForManualRefresh(); > } > >+ protected void refreshExternalArchives(IJavaProject p) throws JavaModelException { >+ getJavaModel().refreshExternalArchives(new IJavaElement[] {p}, null); >+ } >+ > protected void removeJavaNature(String projectName) throws CoreException { > IProject project = this.getProject(projectName); > IProjectDescription description = project.getDescription(); >@@ -2658,10 +2662,17 @@ > } > return result; > } >- protected void touch(File f) { >- f.setLastModified(f.lastModified() + 10000); >+ protected synchronized void touch(File f) { >+ f.setLastModified(f.lastModified() + 1000); >+ long start = System.currentTimeMillis(); >+ do { >+ try { >+ wait(1000); >+ } catch (InterruptedException e) { >+ } >+ } while ((System.currentTimeMillis() - start) < 1000); > } >-protected String toString(String[] strings) { >+ protected String toString(String[] strings) { > return toString(strings, false/*don't add extra new line*/); > } > protected String toString(String[] strings, boolean addExtraNewLine) { >#P org.eclipse.jdt.core.tests.builder >Index: src/org/eclipse/jdt/core/tests/builder/TestingEnvironment.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/TestingEnvironment.java,v >retrieving revision 1.60 >diff -u -r1.60 TestingEnvironment.java >--- src/org/eclipse/jdt/core/tests/builder/TestingEnvironment.java 19 Mar 2008 16:20:47 -0000 1.60 >+++ src/org/eclipse/jdt/core/tests/builder/TestingEnvironment.java 18 Apr 2008 14:35:53 -0000 >@@ -257,7 +257,6 @@ > public void addExternalJars(IPath projectPath, String[] jars, boolean isExported) throws JavaModelException { > for (int i = 0, max = jars.length; i < max; i++) { > String jar = jars[i]; >- checkAssertion("file name must end with .zip or .jar", jar.endsWith(".zip") || jar.endsWith(".jar")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ > addEntry(projectPath, JavaCore.newLibraryEntry(new Path(jar), null, null, isExported)); > } > } >@@ -265,7 +264,6 @@ > /** Adds an external jar to the classpath of a project. > */ > public void addExternalJar(IPath projectPath, String jar, boolean isExported) throws JavaModelException { >- checkAssertion("file name must end with .zip or .jar", jar.endsWith(".zip") || jar.endsWith(".jar")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ > addEntry(projectPath, JavaCore.newLibraryEntry(new Path(jar), null, null, isExported)); > } > >@@ -274,7 +272,7 @@ > addEntry(projectPath, > JavaCore.newLibraryEntry(libraryPath, sourceAttachmentPath, sourceAttachmentRootPath)); > } >- private void addEntry(IPath projectPath, IClasspathEntry entryPath) throws JavaModelException { >+ public void addEntry(IPath projectPath, IClasspathEntry entryPath) throws JavaModelException { > IClasspathEntry[] classpath = getClasspath(projectPath); > IClasspathEntry[] newClaspath = new IClasspathEntry[classpath.length + 1]; > System.arraycopy(classpath, 0, newClaspath, 0, classpath.length); >@@ -311,13 +309,11 @@ > > /** Adds a jar with the given contents to the the workspace. > * If a jar with the same name already exists, it is >- * replaced. A workspace must be open, and the given >- * zip name must end with ".zip" or ".jar". Returns the path of >+ * replaced. A workspace must be open. Returns the path of > * the added jar. > */ > public IPath addInternalJar(IPath projectPath, String zipName, byte[] contents, boolean isExported) throws JavaModelException { > checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$ >- checkAssertion("zipName must end with .zip or .jar", zipName.endsWith(".zip") || zipName.endsWith(".jar")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ > IPath path = projectPath.append(zipName); > > /* remove any existing zip from the java model */ >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.46 >diff -u -r1.46 BuildpathTests.java >--- src/org/eclipse/jdt/core/tests/builder/BuildpathTests.java 19 Mar 2008 16:20:47 -0000 1.46 >+++ src/org/eclipse/jdt/core/tests/builder/BuildpathTests.java 18 Apr 2008 14:35:53 -0000 >@@ -259,7 +259,7 @@ > } > > /* >- * Ensures that the changing a type in an external folder and refreshing triggers a rebuild >+ * Ensures that changing a type in an external folder and refreshing triggers a rebuild > */ > public void testChangeExternalFolder() throws CoreException { > String externalLib = Util.getOutputDirectory() + File.separator + "externalLib"; >@@ -329,6 +329,133 @@ > } > > /* >+ * Ensures that changing a type in an external ZIP archive and refreshing triggers a rebuild >+ */ >+public void testChangeZIPArchive1() throws Exception { >+ String externalLib = Util.getOutputDirectory() + File.separator + "externalLib.abc"; >+ try { >+ org.eclipse.jdt.core.tests.util.Util.createJar( >+ new String[] { >+ "p/X.java", >+ "package p;\n" + >+ "public class X {\n" + >+ " public void foo() {\n" + >+ " }\n" + >+ "}" >+ }, >+ externalLib, >+ "1.4"); >+ >+ IPath projectPath = env.addProject("Project"); >+ env.addExternalJars(projectPath, Util.getJavaClassLibs()); >+ env.addExternalJars(projectPath, new String[] {externalLib}); >+ >+ IPath root = env.getPackageFragmentRootPath(projectPath, ""); //$NON-NLS-1$ >+ env.setOutputFolder(projectPath, ""); >+ >+ IPath classY = env.addClass(root, "q", "Y", >+ "package q;\n"+ >+ "public class Y {\n" + >+ " void bar(p.X x) {\n" + >+ " x.foo();\n" + >+ " }\n" + >+ "}" >+ ); >+ >+ fullBuild(projectPath); >+ expectingNoProblems(); >+ >+ long lastModified = new java.io.File(externalLib).lastModified(); >+ try { >+ Thread.sleep(1000); >+ } catch(InterruptedException e) { >+ } >+ org.eclipse.jdt.core.tests.util.Util.createJar( >+ new String[] { >+ "p/X.java", >+ "package p;\n" + >+ "public class X {\n" + >+ "}" >+ }, >+ externalLib, >+ "1.4"); >+ new java.io.File(externalLib).setLastModified(lastModified + 1000); // to be sure its different >+ >+ IJavaProject p = env.getJavaProject(projectPath); >+ p.getJavaModel().refreshExternalArchives(new IJavaElement[] {p}, null); >+ >+ incrementalBuild(projectPath); >+ expectingProblemsFor( >+ classY, >+ "Problem : The method foo() is undefined for the type X [ resource : </Project/q/Y.java> range : <54,57> category : <50> severity : <2>]" >+ ); >+ } finally { >+ new File(externalLib).delete(); >+ } >+} >+ >+/* >+ * Ensures that changing a type in an internal ZIP archive and refreshing triggers a rebuild >+ */ >+public void testChangeZIPArchive2() throws Exception { >+ IPath projectPath = env.addProject("Project"); >+ String internalLib = env.getProject("Project").getLocation().toOSString() + File.separator + "internalLib.abc"; >+ env.addExternalJars(projectPath, Util.getJavaClassLibs()); >+ env.addEntry(projectPath, JavaCore.newLibraryEntry(new Path("/Project/internalLib.abc"), null, null)); >+ org.eclipse.jdt.core.tests.util.Util.createJar( >+ new String[] { >+ "p/X.java", >+ "package p;\n" + >+ "public class X {\n" + >+ " public void foo() {\n" + >+ " }\n" + >+ "}" >+ }, >+ internalLib, >+ "1.4"); >+ env.getProject(projectPath).refreshLocal(IResource.DEPTH_INFINITE, null); >+ >+ IPath root = env.getPackageFragmentRootPath(projectPath, ""); //$NON-NLS-1$ >+ env.setOutputFolder(projectPath, ""); >+ >+ IPath classY = env.addClass(root, "q", "Y", >+ "package q;\n"+ >+ "public class Y {\n" + >+ " void bar(p.X x) {\n" + >+ " x.foo();\n" + >+ " }\n" + >+ "}" >+ ); >+ >+ fullBuild(projectPath); >+ expectingNoProblems(); >+ >+ long lastModified = new java.io.File(internalLib).lastModified(); >+ try { >+ Thread.sleep(1000); >+ } catch(InterruptedException e) { >+ } >+ org.eclipse.jdt.core.tests.util.Util.createJar( >+ new String[] { >+ "p/X.java", >+ "package p;\n" + >+ "public class X {\n" + >+ "}" >+ }, >+ internalLib, >+ "1.4"); >+ new java.io.File(internalLib).setLastModified(lastModified + 1000); // to be sure its different >+ >+ env.getProject(projectPath).refreshLocal(IResource.DEPTH_INFINITE, null); >+ >+ incrementalBuild(projectPath); >+ expectingProblemsFor( >+ classY, >+ "Problem : The method foo() is undefined for the type X [ resource : </Project/q/Y.java> range : <54,57> category : <50> severity : <2>]" >+ ); >+} >+ >+/* > * Ensures that changing an external jar and refreshing the projects triggers a rebuild > * (regression test for bug 50207 Compile errors fixed by 'refresh' do not reset problem list or package explorer error states) > */
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 182360
: 96606