View | Details | Raw Unified | Return to bug 229042 | Differences between
and this patch

Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/ClasspathEntry.java (-7 / +35 lines)
Lines 2063-2068 Link Here
2063
								return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundSourceAttachment, new String [] {sourceAttachment.toString(), path.toString(), project.getElementName()}));
2063
								return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundSourceAttachment, new String [] {sourceAttachment.toString(), path.toString(), project.getElementName()}));
2064
							}
2064
							}
2065
						}
2065
						}
2066
						// https://bugs.eclipse.org/bugs/show_bug.cgi?id=229042
2067
						// Validate the contents of the archive
2068
						IJavaModelStatus status = validateLibraryContents(path, project, entryPathMsg);
2069
						if (status != JavaModelStatus.VERIFIED_OK) 
2070
							return status;
2066
						break;
2071
						break;
2067
					case IResource.FOLDER :	// internal binary folder
2072
					case IResource.FOLDER :	// internal binary folder
2068
						if (sourceAttachment != null
2073
						if (sourceAttachment != null
Lines 2083-2095 Link Here
2083
					} else {
2088
					} else {
2084
						return  new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_illegalExternalFolder, new String[] {path.toOSString(), project.getElementName()}));
2089
						return  new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_illegalExternalFolder, new String[] {path.toOSString(), project.getElementName()}));
2085
					}
2090
					}
2086
				} else if (sourceAttachment != null
2091
				} else {
2087
						&& !sourceAttachment.isEmpty()
2092
					if (sourceAttachment != null
2088
						&& JavaModel.getTarget(sourceAttachment, true) == null){
2093
							&& !sourceAttachment.isEmpty()
2089
					if (container != null) {
2094
							&& JavaModel.getTarget(sourceAttachment, true) == null){
2090
						return  new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundSourceAttachmentInContainedLibrary, new String [] {sourceAttachment.toString(), path.toOSString(), container}));
2095
						if (container != null) {
2091
					} else {
2096
							return  new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundSourceAttachmentInContainedLibrary, new String [] {sourceAttachment.toString(), path.toOSString(), container}));
2092
						return  new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundSourceAttachment, new String [] {sourceAttachment.toString(), path.toOSString(), project.getElementName()}));
2097
						} else {
2098
							return  new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundSourceAttachment, new String [] {sourceAttachment.toString(), path.toOSString(), project.getElementName()}));
2099
						}
2100
					}
2101
					// https://bugs.eclipse.org/bugs/show_bug.cgi?id=229042
2102
					// Validate the contents of the archive
2103
					if(file.isFile()) {
2104
						IJavaModelStatus status = validateLibraryContents(path, project, entryPathMsg);
2105
						if (status != JavaModelStatus.VERIFIED_OK) 
2106
							return status;
2093
					}
2107
					}
2094
				}
2108
				}
2095
			} else {
2109
			} else {
Lines 2121-2124 Link Here
2121
		}
2135
		}
2122
		return JavaModelStatus.VERIFIED_OK;
2136
		return JavaModelStatus.VERIFIED_OK;
2123
	}
2137
	}
2138
2139
	private static IJavaModelStatus validateLibraryContents(IPath path, IJavaProject project, String entryPathMsg) {
2140
		JavaModelManager manager = JavaModelManager.getJavaModelManager();
2141
		try {
2142
			manager.verifyArchiveContent(path);
2143
		} catch (CoreException e) {
2144
			if (e.getStatus().getMessage() == Messages.status_IOException) {
2145
				return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(
2146
						Messages.classpath_illegalLibraryArchive,
2147
						new String[] {entryPathMsg, project.getElementName()}));
2148
			}
2149
		}
2150
		return JavaModelStatus.VERIFIED_OK;
2151
	}
2124
}
2152
}
(-)model/org/eclipse/jdt/internal/core/DeltaProcessor.java (-1 / +5 lines)
Lines 2271-2277 Link Here
2271
				/* check classpath or prefs files change */
2271
				/* check classpath or prefs files change */
2272
				IFile file = (IFile) resource;
2272
				IFile file = (IFile) resource;
2273
				String fileName = file.getName();
2273
				String fileName = file.getName();
2274
				if (fileName.equals(JavaProject.CLASSPATH_FILENAME)) {
2274
				RootInfo rootInfo = null;
2275
				// https://bugs.eclipse.org/bugs/show_bug.cgi?id=229042
2276
				// Mark a validation if a library with package fragment root in the project has changed
2277
				if (fileName.equals(JavaProject.CLASSPATH_FILENAME)
2278
						|| ((rootInfo = rootInfo(file.getFullPath(), delta.getKind())) != null && rootInfo.entryKind == IClasspathEntry.CPE_LIBRARY)) {
2275
					JavaProject javaProject = (JavaProject)JavaCore.create(file.getProject());
2279
					JavaProject javaProject = (JavaProject)JavaCore.create(file.getProject());
2276
					this.state.addClasspathValidation(javaProject);
2280
					this.state.addClasspathValidation(javaProject);
2277
					affectedProjects.add(file.getProject().getFullPath());
2281
					affectedProjects.add(file.getProject().getFullPath());
(-)model/org/eclipse/jdt/internal/core/JarPackageFragmentRoot.java (-1 / +2 lines)
Lines 18-23 Link Here
18
import org.eclipse.core.resources.IResource;
18
import org.eclipse.core.resources.IResource;
19
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.IPath;
20
import org.eclipse.core.runtime.IPath;
21
import org.eclipse.core.runtime.IStatus;
21
import org.eclipse.jdt.core.*;
22
import org.eclipse.jdt.core.*;
22
import org.eclipse.jdt.core.compiler.CharOperation;
23
import org.eclipse.jdt.core.compiler.CharOperation;
23
import org.eclipse.jdt.internal.core.util.HashtableOfArrayToObject;
24
import org.eclipse.jdt.internal.core.util.HashtableOfArrayToObject;
Lines 97-103 Link Here
97
		} catch (CoreException e) {
98
		} catch (CoreException e) {
98
			if (e.getCause() instanceof ZipException) {
99
			if (e.getCause() instanceof ZipException) {
99
				// not a ZIP archive, leave the children empty
100
				// not a ZIP archive, leave the children empty
100
				Util.log(e, "Invalid ZIP archive: " + toStringWithAncestors()); //$NON-NLS-1$
101
				Util.log(IStatus.ERROR, "Invalid ZIP archive: " + toStringWithAncestors()); //$NON-NLS-1$
101
				children = NO_ELEMENTS;
102
				children = NO_ELEMENTS;
102
			} else if (e instanceof JavaModelException) {
103
			} else if (e instanceof JavaModelException) {
103
				throw (JavaModelException)e;
104
				throw (JavaModelException)e;
(-)model/org/eclipse/jdt/internal/core/JavaModelManager.java (-24 / +72 lines)
Lines 18-23 Link Here
18
import java.text.MessageFormat;
18
import java.text.MessageFormat;
19
import java.util.*;
19
import java.util.*;
20
import java.util.Map.Entry;
20
import java.util.Map.Entry;
21
import java.util.zip.ZipException;
21
import java.util.zip.ZipFile;
22
import java.util.zip.ZipFile;
22
23
23
import javax.xml.parsers.DocumentBuilder;
24
import javax.xml.parsers.DocumentBuilder;
Lines 82-87 Link Here
82
 */
83
 */
83
public class JavaModelManager implements ISaveParticipant, IContentTypeChangeListener {
84
public class JavaModelManager implements ISaveParticipant, IContentTypeChangeListener {
84
85
86
	private static final String NON_CHAINING_JARS_CACHE = "nonChainingJarsCache"; //$NON-NLS-1$
87
	private static final String INVALID_ARCHIVES_CACHE = "invalidArchivesCache";  //$NON-NLS-1$
88
85
	/**
89
	/**
86
	 * Define a zip cache object.
90
	 * Define a zip cache object.
87
	 */
91
	 */
Lines 1171-1178 Link Here
1171
		}
1175
		}
1172
1176
1173
		public synchronized ClasspathChange resetResolvedClasspath() {
1177
		public synchronized ClasspathChange resetResolvedClasspath() {
1174
			// clear non-chaining jars cache
1178
			// clear non-chaining jars cache and invalid jars cache
1175
			JavaModelManager.getJavaModelManager().resetNonChainingJarsCache();
1179
			JavaModelManager.getJavaModelManager().resetClasspathListCache();
1176
			
1180
			
1177
			// null out resolved information
1181
			// null out resolved information
1178
			return setResolvedClasspath(null, null, null, null, this.rawTimeStamp, true/*add classpath change*/);
1182
			return setResolvedClasspath(null, null, null, null, this.rawTimeStamp, true/*add classpath change*/);
Lines 1418-1423 Link Here
1418
	 * List of IPath of jars that are known to not contain a chaining (through MANIFEST.MF) to another library
1422
	 * List of IPath of jars that are known to not contain a chaining (through MANIFEST.MF) to another library
1419
	 */
1423
	 */
1420
	private Set nonChainingJars;
1424
	private Set nonChainingJars;
1425
	
1426
	/*
1427
	 * List of IPath of jars that are known to be invalid - such as not being a valid/known format
1428
	 */
1429
	private Set invalidArchives;
1421
1430
1422
	/**
1431
	/**
1423
	 * Update the classpath variable cache
1432
	 * Update the classpath variable cache
Lines 1549-1555 Link Here
1549
		 */
1558
		 */
1550
		if (Platform.isRunning()) {
1559
		if (Platform.isRunning()) {
1551
			this.indexManager = new IndexManager();
1560
			this.indexManager = new IndexManager();
1552
			this.nonChainingJars = loadNonChainingJarsCache();
1561
			this.nonChainingJars = loadClasspathListCache(NON_CHAINING_JARS_CACHE);
1562
			this.invalidArchives = loadClasspathListCache(INVALID_ARCHIVES_CACHE);
1553
			String includeContainerReferencedLib = System.getProperty(RESOLVE_REFERENCED_LIBRARIES_FOR_CONTAINERS);
1563
			String includeContainerReferencedLib = System.getProperty(RESOLVE_REFERENCED_LIBRARIES_FOR_CONTAINERS);
1554
			this.resolveReferencedLibrariesForContainers = TRUE.equalsIgnoreCase(includeContainerReferencedLib);
1564
			this.resolveReferencedLibrariesForContainers = TRUE.equalsIgnoreCase(includeContainerReferencedLib);
1555
		}
1565
		}
Lines 1567-1572 Link Here
1567
		if (this.nonChainingJars != null)
1577
		if (this.nonChainingJars != null)
1568
			this.nonChainingJars.add(path);
1578
			this.nonChainingJars.add(path);
1569
	}
1579
	}
1580
	
1581
	public void addInvalidArchive(IPath path) {
1582
		// unlikely to be null
1583
		if (this.invalidArchives == null) {
1584
			this.invalidArchives = Collections.synchronizedSet(new HashSet());
1585
		}
1586
		if(this.invalidArchives != null) {
1587
			this.invalidArchives.add(path);
1588
		}
1589
	}
1570
1590
1571
	/**
1591
	/**
1572
	 * Starts caching ZipFiles.
1592
	 * Starts caching ZipFiles.
Lines 2545-2550 Link Here
2545
		return this.workspaceScope;
2565
		return this.workspaceScope;
2546
	}
2566
	}
2547
2567
2568
	public void verifyArchiveContent(IPath path) throws CoreException {
2569
		if (isInvalidArchive(path)) {
2570
			throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Messages.status_IOException, new ZipException()));			
2571
		}
2572
		ZipFile file = getZipFile(path);
2573
		closeZipFile(file);
2574
	}
2575
	
2548
	/**
2576
	/**
2549
	 * Returns the open ZipFile at the given path. If the ZipFile
2577
	 * Returns the open ZipFile at the given path. If the ZipFile
2550
	 * does not yet exist, it is created, opened, and added to the cache
2578
	 * does not yet exist, it is created, opened, and added to the cache
Lines 2558-2563 Link Here
2558
	 */
2586
	 */
2559
	public ZipFile getZipFile(IPath path) throws CoreException {
2587
	public ZipFile getZipFile(IPath path) throws CoreException {
2560
2588
2589
		if (isInvalidArchive(path))
2590
			throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Messages.status_IOException, new ZipException()));
2591
		
2561
		ZipCache zipCache;
2592
		ZipCache zipCache;
2562
		ZipFile zipFile;
2593
		ZipFile zipFile;
2563
		if ((zipCache = (ZipCache)this.zipFiles.get()) != null
2594
		if ((zipCache = (ZipCache)this.zipFiles.get()) != null
Lines 2591-2596 Link Here
2591
			}
2622
			}
2592
			return zipFile;
2623
			return zipFile;
2593
		} catch (IOException e) {
2624
		} catch (IOException e) {
2625
			addInvalidArchive(path);
2594
			throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Messages.status_IOException, e));
2626
			throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Messages.status_IOException, e));
