StringBuffer buffer= new StringBuffer(); BufferedReader reader= new BufferedReader(new InputStreamReader(process.getInputStream())); try { int result= 0; while (reader.ready()) { result= reader.read(); if (result >= 0) buffer.append((char) result); } String string= buffer.toString(); int start= string.indexOf(RESULT_PREFIX); if (start >= 0) { int end= string.indexOf(RESULT_POSTFIX, start); if (end >= 0) fSerialVersionID= Long.valueOf(string.substring(start + RESULT_PREFIX.length(), end)).longValue(); } } catch (IOException exception) { JavaPlugin.log(exception); fErrorMessage= exception.getLocalizedMessage(); } buffer= new StringBuffer(); reader= new BufferedReader(new InputStreamReader(process.getErrorStream())); try { int result= 0; while (reader.ready()) { result= reader.read(); if (result >= 0) buffer.append((char) result); } String string= buffer.toString(); int start= string.indexOf(ERROR_PREFIX); if (start >= 0) { int end= string.indexOf(ERROR_POSTFIX, start); if (end >= 0) fErrorMessage= string.substring(start + ERROR_PREFIX.length(), end); } } catch (IOException exception) { JavaPlugin.log(exception); fErrorMessage= exception.getLocalizedMessage(); }
monitor.worked(10); final String directory= System.getProperty("java.io.tmpdir"); if (directory != null && !"".equals(directory)) { final String separator= System.getProperty("file.separator"); if (separator != null && !"".equals(separator)) { final File file= new File(directory + separator + TEMP_FILE_NAME); if (file.exists()) { monitor.worked(40); file.deleteOnExit(); BufferedReader reader= null; final List lines= new ArrayList(); try { reader= new BufferedReader(new InputStreamReader(new FileInputStream(file), TEMP_FILE_ENCODING)); while (reader.ready()) { final String line= reader.readLine(); if (line != null && !"".equals(line)) lines.add(line); } } catch (IOException exception) { fErrorMessage= exception.getLocalizedMessage(); } finally { if (reader != null) { try { reader.close(); } catch (IOException exception) {  } } } fSerialVersionID= new long[lines.size()]; for (int index= 0; index < fSerialVersionID.length; index++) { final String line= (String) lines.get(index); try { fSerialVersionID[index]= Long.parseLong(line); } catch (NumberFormatException exception) { fSerialVersionID[index]= AbstractSerialVersionProposal.SERIAL_VALUE; fErrorMessage= line; } } } else fErrorMessage= CorrectionMessages.SerialVersionLaunchConfigurationDelegate_temp_file_not_exists; } else fErrorMessage= CorrectionMessages.SerialVersionLaunchConfigurationDelegate_error_getting_separator_property; } else fErrorMessage= CorrectionMessages.SerialVersionLaunchConfigurationDelegate_error_getting_temp_dir_property;
		public final void run(final VMRunnerConfiguration configuration, final ILaunch launch, final IProgressMonitor monitor) throws CoreException {			Assert.isNotNull(configuration);			Assert.isNotNull(launch);			Assert.isNotNull(monitor);			final IProgressMonitor subMonitor= new SubProgressMonitor(monitor, 1);			subMonitor.beginTask(CorrectionMessages.SerialVersionLaunchConfigurationDelegate_launching_vm, 2);			try {				subMonitor.subTask(CorrectionMessages.SerialVersionLaunchConfigurationDelegate_constructing_command_line);				final List arguments= new ArrayList();				arguments.add(getJavaExecutable(configuration));				final String[] vmArguments= combineVmArgs(configuration, fInstall);				for (int index= 0; index < vmArguments.length; index++)					arguments.add(vmArguments[index]);				String[] bootClassPath= configuration.getBootClassPath();				final String[] classPath= configuration.getClassPath();				String[] combinedClassPath= null;				LibraryLocation[] locations= null;				if (bootClassPath == null) {					locations= JavaRuntime.getLibraryLocations(fInstall);					bootClassPath= new String[locations.length];					for (int index= 0; index < locations.length; index++)						bootClassPath[index]= locations[index].getSystemLibraryPath().toOSString();				}				combinedClassPath= new String[bootClassPath.length + classPath.length];				int offset= 0;				for (int index= 0; index < bootClassPath.length; index++) {					combinedClassPath[offset]= bootClassPath[index];					offset++;				}				for (int index= 0; index < classPath.length; index++) {					combinedClassPath[offset]= classPath[index];					offset++;				}				if (combinedClassPath.length > 0) {					arguments.add("-classpath"); //$NON-NLS-1$					arguments.add(flattenClassPath(combinedClassPath));				}				arguments.add(configuration.getClassToLaunch());				final String[] programArguments= configuration.getProgramArguments();				for (int index= 0; index < programArguments.length; index++)					arguments.add(programArguments[index]);				final String[] commandLine= new String[arguments.size()];				arguments.toArray(commandLine);				if (monitor.isCanceled())					return;				subMonitor.worked(1);				subMonitor.subTask(CorrectionMessages.SerialVersionLaunchConfigurationDelegate_starting_vm);				final Process process= exec(commandLine, null);				if (process != null) {					try {						process.waitFor();					} catch (InterruptedException exception) {						// Do nothing					}					StringBuffer buffer= new StringBuffer();					BufferedReader reader= new BufferedReader(new InputStreamReader(process.getInputStream()));					try {						int result= 0;						while (reader.ready()) {							result= reader.read();							if (result >= 0)								buffer.append((char) result);						}						String string= buffer.toString();						int start= string.indexOf(RESULT_PREFIX);						if (start >= 0) {							int end= string.indexOf(RESULT_POSTFIX, start);							if (end >= 0)								fSerialVersionID= Long.valueOf(string.substring(start + RESULT_PREFIX.length(), end)).longValue();						}					} catch (IOException exception) {						JavaPlugin.log(exception);						fErrorMessage= exception.getLocalizedMessage();					}					buffer= new StringBuffer();					reader= new BufferedReader(new InputStreamReader(process.getErrorStream()));					try {						int result= 0;						while (reader.ready()) {							result= reader.read();							if (result >= 0)								buffer.append((char) result);						}						String string= buffer.toString();						int start= string.indexOf(ERROR_PREFIX);						if (start >= 0) {							int end= string.indexOf(ERROR_POSTFIX, start);							if (end >= 0)								fErrorMessage= string.substring(start + ERROR_PREFIX.length(), end);						}					} catch (IOException exception) {						JavaPlugin.log(exception);						fErrorMessage= exception.getLocalizedMessage();					}					if (monitor.isCanceled())						process.destroy();				}			} finally {				subMonitor.done();			}		}