Bug 92937 - Need API: JavaCore#initializeAfterLoad()
Summary: Need API: JavaCore#initializeAfterLoad()
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 RC1   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-04-27 12:05 EDT by Philipe Mulet CLA
Modified: 2005-05-27 07:38 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philipe Mulet CLA 2005-04-27 12:05:11 EDT
Build 3.1m6

In order to better initialize lazy structures, and provide an opportunity for UI
to avoid penalty for lazy inits on user action; JDT/Core should provide a hook
for performing reasonable initializations.

This hook would be invoked from JDT/UI post startup sequence, in background.
JDT/Core would not require this API to be called, it would only be some hint for
precaching information ahead of time.

Naming should be improved, but it has good reminescences for Envy/Smalltalk users.
Comment 1 Jim des Rivieres CLA 2005-04-27 12:16:26 EDT
approved - The spec should probably say that the initialization would be 
across all projects, and explain whether the call, which is long-running, is 
blocking or non-blocking.
Comment 2 Philipe Mulet CLA 2005-04-27 13:01:09 EDT
It would like take a progress monitor as well; and likely should be allowed to
grab the workspace lock (would be nice to remove this requirement though).

So far it should do:
1. cause CP initialization
2. dummy workspace search query (could induce 1 already + ensure index rebuild
occurs if necessary).
3. load build states ? unsure
Comment 3 Dirk Baeumer CLA 2005-04-27 13:05:59 EDT
Philippe, before we add this API we should discuss it in the polish team to
double check if this is the way to go. 
Comment 4 Philipe Mulet CLA 2005-04-28 12:07:02 EDT
Dirk - I even believe you should pioneer on this, and if you figure some set of
actions, we can encapsulate it in our land (now we provisionned an API addition
for it).
Comment 5 Kent Johnson CLA 2005-04-28 12:22:13 EDT
There is no need to load build states.

If the user does not do a build then he does not need them.
Comment 6 Philipe Mulet CLA 2005-04-28 12:37:08 EDT
I am only worried about the one scenario where user doesn't know his classpath
did change until he does a one method edit (think of container init
consequence), and he gets a huge fullbuild then; even though his machine was
idle for the past 30 minutes after startup.
Comment 7 Philipe Mulet CLA 2005-04-28 12:38:53 EDT
Actually 2 cases:
1. noticing that build states got obsoleted: this is more of a migration issue
(which is a separate issue). So I agree that loading build states will have no
effect.

2. checking early on possible CP change which could invalidate entire build state.
Comment 8 Kent Johnson CLA 2005-04-28 12:43:51 EDT
You're basically asking for an incremental build to happen on startup, or 
shortly after.

Even in the migration case, I'm not sure that is a good idea. I would prefer 
we add a call on JavaProject... something needsToBeBuilt(). We could ask one 
project on startup & if returns true, then cause an incremental build to 
happen.

But it should still be an option 'Detect workspace migration'.
Comment 9 Philipe Mulet CLA 2005-04-29 07:19:07 EDT
This is exactly what I had in mind. Note that in migration story, it would be
triggered by platform, and could be imposed as a one time effort.
Comment 10 Philipe Mulet CLA 2005-05-10 05:52:17 EDT
Dirk - do you need anything from us ? If so, pls reopen.
Comment 11 Dirk Baeumer CLA 2005-05-10 17:01:59 EDT
We should discuss this tomorrow on the architectur call again. I still don't
know what the overall opinion is.
Comment 12 Jerome Lanneluc CLA 2005-05-11 11:30:41 EDT
Will add JavaCore#initializeAfterLoad() which will do a dummy search query on a
workspace scope (this will also cause CP initialization to occur).
Comment 13 Jerome Lanneluc CLA 2005-05-18 08:49:25 EDT
Added the following API:
/**
 * Initializes JavaCore internal structures to allow subsequent operations (such 
 * as the ones that need a resolved classpath) to run full speed. A client may 
 * choose to call this method in a background thread early after the workspace 
 * has started so that the initialization is transparent to the user.
 * <p>
 * This initialization runs accross all Java projects in the workspace. 
 * </p><p>
 * This method doesn't return until the initialization is complete.
 * </p>
 * 
 * @param monitor a progress monitor, or <code>null</code> if progress
 *    reporting and cancellation are not desired
 * @exception CoreException if the initialization fails, 
 * 		the status of the exception indicates the reason of the failure
 * @since 3.1
 */