2595
		}
2627
		}
2596
	}
2628
	}
Lines 2994-2999 Link Here
2994
	public boolean isNonChainingJar(IPath path) {
3026
	public boolean isNonChainingJar(IPath path) {
2995
		return this.nonChainingJars != null && this.nonChainingJars.contains(path);
3027
		return this.nonChainingJars != null && this.nonChainingJars.contains(path);
2996
	}
3028
	}
3029
	
3030
	public boolean isInvalidArchive(IPath path) {
3031
		return this.invalidArchives != null && this.invalidArchives.contains(path);
3032
	}
2997
3033
2998
	public void setClasspathBeingResolved(IJavaProject project, boolean classpathIsResolved) {
3034
	public void setClasspathBeingResolved(IJavaProject project, boolean classpathIsResolved) {
2999
	    if (classpathIsResolved) {
3035
	    if (classpathIsResolved) {
Lines 3003-3021 Link Here
3003
	    }
3039
	    }
3004
	}
3040
	}
3005
	
3041
	
3006
	private Set loadNonChainingJarsCache() {
3042
	private Set loadClasspathListCache(String cacheName) {
3007
		Set nonChainingJarsCache = new HashSet();
3043
		Set pathCache = new HashSet();
3008
		File nonChainingJarsFile = getNonChainingJarsFile();
3044
		File cacheFile = getClasspathListFile(cacheName);
3009
		DataInputStream in = null;
3045
		DataInputStream in = null;
3010
		try {
3046
		try {
3011
			in = new DataInputStream(new BufferedInputStream(new FileInputStream(nonChainingJarsFile)));
3047
			in = new DataInputStream(new BufferedInputStream(new FileInputStream(cacheFile)));
3012
			int size = in.readInt();
3048
			int size = in.readInt();
3013
			while (size-- > 0) {
3049
			while (size-- > 0) {
3014
				String path = in.readUTF();
3050
				String path = in.readUTF();
3015
				nonChainingJarsCache.add(Path.fromPortableString(path));
3051
				pathCache.add(Path.fromPortableString(path));
3016
			}
3052
			}
3017
		} catch (IOException e) {
3053
		} catch (IOException e) {
3018
			if (nonChainingJarsFile.exists())
3054
			if (cacheFile.exists())
3019
				Util.log(e, "Unable to read non-chaining jar cache file"); //$NON-NLS-1$
3055
				Util.log(e, "Unable to read non-chaining jar cache file"); //$NON-NLS-1$
3020
		} finally {
3056
		} finally {
3021
			if (in != null) {
3057
			if (in != null) {
Lines 3026-3036 Link Here
3026
				}
3062
				}
3027
			}
3063
			}
3028
		}
3064
		}
3029
		return Collections.synchronizedSet(nonChainingJarsCache);
3065
		return Collections.synchronizedSet(pathCache);
3030
	}
3066
	}
3031
3067
	
3032
	private File getNonChainingJarsFile() {
3068
	private File getClasspathListFile(String fileName) {
3033
		return JavaCore.getPlugin().getStateLocation().append("nonChainingJarsCache").toFile(); //$NON-NLS-1$
3069
		return JavaCore.getPlugin().getStateLocation().append(fileName).toFile(); 
3034
	}
3070
	}
3035
	
3071
	
3036
	private Set getNonChainingJarsCache() throws CoreException {
3072
	private Set getNonChainingJarsCache() throws CoreException {
Lines 3057-3063 Link Here
3057
		this.nonChainingJars = Collections.synchronizedSet(result);
3093
		this.nonChainingJars = Collections.synchronizedSet(result);
3058
		return this.nonChainingJars;
3094
		return this.nonChainingJars;
3059
	}
3095
	}
3060
3096
	
3097
	private Set getClasspathListCache(String cacheName) throws CoreException {
3098
		if (cacheName == NON_CHAINING_JARS_CACHE) 
3099
			return getNonChainingJarsCache();
3100
		else if (cacheName == INVALID_ARCHIVES_CACHE)
3101
			return this.invalidArchives;
3102
		else 
3103
			return null;
3104
	}
3105
	
3061
	public void loadVariablesAndContainers() throws CoreException {
3106
	public void loadVariablesAndContainers() throws CoreException {
3062
		// backward compatibility, consider persistent property
3107
		// backward compatibility, consider persistent property
3063
		QualifiedName qName = new QualifiedName(JavaCore.PLUGIN_ID, "variables"); //$NON-NLS-1$
3108
		QualifiedName qName = new QualifiedName(JavaCore.PLUGIN_ID, "variables"); //$NON-NLS-1$
Lines 3734-3740 Link Here
3734
				info.forgetExternalTimestampsAndIndexes();
3779
				info.forgetExternalTimestampsAndIndexes();
3735
			}
3780
			}
3736
		}
3781
		}
3737
		resetNonChainingJarsCache();
3782
		resetClasspathListCache();
3738
	}
3783
	}
