View | Details | Raw Unified | Return to bug 121652
Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/ElementCache.java (-11 lines)
Lines 10-17 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.core;
11
package org.eclipse.jdt.internal.core;
12
12
13
import java.text.NumberFormat;
14
15
import org.eclipse.jdt.core.IJavaElement;
13
import org.eclipse.jdt.core.IJavaElement;
16
import org.eclipse.jdt.core.JavaModelException;
14
import org.eclipse.jdt.core.JavaModelException;
17
import org.eclipse.jdt.internal.core.util.LRUCache;
15
import org.eclipse.jdt.internal.core.util.LRUCache;
Lines 96-108 Link Here
96
	}
94
	}
97
}
95
}
98
96
99
public String toStringFillingRation(String cacheName) {
100
	StringBuffer buffer = new StringBuffer(cacheName);
101
	buffer.append('[');
102
	buffer.append(getSpaceLimit());
103
	buffer.append("]: "); //$NON-NLS-1$
104
	buffer.append(NumberFormat.getInstance().format(fillingRatio()));
105
	buffer.append("% full"); //$NON-NLS-1$
106
	return buffer.toString();
107
}
108
}
97
}
(-)model/org/eclipse/jdt/internal/core/OverflowingLRUCache.java (-17 / +2 lines)
Lines 10-16 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.core;
11
package org.eclipse.jdt.internal.core;
12
12
13
import java.text.NumberFormat;
14
import java.util.Enumeration;
13
import java.util.Enumeration;
15
import java.util.Iterator;
14
import java.util.Iterator;
16
15
Lines 199-218 Link Here
199
	 * Returns a new instance of the reciever.
198
	 * Returns a new instance of the reciever.
200
	 */
199
	 */
201
	protected abstract LRUCache newInstance(int size, int overflow);
200
	protected abstract LRUCache newInstance(int size, int overflow);
202
	/**
203
	 * Answers the value in the cache at the given key.
204
	 * If the value is not in the cache, returns null
205
	 *
206
	 * This function does not modify timestamps.
207
	 */
208
	public Object peek(Object key) {
209
		
210
		LRUCacheEntry entry = (LRUCacheEntry) fEntryTable.get(key);
211
		if (entry == null) {
212
			return null;
213
		}
214
		return entry._fValue;
215
	}
216
/**
201
/**
217
 * For testing purposes only
202
 * For testing purposes only
218
 */
203
 */
Lines 413-420 Link Here
413
 */
398
 */
414
public String toString() {
399
public String toString() {
415
	return 
400
	return 
416
		"OverflowingLRUCache " + NumberFormat.getInstance().format(this.fillingRatio()) + "% full\n" + //$NON-NLS-1$ //$NON-NLS-2$
401
		toStringFillingRation("OverflowingLRUCache ") + //$NON-NLS-1$
417
		this.toStringContents();
402
		toStringContents();
418
}
403
}
419
/**
404
/**
420
 * Updates the timestamp for the given entry, ensuring that the queue is 
405
 * Updates the timestamp for the given entry, ensuring that the queue is 
(-)model/org/eclipse/jdt/internal/core/JavaProjectElementInfo.java (+1 lines)
Lines 287-292 Link Here
287
	 */
287
	 */
288
	void resetCaches() {
288
	void resetCaches() {
289
		this.projectCache = null;
289
		this.projectCache = null;
290
		JavaModelManager.getJavaModelManager().resetJarTypeCache();
290
	}
291
	}
291
	
292
	
292
	/**
293
	/**
(-)model/org/eclipse/jdt/internal/core/ClassFile.java (-18 / +43 lines)
Lines 174-179 Link Here
174
public boolean exists() {
174
public boolean exists() {
175
	return super.exists() && validateClassFile().isOK();
175
	return super.exists() && validateClassFile().isOK();
176
}
176
}
177
public boolean existsUsingJarTypeCache() {
178
	if (getPackageFragmentRoot().isArchive()) {
179
		JavaModelManager manager = JavaModelManager.getJavaModelManager();
180
		IType type = getType();
181
		Object info = manager.getInfo(type);
182
		if (info == JavaModelCache.NON_EXISTING_JAR_TYPE_INFO)
183
			return false;
184
		else if (info != null)
185
			return true;
186
		try {
187
			info = getJarBinaryTypeInfo((PackageFragment) getParent());
188
		} catch (CoreException e) {
189
			info = null;
190
		} catch (IOException e) {
191
			info = null;
192
		} catch (ClassFormatException e) {
193
			info = null;
194
		}
195
		manager.putJarTypeInfo(type, info == null ? JavaModelCache.NON_EXISTING_JAR_TYPE_INFO : info);
196
		return info != null;
197
	} else
198
		return exists();
199
}
177
200
178
/**
201
/**
179
 * Finds the deepest <code>IJavaElement</code> in the hierarchy of
202
 * Finds the deepest <code>IJavaElement</code> in the hierarchy of
Lines 217-241 Link Here
217
 * or when this class file is not present in the JAR
240
 * or when this class file is not present in the JAR
218
 */