public static void initializeAfterLoad(IProgressMonitor monitor) throws
CoreException

Added test JavaModelTests#testInitializeAfterLoad()
Comment 14 Philipe Mulet CLA 2005-05-18 09:04:53 EDT
It should also say:
- calling it is optional. Services will lazily perform initialization when
invoked. This is only a way to reduce initialization overhead on user actions,
if it can be performed before at some appropriate moment.

- calling it concurrently is allowed

- what scheduling rule is required ?
Comment 15 Jerome Lanneluc CLA 2005-05-18 09:39:21 EDT
Improved spec:
/**
 * Initializes JavaCore internal structures to allow subsequent operations (such 
 * as the ones that need a resolved classpath) to run full speed. A client may 
 * choose to call this method in a background thread early after the workspace 
 * has started so that the initialization is transparent to the user.
 * <p>
 * However calling this method is optional. Services will lazily perform 
 * initialization when invoked. This is only a way to reduce initialization 
 * overhead on user actions, if it can be performed before at some 
 * appropriate moment.
 * </p><p>
 * This initialization runs accross all Java projects in the workspace. Thus the
 * workspace root scheduling rule is used during this operation.
 * </p><p>
 * This method doesn't return until the initialization is complete.
 * </p><p>
 * This method can be called concurrently.
 * </p>
 * 
 * @param monitor a progress monitor, or <code>null</code> if progress
 *    reporting and cancellation are not desired
 * @exception CoreException if the initialization fails, 
 * 		the status of the exception indicates the reason of the failure
 * @since 3.1
 */
public static void initializeAfterLoad(IProgressMonitor monitor) throws
CoreException 
Comment 16 Dirk Baeumer CLA 2005-05-18 11:59:21 EDT
Jerome, 

I looked at the code of the method and noticed that it reuses the progress
monitor for both calls instead of creating sub progress monitors
Comment 17 Jerome Lanneluc CLA 2005-05-18 12:28:38 EDT
Thanks Dirk. Fixed initializeAfterLoad(...) to use SubProgressMonitors.
Comment 18 Jerome Lanneluc CLA 2005-05-19 09:10:12 EDT
After discussion with Dirk, it was decided to change the API to be non-bloking.
It now looks like:
/**
 * Initializes JavaCore internal structures to allow subsequent operations (such 
 * as the ones that need a resolved classpath) to run full speed. A client may 
 * choose to call this method in a background thread early after the workspace 
 * has started so that the initialization is transparent to the user.
 * <p>
 * However calling this method is optional. Services will lazily perform 
 * initialization when invoked. This is only a way to reduce initialization 
 * overhead on user actions, if it can be performed before at some 
 * appropriate moment.
 * </p><p>
 * This initialization runs accross all Java projects in the workspace. Thus the
 * workspace root scheduling rule is used during this operation.
 * </p><p>
 * This method may return before the initialization is complete. The 
 * initialization will then continue in a background thread.
 * </p><p>
 * This method can be called concurrently.
 * </p>
 * 
 * @param monitor a progress monitor, or <code>null</code> if progress
 *    reporting and cancellation are not desired
 * @exception CoreException if the initialization fails, 
 * 		the status of the exception indicates the reason of the failure
 * @since 3.1
 */
public static void initializeAfterLoad(IProgressMonitor monitor) throws
CoreException
Comment 19 David Audel CLA 2005-05-27 07:38:15 EDT
Verified in i20050527-0010