3739
3784
3740
	/*
3785
	/*
Lines 3776-3784 Link Here
3776
		this.cache.resetJarTypeCache();
3821
		this.cache.resetJarTypeCache();
3777
	}
3822
	}
3778
	
3823
	
3779
	public void resetNonChainingJarsCache() {
3824
	public void resetClasspathListCache() {
3780
		if (this.nonChainingJars != null) 
3825
		if (this.nonChainingJars != null) 
3781
			this.nonChainingJars.clear();
3826
			this.nonChainingJars.clear();
3827
		if (this.invalidArchives != null) 
3828
			this.invalidArchives.clear();
3782
	}
3829
	}
3783
3830
3784
	/*
3831
	/*
Lines 3852-3866 Link Here
3852
		}
3899
		}
3853
	}
3900
	}
3854
3901
3855
	private void saveNonChainingJarsCache() throws CoreException {
3902
	private void saveClasspathListCache(String cacheName) throws CoreException {
3856
		File file = getNonChainingJarsFile();
3903
		File file = getClasspathListFile(cacheName);
3857
		DataOutputStream out = null;
3904
		DataOutputStream out = null;
3858
		try {
3905
		try {
3859
			out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file)));
3906
			out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file)));
3860
			Set nonChainingJarsCache = getNonChainingJarsCache();
3907
			Set pathCache = getClasspathListCache(cacheName);
3861
			synchronized (nonChainingJarsCache) {
3908
			synchronized (pathCache) {
3862
				out.writeInt(nonChainingJarsCache.size());
3909
				out.writeInt(pathCache.size());
3863
				Iterator entries = nonChainingJarsCache.iterator();
3910
				Iterator entries = pathCache.iterator();
3864
				while (entries.hasNext()) {
3911
				while (entries.hasNext()) {
3865
					IPath path = (IPath) entries.next();
3912
					IPath path = (IPath) entries.next();
3866
					out.writeUTF(path.toPortableString());
3913
					out.writeUTF(path.toPortableString());
Lines 4139-4146 Link Here
4139
4186
4140
		switch(context.getKind()) {
4187
		switch(context.getKind()) {
4141
			case ISaveContext.FULL_SAVE : {
4188
			case ISaveContext.FULL_SAVE : {
4142
				// save non-chaining jar cache on snapshot/full save
4189
				// save non-chaining jar and invalid jar caches on full save
4143
				saveNonChainingJarsCache();
4190
				saveClasspathListCache(NON_CHAINING_JARS_CACHE);
4191
				saveClasspathListCache(INVALID_ARCHIVES_CACHE);
4144
	
4192
	
4145
				// will need delta since this save (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=38658)
4193
				// will need delta since this save (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=38658)
4146
				context.needDelta();
4194
				context.needDelta();
(-)src/org/eclipse/jdt/core/tests/builder/BuildpathTests.java (-3 / +23 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 13-18 Link Here
13
import junit.framework.*;
13
import junit.framework.*;
14
14
15
import org.eclipse.core.resources.IMarker;
15
import org.eclipse.core.resources.IMarker;
16
import org.eclipse.core.resources.IProject;
16
import org.eclipse.core.resources.IResource;
17
import org.eclipse.core.resources.IResource;
17
import org.eclipse.core.resources.ResourcesPlugin;
18
import org.eclipse.core.resources.ResourcesPlugin;
18
import org.eclipse.core.runtime.*;
19
import org.eclipse.core.runtime.*;
Lines 25-30 Link Here
25
import org.eclipse.jdt.internal.core.*;
26
import org.eclipse.jdt.internal.core.*;
26
27
27
import java.io.File;
28
import java.io.File;
29
import java.io.FileInputStream;
28
import java.io.IOException;
30
import java.io.IOException;
29
import java.util.*;
31
import java.util.*;
30
32
Lines 103-112 Link Here
103
	}
105
	}
104
}
106
}
105
107
106
public void testClosedProject() throws JavaModelException {
108
public void testClosedProject() throws JavaModelException, IOException {
107
	IPath project1Path = env.addProject("CP1"); //$NON-NLS-1$
109
	IPath project1Path = env.addProject("CP1"); //$NON-NLS-1$
110
	IProject project1 = ResourcesPlugin.getWorkspace().getRoot().getProject("CP1");
108
	env.addExternalJars(project1Path, Util.getJavaClassLibs());
111
	env.addExternalJars(project1Path, Util.getJavaClassLibs());
109
	IPath jarPath = env.addInternalJar(project1Path, "temp.jar", new byte[] {0}); //$NON-NLS-1$
112
	
113
	String jarFile = project1.getLocation().toOSString() + File.separator + "temp.jar";
114
	
115
	org.eclipse.jdt.core.tests.util.Util.createJar(
116
			null,
117
			new String[] {
118
				"META-INF/MANIFEST.MF",
119
				"Manifest-Version: 1.0\n",
120
			},
121
			jarFile,
122
			null,
123
			JavaCore.VERSION_1_4);
124
125
	FileInputStream fis = new FileInputStream(jarFile);
126
	int length = fis.available();
127
	byte[] jarContent = new byte[length];
128
	fis.read(jarContent); 
129
	IPath jarPath = env.addInternalJar(project1Path, "temp.jar", jarContent); //$NON-NLS-1$
110
130
111
	IPath project2Path = env.addProject("CP2"); //$NON-NLS-1$
131
	IPath project2Path = env.addProject("CP2"); //$NON-NLS-1$
112
	env.addExternalJars(project2Path, Util.getJavaClassLibs());
132
	env.addExternalJars(project2Path, Util.getJavaClassLibs());
(-)src/org/eclipse/jdt/core/tests/util/Util.java (-1 / +12 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 341-346 Link Here
341
    flushDirectoryContent(classesDir);
341
    flushDirectoryContent(classesDir);
342
    compile(pathsAndContents, getCompileOptions(compliance), folderPath);
342
    compile(pathsAndContents, getCompileOptions(compliance), folderPath);
343
}
343
}
344
public static void createEmptyJar(String jarPath, String compliance) throws IOException {
345
	org.eclipse.jdt.core.tests.util.Util.createJar(
346
			null,
347
			new String[] {
348
				"META-INF/MANIFEST.MF",
349
				"Manifest-Version: 1.0\n",
350
			},
351
			jarPath,
352
			null,
353
			compliance);	
354
}
344
public static void createJar(String[] pathsAndContents, Map options, String jarPath) throws IOException {
355
public static void createJar(String[] pathsAndContents, Map options, String jarPath) throws IOException {
345
	createJar(pathsAndContents, null, options, null, jarPath);
356
	createJar(pathsAndContents, null, options, null, jarPath);
346
}
357
}
(-)src/org/eclipse/jdt/core/tests/model/AttachSourceTests.java (-3 / +20 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 14-19 Link Here
14
import java.io.IOException;
14
import java.io.IOException;
15
15
16
import junit.framework.Test;
16
import junit.framework.Test;
17
17
import org.eclipse.core.resources.IFile;
18
import org.eclipse.core.resources.IFile;
18
import org.eclipse.core.resources.IFolder;
19
import org.eclipse.core.resources.IFolder;
19
import org.eclipse.core.resources.IProject;
20
import org.eclipse.core.resources.IProject;
Lines 22-31 Link Here
22
import org.eclipse.core.runtime.CoreException;
23
import org.eclipse.core.runtime.CoreException;
23
import org.eclipse.core.runtime.IPath;
24
import org.eclipse.core.runtime.IPath;
24
import org.eclipse.core.runtime.Path;
25
import org.eclipse.core.runtime.Path;
25
import org.eclipse.jdt.core.*;
26
import org.eclipse.jdt.core.IBuffer;
26
import org.eclipse.jdt.core.dom.*;
27
import org.eclipse.jdt.core.IClassFile;
28
import org.eclipse.jdt.core.IJavaElement;
29
import org.eclipse.jdt.core.IJavaProject;
30
import org.eclipse.jdt.core.IMember;
31
import org.eclipse.jdt.core.IMethod;
32
import org.eclipse.jdt.core.IPackageFragment;
33
import org.eclipse.jdt.core.IPackageFragmentRoot;
34
import org.eclipse.jdt.core.ISourceRange;
35
import org.eclipse.jdt.core.IType;
36
import org.eclipse.jdt.core.JavaCore;
37
import org.eclipse.jdt.core.JavaModelException;
38
import org.eclipse.jdt.core.SourceRange;
39
import org.eclipse.jdt.core.dom.AST;
40
import org.eclipse.jdt.core.dom.ASTNode;
41
import org.eclipse.jdt.core.dom.ASTParser;
27
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
42
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
28
import org.eclipse.jdt.internal.core.JarPackageFragmentRoot;
43
import org.eclipse.jdt.internal.core.JarPackageFragmentRoot;
44
import org.eclipse.jdt.internal.core.JavaProject;
29
import org.eclipse.jdt.internal.core.util.Util;
45
import org.eclipse.jdt.internal.core.util.Util;
30
46
31
/**
47
/**
Lines 270-275 Link Here
270
286
271
	// add source attachment file back
287
	// add source attachment file back
272
	moveFile("AttachSourceTests/attachsrc.new.zip", "AttachSourceTests/attachsrc.zip");
288
	moveFile("AttachSourceTests/attachsrc.new.zip", "AttachSourceTests/attachsrc.zip");
289
	((JavaProject)this.currentProject).resetResolvedClasspath();
273
	assertSourceEquals(
290
	assertSourceEquals(
274
		"unexpected source for foo() after addition",
291
		"unexpected source for foo() after addition",
275
		"public void foo() {\n" +
292
		"public void foo() {\n" +
(-)src/org/eclipse/jdt/core/tests/model/ClasspathInitializerTests.java (-9 / +22 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jdt.core.tests.model;
11
package org.eclipse.jdt.core.tests.model;
12
12
13
import java.io.IOException;
13
import java.util.HashMap;
14
import java.util.HashMap;
14
import java.util.Map;
15
import java.util.Map;
15
16
Lines 1313-1319 Link Here
1313
 * @bug 138599: [model][classpath] Need a way to mark a classpath variable as deprecated
1314
 * @bug 138599: [model][classpath] Need a way to mark a classpath variable as deprecated
1314
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=138599"
1315
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=138599"
1315
 */
