Source:
public static ITargetPlatformHelper createTargetPlatform(final String location, IProgressMonitor monitor) throws CoreException { boolean isOk = false; final ITargetPlatformService service = PDEHelper.getTargetService(); final ITargetDefinition target = service.newTarget(); final TargetPlatformHelper info = new TargetPlatformHelper(target); try { final List<ITargetLocation> containers = new ArrayList<ITargetLocation>(); final File productDir = PDELocationUtils.getProductLocation(location); final ITargetLocation installationContainer = service .newProfileLocation(productDir.getAbsolutePath(), null); info.getQ7Target().setInstall(installationContainer); containers.add(installationContainer); final File pluginsDir = PDELocationUtils.getPluginFolder(location); final ITargetLocation pluginsContainer = service .newDirectoryLocation(pluginsDir.getAbsolutePath()); containers.add(pluginsContainer); final String localLocation = info.getUserArea(); if (localLocation != null) { try { final File localPluginsDir = PDELocationUtils.getPluginFolder(localLocation); final ITargetLocation localPluginsContainer = service .newDirectoryLocation(localPluginsDir.getAbsolutePath()); containers.add(localPluginsContainer); } catch (CoreException e) { Q7ExtLaunchingPlugin.getDefault().info(e.getMessage()); } } info.setBundleContainers(containers .toArray(new ITargetLocation[containers.size()])); throwOnError(info.resolve(monitor)); isOk = true; return info; } catch (StackOverflowError e) { throw createErrorProductLocationException(location, e); } catch (CoreException e) { throw e; } catch (Throwable e) { throw new CoreException(new Status(IStatus.ERROR, PLUGIN_ID, e.getMessage(), e)); } finally { if (!isOk) info.delete(); } }

Target:
public static ITargetPlatformHelper createTargetPlatform(final String location, IProgressMonitor monitor) throws CoreException { boolean isOk = false; final ITargetPlatformService service = PDEHelper.getTargetService(); final ITargetDefinition target = service.newTarget(); final TargetPlatformHelper info = new TargetPlatformHelper(target); try { final List<ITargetLocation> containers = new ArrayList<ITargetLocation>(); final File productDir = PDELocationUtils.getProductLocation(location); final ITargetLocation installationContainer = service .newProfileLocation(productDir.getAbsolutePath(), null); info.getQ7Target().setInstall(installationContainer); containers.add(installationContainer); final File pluginsDir = PDELocationUtils.getPluginFolder(location); final ITargetLocation pluginsContainer = service .newDirectoryLocation(pluginsDir.getAbsolutePath()); containers.add(pluginsContainer); final String localLocation = info.getUserArea(); if (localLocation != null) { try { final File localPluginsDir = PDELocationUtils.getPluginFolder(localLocation); final ITargetLocation localPluginsContainer = service .newDirectoryLocation(localPluginsDir.getAbsolutePath()); containers.add(localPluginsContainer); } catch (CoreException e) { if(e.getStatus().getCode() == EFS.ERROR_NOT_EXISTS) Q7ExtLaunchingPlugin.getDefault().info(e.getMessage()); else throw e; } } info.setBundleContainers(containers .toArray(new ITargetLocation[containers.size()])); throwOnError(info.resolve(monitor)); isOk = true; return info; } catch (StackOverflowError e) { throw createErrorProductLocationException(location, e); } catch (CoreException e) { throw e; } catch (Throwable e) { throw new CoreException(new Status(IStatus.ERROR, PLUGIN_ID, e.getMessage(), e)); } finally { if (!isOk) info.delete(); } }