241
 */
219
public IBinaryType getBinaryTypeInfo(IFile file) throws JavaModelException {
242
public IBinaryType getBinaryTypeInfo(IFile file) throws JavaModelException {
220
	JavaElement le = (JavaElement) getParent();
243
	JavaElement pkg = (JavaElement) getParent();
221
	if (le instanceof JarPackageFragment) {
244
	if (pkg instanceof JarPackageFragment) {
222
		try {
245
		try {
223
			JarPackageFragmentRoot root = (JarPackageFragmentRoot) le.getParent();
246
			IBinaryType info = getJarBinaryTypeInfo((PackageFragment) pkg);
224
			IBinaryType info = null;
225
			ZipFile zip = null;
226
			try {
227
				zip = root.getJar();
228
				PackageFragment pkg = (PackageFragment) le;
229
				String entryName = Util.concatWith(pkg.names, getElementName(), '/');
230
				ZipEntry ze = zip.getEntry(entryName);
231
				if (ze != null) {
232
					byte contents[] = org.eclipse.jdt.internal.compiler.util.Util.getZipEntryByteContent(ze, zip);
233
					String fileName = root.getHandleIdentifier() + IDependent.JAR_FILE_ENTRY_SEPARATOR + entryName;
234
					info = new ClassFileReader(contents, fileName.toCharArray(), true/*fully initialize so as to not keep a reference to the byte array*/);
235
				}
236
			} finally {
237
				JavaModelManager.getJavaModelManager().closeZipFile(zip);
238
			}
239
			if (info == null) {
247
			if (info == null) {
240
				throw newNotPresentException();
248
				throw newNotPresentException();
241
			}
249
			}
Lines 265-270 Link Here
265
		}
273
		}
266
	}
274
	}
267
}
275
}
276
private IBinaryType getJarBinaryTypeInfo(PackageFragment pkg) throws CoreException, IOException, ClassFormatException {
277
	JarPackageFragmentRoot root = (JarPackageFragmentRoot) pkg.getParent();
278
	ZipFile zip = null;
279
	try {
280
		zip = root.getJar();
281
		String entryName = Util.concatWith(pkg.names, getElementName(), '/');
282
		ZipEntry ze = zip.getEntry(entryName);
283
		if (ze != null) {
284
			byte contents[] = org.eclipse.jdt.internal.compiler.util.Util.getZipEntryByteContent(ze, zip);
285
			String fileName = root.getHandleIdentifier() + IDependent.JAR_FILE_ENTRY_SEPARATOR + entryName;
286
			return new ClassFileReader(contents, fileName.toCharArray(), true/*fully initialize so as to not keep a reference to the byte array*/);
287
		}
288
	} finally {
289
		JavaModelManager.getJavaModelManager().closeZipFile(zip);
290
	}
291
	return null;
292
}
268
public IBuffer getBuffer() throws JavaModelException {
293
public IBuffer getBuffer() throws JavaModelException {
269
	if (validateClassFile().isOK()) {
294
	if (validateClassFile().isOK()) {
270
		return super.getBuffer();
295
		return super.getBuffer();
(-)model/org/eclipse/jdt/internal/core/NameLookup.java (-22 / +13 lines)
Lines 534-545 Link Here
534
	 * Find secondary type for a project.
534
	 * Find secondary type for a project.
535
	 */
535
	 */
536
	private IType findSecondaryType(String packageName, String typeName, IJavaProject project, boolean waitForIndexes, IProgressMonitor monitor) {
536
	private IType findSecondaryType(String packageName, String typeName, IJavaProject project, boolean waitForIndexes, IProgressMonitor monitor) {
537
		if (VERBOSE) {
538
			Util.verbose("NameLookup FIND SECONDARY TYPES:"); //$NON-NLS-1$
539
			Util.verbose(" -> pkg name: " + packageName);  //$NON-NLS-1$
540
			Util.verbose(" -> type name: " + typeName);  //$NON-NLS-1$
541
			Util.verbose(" -> project: "+project.getElementName()); //$NON-NLS-1$
542
		}
543
		JavaModelManager manager = JavaModelManager.getJavaModelManager();
537
		JavaModelManager manager = JavaModelManager.getJavaModelManager();
544
		try {
538
		try {
545
			IJavaProject javaProject = project;
539
			IJavaProject javaProject = project;
Lines 936-962 Link Here
936
		if (VERBOSE)
930
		if (VERBOSE)
937
			start = System.currentTimeMillis();
931
			start = System.currentTimeMillis();
938
		try {
932
		try {
939
			IClassFile[] classFiles= null;
940
			try {
941
				classFiles= pkg.getClassFiles();
942
			} catch (JavaModelException npe) {
943
				return; // the package is not present
944
			}
945
			int length= classFiles.length;
946
			if (!partialMatch) {
933
			if (!partialMatch) {
947
				// exact match
934
				// exact match
948
				for (int i= 0; i < length; i++) {
935
				if (requestor.isCanceled()) return;
949
					if (requestor.isCanceled()) return;
936
				ClassFile classFile =  new ClassFile((PackageFragment) pkg, name);
950
					ClassFile classFile= (ClassFile) classFiles[i];
937
				if (classFile.existsUsingJarTypeCache()) {
951
					if (name.equals(classFile.name)) { // ClassFile#name contains the name of the .class file without the .class extension
938
					IType type = classFile.getType();
952
						IType type = classFile.getType();
939
					if (acceptType(type, acceptFlags, false/*not a source type*/)) {
953
						if (acceptType(type, acceptFlags, false/*not a source type*/)) {
940
						requestor.acceptType(type);
954
							requestor.acceptType(type);
955
							break;  // since an exact match was requested, no other matching type can exist
956
						}
957
					}
941
					}
958
				}
942
				}
959
			} else {
943
			} else {
944
				IClassFile[] classFiles= null;
945
				try {
946
					classFiles= pkg.getClassFiles();
947
				} catch (JavaModelException npe) {
948
					return; // the package is not present
949
				}
950
				int length= classFiles.length;
960
				String unqualifiedName = name;
951
				String unqualifiedName = name;
961
				int index = name.lastIndexOf('$');
952
				int index = name.lastIndexOf('$');
962
				if (index != -1) {
953
				if (index != -1) {
(-)model/org/eclipse/jdt/internal/core/Openable.java (-1 / +1 lines)
Lines 237-243 Link Here
237
	JavaModelManager.getJavaModelManager().getElementsOutOfSynchWithBuffers().remove(this);
237
	JavaModelManager.getJavaModelManager().getElementsOutOfSynchWithBuffers().remove(this);
238
238
239
	if (JavaModelManager.VERBOSE) {
239
	if (JavaModelManager.VERBOSE) {
240
		System.out.println(JavaModelManager.getJavaModelManager().cache.toStringFillingRation("-> ")); //$NON-NLS-1$
240
		System.out.println(JavaModelManager.getJavaModelManager().cacheToString("-> ")); //$NON-NLS-1$
241
	}
241
	}
242
}
242
}
243
/**
243
/**
(-)model/org/eclipse/jdt/internal/core/JavaModelCache.java (+29 lines)
Lines 13-18 Link Here
13
import java.util.Map;
13
import java.util.Map;
14
14
15
import org.eclipse.jdt.core.IJavaElement;
15
import org.eclipse.jdt.core.IJavaElement;
16
import org.eclipse.jdt.internal.core.util.LRUCache;
16
17
17
/**
18
/**
18
 * The cache of java elements to their respective info.
19
 * The cache of java elements to their respective info.
Lines 26-31 Link Here
26
	public static final int DEFAULT_OPENABLE_SIZE = 500; // average 6629 bytes per openable (includes children) -> maximum size : 662900*BASE_VALUE bytes
27
	public static final int DEFAULT_OPENABLE_SIZE = 500; // average 6629 bytes per openable (includes children) -> maximum size : 662900*BASE_VALUE bytes
27
	public static final int DEFAULT_CHILDREN_SIZE = 500*20; // average 20 children per openable
28
	public static final int DEFAULT_CHILDREN_SIZE = 500*20; // average 20 children per openable
28
	
29
	
30
	public static final Object NON_EXISTING_JAR_TYPE_INFO = new Object();
31
29
	/*
32
	/*
30
	 * The memory ratio that should be applied to the above constants.
33
	 * The memory ratio that should be applied to the above constants.
31
	 */
34
	 */
Lines 61-66 Link Here
61
	 */
64
	 */
62
	protected Map childrenCache;
65
	protected Map childrenCache;
63
	
66
	
67
	/*
68
	 * Cache of open binary type (inside a jar) that have a non-open parent
69
	 */
70
	protected LRUCache jarTypeCache;
71
	
64
public JavaModelCache() {
72
public JavaModelCache() {
65
	// set the size of the caches in function of the maximum amount of memory available
73
	// set the size of the caches in function of the maximum amount of memory available
66
	double ratio = getMemoryRatio();
74
	double ratio = getMemoryRatio();
Lines 75-80 Link Here
75
		this.openableCache = new ElementCache((int) (DEFAULT_OPENABLE_SIZE * ratio));
83
		this.openableCache = new ElementCache((int) (DEFAULT_OPENABLE_SIZE * ratio));
76
	}
84
	}
77
	this.childrenCache = new HashMap((int) (DEFAULT_CHILDREN_SIZE * ratio));
85
	this.childrenCache = new HashMap((int) (DEFAULT_CHILDREN_SIZE * ratio));
86
	resetJarTypeCache();
78
}
87
}
79
88
80
/**
89
/**
Lines 93-98 Link Here
93
		case IJavaElement.COMPILATION_UNIT:
102
		case IJavaElement.COMPILATION_UNIT:
94
		case IJavaElement.CLASS_FILE:
103
		case IJavaElement.CLASS_FILE:
95
			return this.openableCache.get(element);
104
			return this.openableCache.get(element);
105
		case IJavaElement.TYPE:
106
			Object result = this.jarTypeCache.get(element);
107
			if (result != null)
108
				return result;
109
			else
110
				return this.childrenCache.get(element);
96
		default:
111
		default:
97
			return this.childrenCache.get(element);
112
			return this.childrenCache.get(element);
98
	}
113
	}
Lines 125-130 Link Here
125
		case IJavaElement.COMPILATION_UNIT:
140
		case IJavaElement.COMPILATION_UNIT:
126
		case IJavaElement.CLASS_FILE:
141
		case IJavaElement.CLASS_FILE:
127
			return this.openableCache.peek(element);
142
			return this.openableCache.peek(element);
143
		case IJavaElement.TYPE:
144
			Object result = this.jarTypeCache.peek(element);
145
			if (result != null)
146
				return result;
147
			else
148
				return this.childrenCache.get(element);
128
		default:
149
		default:
129
			return this.childrenCache.get(element);
150
			return this.childrenCache.get(element);
130
	}
151
	}
Lines 186-191 Link Here
186
			this.childrenCache.remove(element);
207
			this.childrenCache.remove(element);
187
	}
208
	}
188
}
209
}
210
protected void resetJarTypeCache() {
211
	this.jarTypeCache = new LRUCache((int) (DEFAULT_OPENABLE_SIZE * getMemoryRatio()));
212
}
213
public String toString() {
214
	return toStringFillingRation(""); //$NON-NLS-1$
215
}
189
public String toStringFillingRation(String prefix) {
216
public String toStringFillingRation(String prefix) {
190
	StringBuffer buffer = new StringBuffer();
217
	StringBuffer buffer = new StringBuffer();
191
	buffer.append(prefix);
218
	buffer.append(prefix);
Lines 201-206 Link Here
201
	buffer.append(prefix);
228
	buffer.append(prefix);
202
	buffer.append(this.openableCache.toStringFillingRation("Openable cache")); //$NON-NLS-1$
229
	buffer.append(this.openableCache.toStringFillingRation("Openable cache")); //$NON-NLS-1$
203
	buffer.append('\n');
230
	buffer.append('\n');
231
	buffer.append(this.jarTypeCache.toStringFillingRation("Jar type cache")); //$NON-NLS-1$
232
	buffer.append('\n');
204
	return buffer.toString();
233
	return buffer.toString();
205
}
234
}
206
}
235
}
(-)model/org/eclipse/jdt/internal/core/BinaryType.java (+6 lines)
Lines 274-279 Link Here
274
		}
274
		}
275
	}
275
	}
276
}
276
}
277
public Object getElementInfo(IProgressMonitor monitor) throws JavaModelException {
278
	JavaModelManager manager = JavaModelManager.getJavaModelManager();
279
	Object info = manager.getInfo(this);
280
	if (info != null && info != JavaModelCache.NON_EXISTING_JAR_TYPE_INFO) return info;
281
	return openWhenClosed(createElementInfo(), monitor);
282
}
277
/*
283
/*
278
 * @see IJavaElement
284
 * @see IJavaElement
279
 */
285
 */
(-)model/org/eclipse/jdt/internal/core/JavaModelManager.java (-1 / +19 lines)
Lines 817-823 Link Here
817
	/**
817
	/**
818
	 * Infos cache.
818
	 * Infos cache.
819
	 */
819
	 */
820
	public JavaModelCache cache;
820
	private JavaModelCache cache;
821
	
821
	
822
	/*
822
	/*
823
	 * Temporary cache of newly opened elements
823
	 * Temporary cache of newly opened elements
Lines 2464-2469 Link Here
2464
			this.cache.putInfo(element, info);
2464
			this.cache.putInfo(element, info);
2465
		}
2465
		}
2466
	}
2466
	}
2467
	
2468
	/*
2469
	 * Remember the info for the jar binary type
2470
	 */
2471
	protected synchronized void putJarTypeInfo(IJavaElement type, Object info) {
2472
		this.cache.jarTypeCache.put(type, info);
2473
	}
2467
2474
2468
	/**
2475
	/**
2469
	 * Reads the build state for the relevant project.
2476
	 * Reads the build state for the relevant project.
Lines 2654-2659 Link Here
2654
		// used by tests to simulate a startup
2661
		// used by tests to simulate a startup
2655
		MANAGER = new JavaModelManager();
2662
		MANAGER = new JavaModelManager();
2656
	}
2663
	}
2664
	
2665
	/*
2666
	 * Resets the cache that holds on binary type in jar files
2667
	 */
2668
	protected synchronized void resetJarTypeCache() {
2669
		this.cache.resetJarTypeCache();
2670
	}
2657
2671
2658
	/*
2672
	/*
2659
	 * Resets the temporary cache for newly created elements to null.
2673
	 * Resets the temporary cache for newly created elements to null.
Lines 3930-3933 Link Here
3930
		Util.resetJavaLikeExtensions();
3944
		Util.resetJavaLikeExtensions();
3931
		
3945
		
3932
	}
3946
	}
3947
3948
	public synchronized String cacheToString(String prefix) {
3949
		return this.cache.toStringFillingRation(prefix);
3950
	}
3933
}
3951
}
(-)model/org/eclipse/jdt/internal/core/util/LRUCache.java (-38 / +68 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.core.util;
11
package org.eclipse.jdt.internal.core.util;
12
12
13
import java.text.NumberFormat;
13
import java.util.Enumeration;
14
import java.util.Enumeration;
14
import java.util.Hashtable;
15
import java.util.Hashtable;
15
16
Lines 160-165 Link Here
160
		}
161
		}
161
		return newCache;
162
		return newCache;
162
	}
163
	}
164
	public double fillingRatio() {
165
		return (fCurrentSpace) * 100.0 / fSpaceLimit;
166
	}
163
	/**
167
	/**
164
	 * Flushes all entries from the cache.
168
	 * Flushes all entries from the cache.
165
	 */
169
	 */
Lines 290-295 Link Here
290
		return new LRUCache(size);
294
		return new LRUCache(size);
291
	}
295
	}
292
	/**
296
	/**
297
	 * Answers the value in the cache at the given key.
298
	 * If the value is not in the cache, returns null
299
	 *
300
	 * This function does not modify timestamps.
301
	 */
302
	public Object peek(Object key) {
303
		
304
		LRUCacheEntry entry = (LRUCacheEntry) fEntryTable.get(key);
305
		if (entry == null) {
306
			return null;
307
		}
308
		return entry._fValue;
309
	}
310
	/**
293
	 * Adds an entry for the given key/value/space.
311
	 * Adds an entry for the given key/value/space.
294
	 */
312
	 */
295
	protected void privateAdd (Object key, Object value, int space) {
313
	protected void privateAdd (Object key, Object value, int space) {
Lines 443-487 Link Here
443
			return 1;
461
			return 1;
444
		}
462
		}
445
	}
463
	}
446
/**
464
	/**
447
 * Returns a String that represents the value of this object.  This method
465
	 * Returns a String that represents the value of this object.  This method
448
 * is for debugging purposes only.
466
	 * is for debugging purposes only.
449
 */
467
	 */
450
public String toString() {
468
	public String toString() {
451
	return 
469
		return 
452
		"LRUCache " + (fCurrentSpace * 100.0 / fSpaceLimit) + "% full\n" + //$NON-NLS-1$ //$NON-NLS-2$
470
			toStringFillingRation("LRUCache") + //$NON-NLS-1$
453
		this.toStringContents();
471
			toStringContents();
454
}
455
/**
456
 * Returns a String that represents the contents of this object.  This method
457
 * is for debugging purposes only.
458
 */
459
protected String toStringContents() {
460
	StringBuffer result = new StringBuffer();
461
	int length = fEntryTable.size();
462
	Object[] unsortedKeys = new Object[length];
463
	String[] unsortedToStrings = new String[length];
464
	Enumeration e = this.keys();
465
	for (int i = 0; i < length; i++) {
466
		Object key = e.nextElement();
467
		unsortedKeys[i] = key;
468
		unsortedToStrings[i] = 
469
			(key instanceof org.eclipse.jdt.internal.core.JavaElement) ?
470
				((org.eclipse.jdt.internal.core.JavaElement)key).getElementName() :
471
				key.toString();
472
	}
473
	ToStringSorter sorter = new ToStringSorter();
474
	sorter.sort(unsortedKeys, unsortedToStrings);
475
	for (int i = 0; i < length; i++) {
476
		String toString = sorter.sortedStrings[i];
477
		Object value = this.get(sorter.sortedObjects[i]);
478
		result.append(toString);		
479
		result.append(" -> "); //$NON-NLS-1$
480
		result.append(value);
481
		result.append("\n"); //$NON-NLS-1$
482
	}
472
	}
483
	return result.toString();
473
	
484
}
474
	/**
475
	 * Returns a String that represents the contents of this object.  This method
476
	 * is for debugging purposes only.
477
	 */
478
	protected String toStringContents() {
479
		StringBuffer result = new StringBuffer();
480
		int length = fEntryTable.size();
481
		Object[] unsortedKeys = new Object[length];
482
		String[] unsortedToStrings = new String[length];
483
		Enumeration e = this.keys();
484
		for (int i = 0; i < length; i++) {
485
			Object key = e.nextElement();
486
			unsortedKeys[i] = key;
487
			unsortedToStrings[i] = 
488
				(key instanceof org.eclipse.jdt.internal.core.JavaElement) ?
489
					((org.eclipse.jdt.internal.core.JavaElement)key).getElementName() :
490
					key.toString();
491
		}
492
		ToStringSorter sorter = new ToStringSorter();
493
		sorter.sort(unsortedKeys, unsortedToStrings);
494
		for (int i = 0; i < length; i++) {
495
			String toString = sorter.sortedStrings[i];
496
			Object value = this.get(sorter.sortedObjects[i]);
497
			result.append(toString);		
498
			result.append(" -> "); //$NON-NLS-1$
499
			result.append(value);
500
			result.append("\n"); //$NON-NLS-1$
501
		}
502
		return result.toString();
503
	}
504
	
505
	public String toStringFillingRation(String cacheName) {
506
		StringBuffer buffer = new StringBuffer(cacheName);
507
		buffer.append('[');
508
		buffer.append(getSpaceLimit());
509
		buffer.append("]: "); //$NON-NLS-1$
510
		buffer.append(NumberFormat.getInstance().format(fillingRatio()));
511
		buffer.append("% full"); //$NON-NLS-1$
512
		return buffer.toString();
513
	}
514
485
	/**
515
	/**
486
	 * Updates the timestamp for the given entry, ensuring that the queue is 
516
	 * Updates the timestamp for the given entry, ensuring that the queue is 
487
	 * kept in correct order.  The entry must exist
517
	 * kept in correct order.  The entry must exist
(-)src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java (-3 / +12 lines)
Lines 374-380 Link Here
374
			"Focus: Y [in Y.class [in p [in " + externalJar2 + " [in P]]]]\n" + 
374
			"Focus: Y [in Y.class [in p [in " + externalJar2 + " [in P]]]]\n" + 
375
			"Super types:\n" + 
375
			"Super types:\n" + 
376
			"  X [in X.class [in p [in " + externalJar1 + " [in P]]]]\n" + 
376
			"  X [in X.class [in p [in " + externalJar1 + " [in P]]]]\n" + 
377
			"    Object [in Object.class [in java.lang [in "+ getExternalJCLPathString() + " [in TypeHierarchy]]]]\n" + 
377
			"    Object [in Object.class [in java.lang [in "+ getExternalJCLPathString() + " [in P]]]]\n" + 
378
			"Sub types:\n",
378
			"Sub types:\n",
379
			focus.newTypeHierarchy(null)
379
			focus.newTypeHierarchy(null)
380
		);
380
		);
Lines 721-727 Link Here
721
			"Sub types of root classes:\n" + 
721
			"Sub types of root classes:\n" + 
722
			"  X [in X.java [in <default> [in <project root> [in P1]]]]\n" + 
722
			"  X [in X.java [in <default> [in <project root> [in P1]]]]\n" + 
723
			"    Z [in Z.java [in <default> [in <project root> [in P3]]]]\n" + 
723
			"    Z [in Z.java [in <default> [in <project root> [in P3]]]]\n" + 
724
			"    Y [in Y.java [in <default> [in <project root> [in P2]]]]\n",
724
			"    Y [in Y.java [in <default> [in <project root> [in P2]]]]\n" + 
725
			"  Throwable [in Throwable.class [in java.lang [in "+ getExternalJCLPathString() + " [in P1]]]]\n" + 
726
			"    Exception [in Exception.class [in java.lang [in "+ getExternalJCLPathString() + " [in P1]]]]\n" + 
727
			"      RuntimeException [in RuntimeException.class [in java.lang [in "+ getExternalJCLPathString() + " [in P1]]]]\n" + 
728
			"        IllegalMonitorStateException [in IllegalMonitorStateException.class [in java.lang [in "+ getExternalJCLPathString() + " [in P1]]]]\n" + 
729
			"      InterruptedException [in InterruptedException.class [in java.lang [in "+ getExternalJCLPathString() + " [in P1]]]]\n" + 
730
			"      CloneNotSupportedException [in CloneNotSupportedException.class [in java.lang [in "+ getExternalJCLPathString() + " [in P1]]]]\n" + 
731
			"    Error [in Error.class [in java.lang [in "+ getExternalJCLPathString() + " [in P1]]]]\n" + 
732
			"  String [in String.class [in java.lang [in "+ getExternalJCLPathString() + " [in P1]]]]\n" + 
733
			"  Class [in Class.class [in java.lang [in "+ getExternalJCLPathString() + " [in P1]]]]\n",
725
			hierarchy);
734
			hierarchy);
726
	} finally {
735
	} finally {
727
		deleteProjects(new String[] {"P1", "P2", "P3"});
736
		deleteProjects(new String[] {"P1", "P2", "P3"});
Lines 753-759 Link Here
753
		assertHierarchyEquals(
762
		assertHierarchyEquals(
754
			"Focus: Member [in X [in X.java [in <default> [in <project root> [in P1]]]]]\n" + 
763
			"Focus: Member [in X [in X.java [in <default> [in <project root> [in P1]]]]]\n" + 
755
			"Super types:\n" + 
764
			"Super types:\n" + 
756
			"  Object [in Object.class [in java.lang [in "+ getExternalJCLPathString() + " [in P1]]]]\n" + 
765
			"  Object [in Object.class [in java.lang [in "+ getExternalJCLPathString() + " [in P2]]]]\n" + 
757
			"Sub types:\n" + 
766
			"Sub types:\n" + 
758
			"  Y [in Y.java [in <default> [in <project root> [in P2]]]]\n",
767
			"  Y [in Y.java [in <default> [in <project root> [in P2]]]]\n",
759
			hierarchy);
768
			hierarchy);

Return to bug 121652