1316
 */
1316
public void testVariableInitializerDeprecated() throws CoreException {
1317
public void testVariableInitializerDeprecated() throws CoreException, IOException {
1317
	try {
1318
	try {
1318
		// Create initializer
1319
		// Create initializer
1319
		String varName = "TEST_DEPRECATED";
1320
		String varName = "TEST_DEPRECATED";
Lines 1326-1332 Link Here
1326
1327
1327
		// Create project
1328
		// Create project
1328
		IJavaProject project = createJavaProject("P1");
1329
		IJavaProject project = createJavaProject("P1");
1329
		createFile("/P1/lib.jar", "");
1330
		addLibrary(project, "lib.jar", null, new String[0],
1331
				new String[]{"META-INF/MANIFEST.MF", 
1332
					"Manifest-Version: 1.0\n"} , 
1333
					JavaCore.VERSION_1_4);
1330
		IClasspathEntry variable = JavaCore.newVariableEntry(new Path("TEST_DEPRECATED"), null, null);
1334
		IClasspathEntry variable = JavaCore.newVariableEntry(new Path("TEST_DEPRECATED"), null, null);
1331
		IJavaModelStatus status = JavaConventions.validateClasspathEntry(project, variable, false);
1335
		IJavaModelStatus status = JavaConventions.validateClasspathEntry(project, variable, false);
1332
		assertStatus("Classpath variable 'TEST_DEPRECATED' in project 'P1' is deprecated: Test deprecated flag", status);
1336
		assertStatus("Classpath variable 'TEST_DEPRECATED' in project 'P1' is deprecated: Test deprecated flag", status);
Lines 1367-1373 Link Here
1367
 * @bug 156226: [model][classpath] Allow classpath variable to be marked as non modifiable
1371
 * @bug 156226: [model][classpath] Allow classpath variable to be marked as non modifiable
1368
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=156226"
1372
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=156226"
1369
 */
1373
 */
1370
public void testVariableInitializerReadOnly() throws CoreException {
1374
public void testVariableInitializerReadOnly() throws CoreException, IOException {
1371
	try {
1375
	try {
1372
		// Create initializer
1376
		// Create initializer
1373
		String varName = "TEST_READ_ONLY";
1377
		String varName = "TEST_READ_ONLY";
Lines 1380-1386 Link Here
1380
1384
1381
		// Create project
1385
		// Create project
1382
		IJavaProject project = createJavaProject("P1");
1386
		IJavaProject project = createJavaProject("P1");
1383
		createFile("/P1/lib.jar", "");
1387
		addLibrary(project, "lib.jar", null, new String[0],
1388
				new String[]{"META-INF/MANIFEST.MF", 
1389
					"Manifest-Version: 1.0\n"} , 
1390
					JavaCore.VERSION_1_4);
1384
		IClasspathEntry variable = JavaCore.newVariableEntry(new Path("TEST_READ_ONLY"), null, null);
1391
		IClasspathEntry variable = JavaCore.newVariableEntry(new Path("TEST_READ_ONLY"), null, null);
1385
		IJavaModelStatus status = JavaConventions.validateClasspathEntry(project, variable, false);
1392
		IJavaModelStatus status = JavaConventions.validateClasspathEntry(project, variable, false);
1386
		assertStatus("OK", status);
1393
		assertStatus("OK", status);
Lines 1391-1397 Link Here
1391
		deleteProject("P1");
1398
		deleteProject("P1");
1392
	}
1399
	}
1393
}
1400
}
1394
public void testVariableInitializerDeprecatedAndReadOnly() throws CoreException {
1401
public void testVariableInitializerDeprecatedAndReadOnly() throws CoreException, IOException {
1395
	try {
1402
	try {
1396
		// Create initializer
1403
		// Create initializer
1397
		String varName = "TEST_DEPRECATED_READ_ONLY";
1404
		String varName = "TEST_DEPRECATED_READ_ONLY";
Lines 1405-1411 Link Here
1405
1412
1406
		// Create project
1413
		// Create project
1407
		IJavaProject project = createJavaProject("P1");
1414
		IJavaProject project = createJavaProject("P1");
1408
		createFile("/P1/lib.jar", "");
1415
		addLibrary(project, "lib.jar", null, new String[0],
1416
				new String[]{"META-INF/MANIFEST.MF", 
1417
					"Manifest-Version: 1.0\n"} , 
1418
					JavaCore.VERSION_1_4);
1409
		IClasspathEntry variable = JavaCore.newVariableEntry(new Path("TEST_DEPRECATED_READ_ONLY"), null, null);
1419
		IClasspathEntry variable = JavaCore.newVariableEntry(new Path("TEST_DEPRECATED_READ_ONLY"), null, null);
1410
		IJavaModelStatus status = JavaConventions.validateClasspathEntry(project, variable, false);
1420
		IJavaModelStatus status = JavaConventions.validateClasspathEntry(project, variable, false);
1411
		assertStatus("Classpath variable 'TEST_DEPRECATED_READ_ONLY' in project 'P1' is deprecated: A deprecated and read-only initializer", status);
1421
		assertStatus("Classpath variable 'TEST_DEPRECATED_READ_ONLY' in project 'P1' is deprecated: A deprecated and read-only initializer", status);
Lines 1422-1428 Link Here
1422
 * @bug 172207: [model] Marker for deprecated classpath variable should always have WARNING severity
1432
 * @bug 172207: [model] Marker for deprecated classpath variable should always have WARNING severity
1423
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=172207"
1433
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=172207"
1424
 */
1434
 */
1425
public void testVariableInitializerBug172207() throws CoreException {
1435
public void testVariableInitializerBug172207() throws CoreException, IOException {
1426
	try {
1436
	try {
1427
		// Create initializer
1437
		// Create initializer
1428
		String varName = "TEST_DEPRECATED_READ_ONLY";
1438
		String varName = "TEST_DEPRECATED_READ_ONLY";
Lines 1436-1442 Link Here
1436
1446
1437
		// Create project
1447
		// Create project
1438
		IJavaProject project = createJavaProject("P1");
1448
		IJavaProject project = createJavaProject("P1");
1439
		createFile("/P1/lib.jar", "");
1449
		addLibrary(project, "lib.jar", null, new String[0],
1450
				new String[]{"META-INF/MANIFEST.MF", 
1451
					"Manifest-Version: 1.0\n"} , 
1452
					JavaCore.VERSION_1_4);
1440
		IClasspathEntry variable = JavaCore.newVariableEntry(new Path("TEST_DEPRECATED_READ_ONLY"), null, null);
1453
		IClasspathEntry variable = JavaCore.newVariableEntry(new Path("TEST_DEPRECATED_READ_ONLY"), null, null);
1441
		IClasspathEntry[] entries = project.getRawClasspath();
1454
		IClasspathEntry[] entries = project.getRawClasspath();
1442
		int length = entries.length;
1455
		int length = entries.length;
(-)src/org/eclipse/jdt/core/tests/model/ClasspathTests.java (-53 / +143 lines)
Lines 549-558 Link Here
549
/*
549
/*
550
 * Ensures that adding a library entry for an existing external ZIP archive doesn't generate a marker
550
 * Ensures that adding a library entry for an existing external ZIP archive doesn't generate a marker
551
 */
551
 */
552
public void testAddZIPArchive1() throws CoreException {
552
public void testAddZIPArchive1() throws CoreException, IOException {
553
	try {
553
	try {
554
		IJavaProject p = createJavaProject("P");
554
		IJavaProject p = createJavaProject("P");
555
		createExternalFile("externalLib.abc", "");
555
		org.eclipse.jdt.core.tests.util.Util.createEmptyJar(
556
				getExternalResourcePath("externalLib.abc"),
557
				JavaCore.VERSION_1_4);
556
		setClasspath(p, new IClasspathEntry[] {JavaCore.newLibraryEntry(new Path(getExternalResourcePath("externalLib.abc")), null, null)});
558
		setClasspath(p, new IClasspathEntry[] {JavaCore.newLibraryEntry(new Path(getExternalResourcePath("externalLib.abc")), null, null)});
557
		assertMarkers("Unexpected markers", "", p);
559
		assertMarkers("Unexpected markers", "", p);
558
	} finally {
560
	} finally {
Lines 564-572 Link Here
564
/*
566
/*
565
 * Ensures that creating a project with a library entry for an existing external ZIP archive doesn't generate a marker
567
 * Ensures that creating a project with a library entry for an existing external ZIP archive doesn't generate a marker
566
 */
568
 */
567
public void testAddZIPArchive2() throws CoreException {
569
public void testAddZIPArchive2() throws CoreException, IOException {
568
	try {
570
	try {
569
		createExternalFile("externalLib.abc", "");
571
		org.eclipse.jdt.core.tests.util.Util.createEmptyJar(
572
				getExternalResourcePath("externalLib.abc"),
573
				JavaCore.VERSION_1_4);
570
		IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, "");
574
		IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, "");
571
		assertMarkers("Unexpected markers", "", p);
575
		assertMarkers("Unexpected markers", "", p);
572
	} finally {
576
	} finally {
Lines 614-626 Link Here
614
/*
618
/*
615
 * Ensures that creating an external ZIP archive referenced by a library entry and refreshing removes the marker
619
 * Ensures that creating an external ZIP archive referenced by a library entry and refreshing removes the marker
616
 */
620
 */
617
public void testAddZIPArchive5() throws CoreException {
621
public void testAddZIPArchive5() throws CoreException, IOException {
618
	try {
622
	try {
619
		IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, "");
623
		IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, "");
620
		refreshExternalArchives(p);
624
		refreshExternalArchives(p);
621
		waitForAutoBuild();
625
		waitForAutoBuild();
622
626
		org.eclipse.jdt.core.tests.util.Util.createEmptyJar(
623
		createExternalFile("externalLib.abc", "");
627
				getExternalResourcePath("externalLib.abc"),
628
				JavaCore.VERSION_1_4);
624
		refreshExternalArchives(p);
629
		refreshExternalArchives(p);
625
		assertMarkers("Unexpected markers", "", p);
630
		assertMarkers("Unexpected markers", "", p);
626
	} finally {
631
	} finally {
Lines 633-645 Link Here
633
 * Ensures that creating an external ZIP archive referenced by a library entry and refreshing after a restart
638
 * Ensures that creating an external ZIP archive referenced by a library entry and refreshing after a restart
634
 * removes the marker
639
 * removes the marker
635
 */
640
 */
636
public void testAddZIPArchive6() throws CoreException {
641
public void testAddZIPArchive6() throws CoreException, IOException {
637
	try {
642
	try {
638
		simulateExitRestart();
643
		simulateExitRestart();
639
		IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, "");
644
		IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, "");
640
		refreshExternalArchives(p);
645
		refreshExternalArchives(p);
641
646
		org.eclipse.jdt.core.tests.util.Util.createEmptyJar(
642
		createExternalFile("externalLib.abc", "");
647
				getExternalResourcePath("externalLib.abc"),
648
				JavaCore.VERSION_1_4);
643
		refreshExternalArchives(p);
649
		refreshExternalArchives(p);
644
		assertMarkers("Unexpected markers", "", p);
650
		assertMarkers("Unexpected markers", "", p);
645
	} finally {
651
	} finally {
Lines 651-663 Link Here
651
/*
657
/*
652
 * Ensures that adding a library entry for an existing internal ZIP archive doesn't generate a marker
658
 * Ensures that adding a library entry for an existing internal ZIP archive doesn't generate a marker
653
 */
659
 */
654
public void testAddZIPArchive7() throws CoreException {
660
public void testAddZIPArchive7() throws CoreException, IOException {
655
	try {
661
	try {
656
		IJavaProject p = createJavaProject("P");
662
		IJavaProject p = createJavaProject("P");
657
		refreshExternalArchives(p);
663
		refreshExternalArchives(p);
658
		waitForAutoBuild();
664
		waitForAutoBuild();
659
665
		addLibrary(p, "internalLib.abc", null, new String[0],
660
		createFile("/P/internalLib.abc", "");
666
				new String[]{"META-INF/MANIFEST.MF", 
667
					"Manifest-Version: 1.0\n"} , 
668
					JavaCore.VERSION_1_4);
661
		setClasspath(p, new IClasspathEntry[] {JavaCore.newLibraryEntry(new Path("/P/internalLib.abc"), null, null)});
669
		setClasspath(p, new IClasspathEntry[] {JavaCore.newLibraryEntry(new Path("/P/internalLib.abc"), null, null)});
662
		assertMarkers("Unexpected markers", "", p);
670
		assertMarkers("Unexpected markers", "", p);
663
	} finally {
671
	} finally {
Lines 2604-2616 Link Here
2604
	String externalJarPath = getWorkspaceRoot().getLocation().removeLastSegments(1).append("external.jar").toOSString();
2612
	String externalJarPath = getWorkspaceRoot().getLocation().removeLastSegments(1).append("external.jar").toOSString();
2605
	try {
2613
	try {
2606
		IJavaProject p = createJavaProject("P");
2614
		IJavaProject p = createJavaProject("P");
2607
		Util.writeToFile("", externalJarPath);
2615
		org.eclipse.jdt.core.tests.util.Util.createEmptyJar(
2616
				externalJarPath,
2617
				JavaCore.VERSION_1_4);
2608
		ContainerInitializer.setInitializer(new DefaultContainerInitializer(new String[] {"P", "../../external.jar"}));
2618
		ContainerInitializer.setInitializer(new DefaultContainerInitializer(new String[] {"P", "../../external.jar"}));
2609
		setClasspath(p, new IClasspathEntry[] {JavaCore.newContainerEntry(new Path("org.eclipse.jdt.core.tests.model.TEST_CONTAINER"))});
2619
		setClasspath(p, new IClasspathEntry[] {JavaCore.newContainerEntry(new Path("org.eclipse.jdt.core.tests.model.TEST_CONTAINER"))});
2610
		assertElementDescendants(
2620
		assertElementDescendants(
2611
			"Unexpected project content",
2621
			"Unexpected project content",
2612
			"P\n" + 
2622
			"P\n" + 
2613
			"  "+ getExternalPath() + "external.jar",
2623
			"  "+ getExternalPath() + "external.jar\n" + 
2624
			"    <default> (...)",
2614
			p
2625
			p
2615
		);
2626
		);
2616
	} finally {
2627
	} finally {
Lines 2645-2656 Link Here
2645
	String externalJarPath = getWorkspaceRoot().getLocation().append("external.jar").toOSString();
2656
	String externalJarPath = getWorkspaceRoot().getLocation().append("external.jar").toOSString();
2646
	try {
2657
	try {
2647
		IJavaProject p = createJavaProject("P");
2658
		IJavaProject p = createJavaProject("P");
2648
		Util.writeToFile("", externalJarPath);
2659
		org.eclipse.jdt.core.tests.util.Util.createEmptyJar(
2660
				externalJarPath,
2661
				JavaCore.VERSION_1_4);
2649
		setClasspath(p, new IClasspathEntry[] {JavaCore.newLibraryEntry(new Path("../external.jar"), null, null)});
2662
		setClasspath(p, new IClasspathEntry[] {JavaCore.newLibraryEntry(new Path("../external.jar"), null, null)});
2650
		assertElementDescendants(
2663
		assertElementDescendants(
2651
			"Unexpected project content",
2664
			"Unexpected project content",
2652
			"P\n" + 
2665
			"P\n" + 
2653
			"  "+ getWorkspacePath() + "external.jar",
2666
			"  "+ getWorkspacePath() + "external.jar\n" + 
2667
			"    <default> (...)",
2654
			p
2668
			p
2655
		);
2669
		);
2656
	} finally {
2670
	} finally {
Lines 2666-2677 Link Here
2666
	String externalJarPath = getWorkspaceRoot().getLocation().removeLastSegments(1).append("external.jar").toOSString();
2680
	String externalJarPath = getWorkspaceRoot().getLocation().removeLastSegments(1).append("external.jar").toOSString();
2667
	try {
2681
	try {
2668
		IJavaProject p = createJavaProject("P");
2682
		IJavaProject p = createJavaProject("P");
2669
		Util.writeToFile("", externalJarPath);
2683
		org.eclipse.jdt.core.tests.util.Util.createEmptyJar(
2684
				externalJarPath,
2685
				JavaCore.VERSION_1_4);
2670
		setClasspath(p, new IClasspathEntry[] {JavaCore.newLibraryEntry(new Path("../../external.jar"), null, null)});
2686
		setClasspath(p, new IClasspathEntry[] {JavaCore.newLibraryEntry(new Path("../../external.jar"), null, null)});
2671
		assertElementDescendants(
2687
		assertElementDescendants(
2672
			"Unexpected project content",
2688
			"Unexpected project content",
2673
			"P\n" + 
2689
			"P\n" + 
2674
			"  "+ getExternalPath() + "external.jar",
2690
			"  "+ getExternalPath() + "external.jar\n" + 
2691
			"    <default> (...)",
2675
			p
2692
			p
2676
		);
2693
		);
2677
	} finally {
2694
	} finally {
Lines 2687-2698 Link Here
2687
	String externalJarPath = getWorkspaceRoot().getLocation().removeLastSegments(1).append("external.jar").toOSString();
2704
	String externalJarPath = getWorkspaceRoot().getLocation().removeLastSegments(1).append("external.jar").toOSString();
2688
	try {
2705
	try {
2689
		IJavaProject p = createJavaProject("P");
2706
		IJavaProject p = createJavaProject("P");
2690
		Util.writeToFile("", externalJarPath);
2707
		org.eclipse.jdt.core.tests.util.Util.createEmptyJar(
2708
				externalJarPath,
2709
				JavaCore.VERSION_1_4);
2691
		setClasspath(p, new IClasspathEntry[] {JavaCore.newLibraryEntry(new Path("src/../../../external.jar"), null, null)});
2710
		setClasspath(p, new IClasspathEntry[] {JavaCore.newLibraryEntry(new Path("src/../../../external.jar"), null, null)});
2692
		assertElementDescendants(
2711
		assertElementDescendants(
2693
			"Unexpected project content",
2712
			"Unexpected project content",
2694
			"P\n" + 
2713
			"P\n" + 
2695
			"  "+ getExternalPath() + "external.jar",
2714
			"  "+ getExternalPath() + "external.jar\n" + 
2715
			"    <default> (...)",
2696
			p
2716
			p
2697
		);
2717
		);
2698
	} finally {
2718
	} finally {
Lines 2706-2720 Link Here
2706
 */
2726
 */
2707
public void testDotDotLibraryEntry4() throws Exception {
2727
public void testDotDotLibraryEntry4() throws Exception {
2708
	try {
2728
	try {
2709
		createProject("P1");
2729
		IJavaProject p1 = createJavaProject("P1");
2710
		createFile("/P1/internal.jar", "");
2730
		IJavaProject p2 = createJavaProject("P2");
2711
		IJavaProject p = createJavaProject("P2");
2731
		
2712
		setClasspath(p, new IClasspathEntry[] {JavaCore.newLibraryEntry(new Path("../P1/internal.jar"), null, null)});
2732
		addLibrary(p1, "internal.jar", null, new String[0],
2733
				new String[]{"META-INF/MANIFEST.MF", 
2734
					"Manifest-Version: 1.0\n"} , 
2735
					JavaCore.VERSION_1_4);		
2736
		setClasspath(p2, new IClasspathEntry[] {JavaCore.newLibraryEntry(new Path("../P1/internal.jar"), null, null)});
2713
		assertElementDescendants(
2737
		assertElementDescendants(
2714
			"Unexpected project content",
2738
			"Unexpected project content",
2715
			"P2\n" + 
2739
			"P2\n" + 
2716
			"  /P1/internal.jar",
2740
			"  /P1/internal.jar\n" + 
2717
			p
2741
			"    <default> (...)",
2742
			p2
2718
		);
2743
		);
2719
	} finally {
2744
	} finally {
2720
		deleteProject("P1");
2745
		deleteProject("P1");
Lines 2729-2735 Link Here
2729
	String externalJarPath = getWorkspaceRoot().getLocation().append("external.jar").toOSString();
2754
	String externalJarPath = getWorkspaceRoot().getLocation().append("external.jar").toOSString();
2730
	try {
2755
	try {
2731
		IJavaProject p = createJavaProject("P");
2756
		IJavaProject p = createJavaProject("P");
2732
		Util.writeToFile("", externalJarPath);
2757
		org.eclipse.jdt.core.tests.util.Util.createEmptyJar(
2758
				externalJarPath,
2759
				JavaCore.VERSION_1_4);
2733
		setClasspath(p, new IClasspathEntry[] {JavaCore.newLibraryEntry(new Path("../external.jar"), null, null)});
2760
		setClasspath(p, new IClasspathEntry[] {JavaCore.newLibraryEntry(new Path("../external.jar"), null, null)});
2734
		assertMarkers(
2761
		assertMarkers(
2735
			"Unexpected markers", 
2762
			"Unexpected markers", 
Lines 2764-2770 Link Here
2764
	String externalJarPath = getWorkspaceRoot().getLocation().append("external.jar").toOSString();
2791
	String externalJarPath = getWorkspaceRoot().getLocation().append("external.jar").toOSString();
2765
	try {
2792
	try {
2766
		IJavaProject p = createJavaProject("P");
2793
		IJavaProject p = createJavaProject("P");
2767
		Util.writeToFile("", externalJarPath);
2794
		org.eclipse.jdt.core.tests.util.Util.createEmptyJar(
2795
				externalJarPath,
2796
				JavaCore.VERSION_1_4);
2768
		editFile(
2797
		editFile(
2769
			"/P/.classpath",
2798
			"/P/.classpath",
2770
			"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + 
2799
			"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + 
Lines 2778-2784 Link Here
2778
			"P\n" + 
2807
			"P\n" + 
2779
			"  <project root>\n" + 
2808
			"  <project root>\n" + 
2780
			"    <default> (...)\n" + 
2809
			"    <default> (...)\n" + 
2781
			"  "+ getWorkspacePath() + "external.jar",
2810
			"  "+ getWorkspacePath() + "external.jar\n" + 
2811
			"    <default> (...)",
2782
			p
2812
			p
2783
		);
2813
		);
2784
	} finally {
2814
	} finally {
Lines 2819-2830 Link Here
2819
	try {
2849
	try {
2820
		JavaCore.setClasspathVariable("TWO_UP", new Path("../.."), null);
2850
		JavaCore.setClasspathVariable("TWO_UP", new Path("../.."), null);
2821
		IJavaProject p = createJavaProject("P");
2851
		IJavaProject p = createJavaProject("P");
2822
		Util.writeToFile("", externalJarPath);
2852
		org.eclipse.jdt.core.tests.util.Util.createEmptyJar(
2853
				externalJarPath,
2854
				JavaCore.VERSION_1_4);
2823
		setClasspath(p, new IClasspathEntry[] {JavaCore.newVariableEntry(new Path("TWO_UP/external.jar"), null, null)});
2855
		setClasspath(p, new IClasspathEntry[] {JavaCore.newVariableEntry(new Path("TWO_UP/external.jar"), null, null)});
2824
		assertElementDescendants(
2856
		assertElementDescendants(
2825
			"Unexpected project content",
2857
			"Unexpected project content",
2826
			"P\n" + 
2858
			"P\n" + 
2827
			"  "+ getExternalPath() + "external.jar",
2859
			"  "+ getExternalPath() + "external.jar\n" + 
2860
			"    <default> (...)",
2828
			p
2861
			p
2829
		);
2862
		);
2830
	} finally {
2863
	} finally {
Lines 3122-3129 Link Here
3122
		waitUntilIndexesReady();
3155
		waitUntilIndexesReady();
3123
		waitForAutoBuild();
3156
		waitForAutoBuild();
3124
		// at this point, a marker indicates that test185733.jar has been created: "Project 'P' is missing required library: '[...]\test185733.jar'"
3157
		// at this point, a marker indicates that test185733.jar has been created: "Project 'P' is missing required library: '[...]\test185733.jar'"
3125
3158
		org.eclipse.jdt.core.tests.util.Util.createEmptyJar(
3126
		createFile(new File(getExternalPath()), "test185733.jar", "");
3159
				getExternalResourcePath("test185733.jar"),
3160
				JavaCore.VERSION_1_4);
3127
		refreshExternalArchives(p);
3161
		refreshExternalArchives(p);
3128
		assertMarkers(
3162
		assertMarkers(
3129
			"Unexpected markers",
3163
			"Unexpected markers",
Lines 3749-3761 Link Here
3749
 * Ensures that a marker is removed if adding an internal jar that is on the classpath in another project
3783
 * Ensures that a marker is removed if adding an internal jar that is on the classpath in another project
3750
 * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=213723 )
3784
 * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=213723 )
3751
 */
3785
 */
3752
public void testFixClasspath1() throws CoreException {
3786
public void testFixClasspath1() throws CoreException, IOException {
3753
	try {
3787
	try {
3754
		createProject("P1");
3788
		createProject("P1");
3755
		IJavaProject project = createJavaProject("P2", new String[0], new String[] {"/P1/lib.jar"}, "bin");
3789
		IJavaProject project = createJavaProject("P2", new String[0], new String[0], "bin");
3756
		waitForAutoBuild();
3790
		waitForAutoBuild();
3757
3791
		addLibrary(project, "lib.jar", null, new String[0],
3758
		createFile("/P1/lib.jar", "");
3792
				new String[]{"META-INF/MANIFEST.MF", 
3793
					"Manifest-Version: 1.0\n"} , 
3794
					JavaCore.VERSION_1_4);
3795
		
3759
		assertMarkers(
3796
		assertMarkers(
3760
			"Unexpected markers",
3797
			"Unexpected markers",
3761
			"",
3798
			"",
Lines 3769-3779 Link Here
3769
 * Ensures that a marker is removed if adding an external jar, restarting and refreshing
3806
 * Ensures that a marker is removed if adding an external jar, restarting and refreshing
3770
 * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=216446 )
3807
 * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=216446 )
3771
 */
3808
 */
3772
public void testFixClasspath2() throws CoreException {
3809
public void testFixClasspath2() throws CoreException, IOException {
3773
	try {
3810
	try {
3774
		IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, "");
3811
		IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, "");
3775
		waitForAutoBuild(); // 1 marker
3812
		waitForAutoBuild(); // 1 marker
3776
		createExternalFile("externalLib.abc", "");
3813
		org.eclipse.jdt.core.tests.util.Util.createEmptyJar(
3814
				getExternalResourcePath("externalLib.abc"),
3815
				JavaCore.VERSION_1_4);
3777
		
3816
		
3778
		simulateExitRestart();
3817
		simulateExitRestart();
3779
		refreshExternalArchives(p);
3818
		refreshExternalArchives(p);
Lines 3939-3949 Link Here
3939
 * Ensures that a file not ending with .jar or .zip can be put on the classpath.
3978
 * Ensures that a file not ending with .jar or .zip can be put on the classpath.
3940
 * (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=182360 )
3979
 * (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=182360 )
3941
 */
3980
 */
3942
public void testInvalidInternalJar2() throws CoreException {
3981
public void testInvalidInternalJar2() throws CoreException, IOException {
3943
	try {
3982
	try {
3944
		createProject("P1");
3983
		IJavaProject proj =  createJavaProject("P1", new String[] {}, new String[0], "bin");
3945
		createFile("/P1/existing.txt", "");
3984
		
3946
		IJavaProject proj =  createJavaProject("P2", new String[] {}, new String[] {"/P1/existing.txt"}, "bin");
3985
		addLibrary(proj, "existing.txt", null, new String[0],
3986
				new String[]{"META-INF/MANIFEST.MF", 
3987
					"Manifest-Version: 1.0\n"} , 
3988
					JavaCore.VERSION_1_4);
3989
		proj =  createJavaProject("P2", new String[] {}, new String[] {"/P1/existing.txt"}, "bin");
3947
		assertMarkers(
3990
		assertMarkers(
3948
			"Unexpected markers",
3991
			"Unexpected markers",
3949
			"",
3992
			"",
Lines 4933-4944 Link Here
4933
 * Ensures that duplicate entries due to resolution are not reported
4976
 * Ensures that duplicate entries due to resolution are not reported
4934
 * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=175226 )
4977
 * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=175226 )
4935
 */
4978
 */
4936
public void testDuplicateEntries2() throws CoreException {
4979
public void testDuplicateEntries2() throws CoreException, IOException {
4937
	try {
4980
	try {
4938
		IJavaProject project = createJavaProject("P");
4981
		IJavaProject project = createJavaProject("P");
4939
		VariablesInitializer.setInitializer(new DefaultVariableInitializer(new String[] {"TEST_LIB", "/P/lib.jar"}));
4982
		VariablesInitializer.setInitializer(new DefaultVariableInitializer(new String[] {"TEST_LIB", "/P/lib.jar"}));
4940
		ContainerInitializer.setInitializer(new DefaultContainerInitializer(new String[] {"P", "/P/lib.jar"}));
4983
		ContainerInitializer.setInitializer(new DefaultContainerInitializer(new String[] {"P", "/P/lib.jar"}));
4941
		createFile("/P/lib.jar", "");
4984
		addLibrary(project, "lib.jar", null, new String[0],
4985
				new String[]{"META-INF/MANIFEST.MF", 
4986
					"Manifest-Version: 1.0\n"} , 
4987
					JavaCore.VERSION_1_4);
4942
		editFile(
4988
		editFile(
4943
			"/P/.classpath",
4989
			"/P/.classpath",
4944
			"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
4990
			"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
Lines 4948-4953 Link Here
4948
			"    <classpathentry kind=\"output\" path=\"bin\"/>\n" +
4994
			"    <classpathentry kind=\"output\" path=\"bin\"/>\n" +
4949
			"</classpath>"
4995
			"</classpath>"
4950
		);
4996
		);
4997
		waitForAutoBuild();
4951
		assertMarkers(
4998
		assertMarkers(
4952
			"Unexpected markers",
4999
			"Unexpected markers",
4953
			"",
5000
			"",
Lines 5497-5509 Link Here
5497
/*
5544
/*
5498
 * Ensures that removing an internal ZIP archive referenced by a library entry creates a marker
5545
 * Ensures that removing an internal ZIP archive referenced by a library entry creates a marker
5499
 */
5546
 */
5500
public void testRemoveZIPArchive6() throws CoreException {
5547
public void testRemoveZIPArchive6() throws CoreException, IOException {
5501
	try {
5548
	try {
5502
		IJavaProject p = createJavaProject("P", new String[0], new String[] {"/P/internalLib.abc"}, "");
5549
		IJavaProject p = createJavaProject("P", new String[0], new String[0], "");
5503
		createFile("/P/internalLib.abc", "");
5550
		
5551
		addLibrary(p, "internalLib.abc", null, new String[0],
5552
				new String[]{"META-INF/MANIFEST.MF", 
5553
					"Manifest-Version: 1.0\n"} , 
5554
					JavaCore.VERSION_1_4);
5504
		waitForAutoBuild();
5555
		waitForAutoBuild();
5505
5556
5506
		deleteFile("/P/internalLib.abc");
5557
		deleteFile("/P/internalLib.abc");
5558
		waitForAutoBuild();
5507
		assertMarkers(
5559
		assertMarkers(
5508
			"Unexpected markers",
5560
			"Unexpected markers",
5509
			"Project \'P\' is missing required library: \'internalLib.abc\'",
5561
			"Project \'P\' is missing required library: \'internalLib.abc\'",
Lines 5517-5528 Link Here
5517
 * Ensures that renaming a .jar file and updating the classpath in a PRE_BUILD event doesn't leave markers
5569
 * Ensures that renaming a .jar file and updating the classpath in a PRE_BUILD event doesn't leave markers
5518
 * (regression test for bug 177922 FlexibleProjectContainer refresh logic sporadically leaves project with "missing library" error on rename/delete)
5570
 * (regression test for bug 177922 FlexibleProjectContainer refresh logic sporadically leaves project with "missing library" error on rename/delete)
5519
 */
5571
 */
5520
public void testRenameJar() throws CoreException {
5572
public void testRenameJar() throws CoreException, IOException {
5521
	IResourceChangeListener listener = null;
5573
	IResourceChangeListener listener = null;
5522
	try {
5574
	try {
5523
		final IJavaProject p = createJavaProject("P", new String[0], new String[] {"/P/lib/test1.jar"}, "");
5575
		final IJavaProject p = createJavaProject("P", new String[0], new String[0], "");
5524
		createFolder("/P/lib");
5576
		createFolder("/P/lib");
5525
		createFile("/P/lib/test1.jar", "");
5577
		addLibrary(p, "lib/test1.jar", null, new String[0],
5578
				new String[]{"META-INF/MANIFEST.MF", 
5579
					"Manifest-Version: 1.0\n"} , 
5580
					JavaCore.VERSION_1_4);
5526
		// at this point no markers exist
5581
		// at this point no markers exist
5527
5582
5528
		// register a listener that updates the classpath in a PRE_BUILD event
5583
		// register a listener that updates the classpath in a PRE_BUILD event
Lines 6813-6818 Link Here
6813
		deleteProject("ReferencedProject");
6868
		deleteProject("ReferencedProject");
6814
	}
6869
	}
6815
}
6870
}
6816
6871
/**
6872
 * @bug 229042: [buildpath] could create build path error in case of invalid external JAR format
6873
 * 
6874
 * Test that an invalid archive (JAR) creates a buildpath error
6875
 * 
6876
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=229042"
6877
 * @throws Exception
6878
 */
6879
public void testBug229042() throws Exception {
6880
	try {
6881
		IJavaProject p = createJavaProject("P");
6882
		createFile("/P/library.jar", "");
6883
		setClasspath(p, new IClasspathEntry[] { JavaCore.newLibraryEntry(new Path("/P/library.jar"), null,null)});
6884
		assertMarkers("Expected marker", 
6885
				"Illegal type of archive for required library: \'library.jar\' in project \'P\'", p);
6886
		setClasspath(p, new IClasspathEntry[0]);
6887
		addLibrary(p, "library.jar", null, new String[0], 
6888
				new String[] {
6889
				"p/X.java",
6890
				"package p;\n" +
6891
				"public class X {}\n",
6892
				"META-INF/MANIFEST.MF",
6893
				"Manifest-Version: 1.0\n",
6894
			},
6895
			JavaCore.VERSION_1_4);
6896
		IFile file = p.getProject().getFile("library.jar");
6897
		assertNotNull(file);
6898
		file.touch(null);
6899
		waitForAutoBuild();
6900
		assertMarkers("Unexpected marker", 
6901
				"", p);
6902
		
6903
	} finally {
6904
		deleteProject("P");
6905
	}
6906
}
6817
6907
6818
}
6908
}
(-)src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java (-18 / +28 lines)
Lines 244-256 Link Here
244
public void testAddZIPArchive1() throws Exception {
244
public void testAddZIPArchive1() throws Exception {
245
	try {
245
	try {
246
		IJavaProject p = createJavaProject("P");
246
		IJavaProject p = createJavaProject("P");
247
		createExternalFile("externalLib.abc", "");
247
		org.eclipse.jdt.core.tests.util.Util.createEmptyJar(getExternalResourcePath("externalLib.abc"), JavaCore.VERSION_1_4);
248
248
249
		setClasspath(p, new IClasspathEntry[] {JavaCore.newLibraryEntry(new Path(getExternalResourcePath("externalLib.abc")), null, null)});
249
		setClasspath(p, new IClasspathEntry[] {JavaCore.newLibraryEntry(new Path(getExternalResourcePath("externalLib.abc")), null, null)});
250
		assertElementDescendants(
250
		assertElementDescendants(
251
			"Unexpected project content",
251
			"Unexpected project content",
252
			"P\n" +
252
			"P\n" + 
253
			"  "+ getExternalPath() + "externalLib.abc",
253
			"  "+ getExternalPath() + "externalLib.abc\n" + 
254
			"    <default> (...)",
254
			p
255
			p
255
		);
256
		);
256
	} finally {
257
	} finally {
Lines 319-330 Link Here
319
		refreshExternalArchives(p);
320
		refreshExternalArchives(p);
320
		expandAll(p);
321
		expandAll(p);
321
322
322
		createExternalFile("externalLib.abc", "");
323
		org.eclipse.jdt.core.tests.util.Util.createEmptyJar(getExternalResourcePath("externalLib.abc"), JavaCore.VERSION_1_4);
323
		refreshExternalArchives(p);
324
		refreshExternalArchives(p);
324
		assertElementDescendants(
325
		assertElementDescendants(
325
			"Unexpected project content",
326
			"Unexpected project content",
326
			"P\n" +
327
			"P\n" + 
327
			"  "+ getExternalPath() + "externalLib.abc",
328
			"  "+ getExternalPath() + "externalLib.abc\n" + 
329
			"    <default> (...)",
328
			p
330
			p
329
		);
331
		);
330
	} finally {
332
	} finally {
Lines 372-383 Link Here
372
public void testAddZIPArchive6() throws Exception {
374
public void testAddZIPArchive6() throws Exception {
373
	try {
375
	try {
374
		IJavaProject p = createJavaProject("P");
376
		IJavaProject p = createJavaProject("P");
375
		createFile("/P/internalLib.abc", "");
377
		addLibrary(p, "internalLib.abc", null, new String[0], 
378
				new String[] {
379
					"META-INF/MANIFEST.MF",
380
					"Manifest-Version: 1.0\n" +
381
					"Class-Path: lib2.jar\n",
382
				},
383
				JavaCore.VERSION_1_4);
376
		setClasspath(p, new IClasspathEntry[] {JavaCore.newLibraryEntry(new Path("/P/internalLib.abc"), null, null)});
384
		setClasspath(p, new IClasspathEntry[] {JavaCore.newLibraryEntry(new Path("/P/internalLib.abc"), null, null)});
377
		assertElementDescendants(
385
		assertElementDescendants(
378
			"Unexpected project content",
386
			"Unexpected project content",
379
			"P\n" +
387
			"P\n" + 
380
			"  internalLib.abc",
388
			"  internalLib.abc\n" + 
389
			"    <default> (...)",
381
			p
390
			p
382
		);
391
		);
383
	} finally {
392
	} finally {
Lines 527-533 Link Here
527
 */
536
 */
528
public void testChangeZIPArchive1() throws CoreException, IOException {
537
public void testChangeZIPArchive1() throws CoreException, IOException {
529
	try {
538
	try {
530
		createExternalFile("externalLib.abc", "");
539
		org.eclipse.jdt.core.tests.util.Util.createEmptyJar(getExternalResourcePath("externalLib.abc"), JavaCore.VERSION_1_4);
531
		IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, "bin");
540
		IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, "bin");
532
		refreshExternalArchives(p);
541
		refreshExternalArchives(p);
533
		expandAll(p);
542
		expandAll(p);
Lines 607-613 Link Here
607
public void testChangeZIPArchive3() throws CoreException, IOException {
616
public void testChangeZIPArchive3() throws CoreException, IOException {
608
	try {
617
	try {
609
		IJavaProject p = createJavaProject("P", new String[0], new String[] {"/P/internalLib.abc"}, "bin");
618
		IJavaProject p = createJavaProject("P", new String[0], new String[] {"/P/internalLib.abc"}, "bin");
610
		IFile lib = createFile("/P/internalLib.abc", "");
619
		String libPath = p.getProject().getLocation().toOSString()+ File.separator + "internalLib.abc";
620
		org.eclipse.jdt.core.tests.util.Util.createEmptyJar(libPath, JavaCore.VERSION_1_4);
611
		expandAll(p);
621
		expandAll(p);
612
622
613
		createJar(
623
		createJar(
Lines 617-623 Link Here
617
				"public class X {\n" +
627
				"public class X {\n" +
618
				"}"
628
				"}"
619
			},
629
			},
620
			lib.getLocation().toOSString());
630
			libPath);
621
		p.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
631
		p.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
622
		assertElementDescendants(
632
		assertElementDescendants(
623
			"Unexpected project content",
633
			"Unexpected project content",
Lines 2065-2073 Link Here
2065
/*
2075
/*
2066
 * Ensures that removing a library entry for an existing external ZIP archive updates the model
2076
 * Ensures that removing a library entry for an existing external ZIP archive updates the model
2067
 */
2077
 */
2068
public void testRemoveZIPArchive1() throws CoreException {
2078
public void testRemoveZIPArchive1() throws CoreException, IOException {
2069
	try {
2079
	try {
2070
		createExternalFile("externalLib.abc", "");
2080
		org.eclipse.jdt.core.tests.util.Util.createEmptyJar(getExternalResourcePath("externalLib.abc"), JavaCore.VERSION_1_4);
2071
		IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, "");
2081
		IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, "");
2072
		refreshExternalArchives(p);
2082
		refreshExternalArchives(p);
2073
		expandAll(p);
2083
		expandAll(p);
Lines 2108-2116 Link Here
2108
/*
2118
/*
2109
 * Ensures that removing an external ZIP archive referenced by a library entry and refreshing updates the model
2119
 * Ensures that removing an external ZIP archive referenced by a library entry and refreshing updates the model
2110
 */
2120
 */
2111
public void testRemoveZIPArchive3() throws CoreException {
2121
public void testRemoveZIPArchive3() throws CoreException, IOException {
2112
	try {
2122
	try {
2113
		createExternalFile("externalLib.abc", "");
2123
		org.eclipse.jdt.core.tests.util.Util.createEmptyJar(getExternalResourcePath("externalLib.abc"), JavaCore.VERSION_1_4);
2114
		IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, "");
2124
		IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, "");
2115
		refreshExternalArchives(p);
2125
		refreshExternalArchives(p);
2116
		expandAll(p);
2126
		expandAll(p);
Lines 2131-2140 Link Here
2131
/*
2141
/*
2132
 * Ensures that removing a library entry for an existing internal ZIP archive updates the model
2142
 * Ensures that removing a library entry for an existing internal ZIP archive updates the model
2133
 */
2143
 */
2134
public void testRemoveZIPArchive4() throws CoreException {
2144
public void testRemoveZIPArchive4() throws CoreException, IOException {
2135
	try {
2145
	try {
2136
		IJavaProject p = createJavaProject("P", new String[0], new String[] {"/P/internalLib.abc"}, "");
2146
		IJavaProject p = createJavaProject("P", new String[0], new String[] {"/P/internalLib.abc"}, "");
2137
		createFile("/P/internalLib.abc", "");
2147
		org.eclipse.jdt.core.tests.util.Util.createEmptyJar(p.getProject().getLocation().toOSString()+ File.separator + "internalLib.abc", JavaCore.VERSION_1_4);
2138
		expandAll(p);
2148
		expandAll(p);
2139
2149
2140
		setClasspath(p, new IClasspathEntry[] {});
2150
		setClasspath(p, new IClasspathEntry[] {});

Return to bug 229042