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

Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/JavaModelManager.java (-1 / +2 lines)
Lines 175-181 Link Here
175
		public IPath getPath() { return null; }
175
		public IPath getPath() { return null; }
176
		public String toString() { return getDescription(); }
176
		public String toString() { return getDescription(); }
177
	};
177
	};
178
	
178
	public final static String VARIABLE_INITIALIZATION_IN_PROGRESS_MESSAGE = "#@*!§_variable_initialization_in_progress_§!*@#"; //$NON-NLS-1$
179
179
	private static final String BUFFER_MANAGER_DEBUG = JavaCore.PLUGIN_ID + "/debug/buffermanager" ; //$NON-NLS-1$
180
	private static final String BUFFER_MANAGER_DEBUG = JavaCore.PLUGIN_ID + "/debug/buffermanager" ; //$NON-NLS-1$
180
	private static final String INDEX_MANAGER_DEBUG = JavaCore.PLUGIN_ID + "/debug/indexmanager" ; //$NON-NLS-1$
181
	private static final String INDEX_MANAGER_DEBUG = JavaCore.PLUGIN_ID + "/debug/indexmanager" ; //$NON-NLS-1$
181
	private static final String COMPILER_DEBUG = JavaCore.PLUGIN_ID + "/debug/compiler" ; //$NON-NLS-1$
182
	private static final String COMPILER_DEBUG = JavaCore.PLUGIN_ID + "/debug/compiler" ; //$NON-NLS-1$
(-)model/org/eclipse/jdt/core/JavaCore.java (-1 / +16 lines)
Lines 1749-1758 Link Here
1749
	 *
1749
	 *
1750
	 * @param variableName
1750
	 * @param variableName
1751
	 * @return A string if the classpath variable is deprecated, <code>null</code> otherwise.
1751
	 * @return A string if the classpath variable is deprecated, <code>null</code> otherwise.
1752
	 * 	{@link JavaModelManager#VARIABLE_INITIALIZATION_IN_PROGRESS_MESSAGE} special
1753
	 * 	string is returned when classpath variable was not initialized or if its initialization is not finished.
1752
	 * @since 3.3
1754
	 * @since 3.3
1753
	 */
1755
	 */
1754
	public static String getClasspathVariableDeprecationMessage(String variableName) {
1756
	public static String getClasspathVariableDeprecationMessage(String variableName) {
1755
	    return (String) JavaModelManager.getJavaModelManager().deprecatedVariables.get(variableName);
1757
	    JavaModelManager manager = JavaModelManager.getJavaModelManager();
1758
	    
1759
	    // Verify that classpath variable has been initialized
1760
		IPath variablePath = manager.variableGet(variableName);
1761
		if (variablePath == JavaModelManager.VARIABLE_INITIALIZATION_IN_PROGRESS){
1762
		    return JavaModelManager.VARIABLE_INITIALIZATION_IN_PROGRESS_MESSAGE;
1763
		}
1764
		if (variablePath == null) {
1765
			getClasspathVariable(variableName); // start variable initialization
1766
		    return JavaModelManager.VARIABLE_INITIALIZATION_IN_PROGRESS_MESSAGE;
1767
		}
1768
		
1769
		// Returns the stored deprecation message
1770
	    return (String) manager.deprecatedVariables.get(variableName);
1756
	}
1771
	}
1757
1772
1758
	/**
1773
	/**
(-)src/org/eclipse/jdt/core/tests/model/ClasspathInitializerTests.java (+28 lines)
Lines 1317-1322 Link Here
1317
}
1317
}
1318
1318
1319
/**
1319
/**
1320
 * @bug 186113: [model] classpath variable deprecation messages not initialized when called
1321
 * @test Verify that deprecation message can be get through {@link JavaCore#getClasspathVariableDeprecationMessage(String)}
1322
 * 	even if the variable initializer was not called before
1323
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=186113"
1324
 */
1325
public void testVariableInitializerBug186113_Initializing() throws CoreException {
1326
	assertEquals("Invalid deprecation message!",
1327
		JavaModelManager.VARIABLE_INITIALIZATION_IN_PROGRESS_MESSAGE,
1328
		JavaCore.getClasspathVariableDeprecationMessage("TEST_DEPRECATED_READ_ONLY")
1329
	);
1330
}
1331
public void testVariableInitializerBug186113_Ready() throws CoreException, InterruptedException {
1332
	String message = JavaCore.getClasspathVariableDeprecationMessage("TEST_DEPRECATED_READ_ONLY");
1333
	int n = 0;
1334
	while (message == JavaModelManager.VARIABLE_INITIALIZATION_IN_PROGRESS_MESSAGE) {
1335
		Thread.sleep(100);
1336
		if (++n >= 10) {
1337
			throw new InterruptedException("TEST_DEPRECATED_READ_ONLY should have been initialized after 1s!!!");
1338
		}
1339
		message = JavaCore.getClasspathVariableDeprecationMessage("TEST_DEPRECATED_READ_ONLY");
1340
	}
1341
	assertEquals("Invalid deprecation message!",
1342
		"A deprecated and read-only initializer",
1343
		message
1344
	);
1345
}
1346
1347
/**
1320
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=61872"
1348
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=61872"
1321
 */
1349
 */
1322
public void testUserLibraryInitializer1() throws CoreException {
1350
public void testUserLibraryInitializer1() throws CoreException {

Return to bug 186113