Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 286453
Collapse All | Expand All

(-)src/org/eclipse/equinox/launcher/Main.java (-47 / +85 lines)
Lines 289-294 Link Here
289
	private String getWS() {
289
	private String getWS() {
290
		if (ws != null)
290
		if (ws != null)
291
			return ws;
291
			return ws;
292
293
		String osgiWs = System.getProperty("osgi.ws"); //$NON-NLS-1$
294
		if (osgiWs != null) {
295
			ws = osgiWs;
296
			return ws;
297
		}
298
292
		String osName = getOS();
299
		String osName = getOS();
293
		if (osName.equals(Constants.OS_WIN32))
300
		if (osName.equals(Constants.OS_WIN32))
294
			return Constants.WS_WIN32;
301
			return Constants.WS_WIN32;
Lines 307-312 Link Here
307
		return Constants.WS_UNKNOWN;
314
		return Constants.WS_UNKNOWN;
308
	}
315
	}
309
316
317
	private String getAlternateWS(String defaultWS) {
318
		// We'll have already tried the default, so we only need to map
319
		// in one direction. (default -> alternate)
320
		if (Constants.WS_CARBON.equals(defaultWS))
321
			return Constants.WS_COCOA;
322
		if (Constants.WS_GTK.equals(defaultWS))
323
			return Constants.WS_MOTIF;
324
		if (Constants.WS_WIN32.equals(defaultWS))
325
			return Constants.WS_WPF;
326
		return Constants.WS_UNKNOWN;
327
	}
328
310
	private String getOS() {
329
	private String getOS() {
311
		if (os != null)
330
		if (os != null)
312
			return os;
331
			return os;
Lines 350-355 Link Here
350
		return name;
369
		return name;
351
	}
370
	}
352
371
372
	private String getFragmentString(String fragmentOS, String fragmentWS, String fragmentArch) {
373
		StringBuffer buffer = new StringBuffer(PLUGIN_ID);
374
		buffer.append('.');
375
		buffer.append(fragmentWS);
376
		buffer.append('.');
377
		buffer.append(fragmentOS);
378
		if (!(fragmentOS.equals(Constants.OS_MACOSX) && !Constants.ARCH_X86_64.equals(fragmentArch))) {
379
			buffer.append('.');
380
			buffer.append(fragmentArch);
381
		}
382
		return buffer.toString();
383
	}
384
353
	/**
385
	/**
354
	 *  Sets up the JNI bridge to native calls
386
	 *  Sets up the JNI bridge to native calls
355
	 */
387
	 */
Lines 367-427 Link Here
367
		if (libPath == null) {
399
		if (libPath == null) {
368
			//find our fragment name
400
			//find our fragment name
369
			String fragmentOS = getOS();
401
			String fragmentOS = getOS();
402
			String fragmentWS = getWS();
370
			String fragmentArch = getArch();
403
			String fragmentArch = getArch();
371
			StringBuffer buffer = new StringBuffer(PLUGIN_ID);
404
372
			buffer.append('.');
405
			libPath = getLibraryPath(getFragmentString(fragmentOS, fragmentWS, fragmentArch), defaultPath);
373
			buffer.append(getWS());
406
			if (libPath == null && ws == null) {
374
			buffer.append('.');
407
				// no ws was specified and we didn't find the default fragment, try an alternate ws
375
			buffer.append(fragmentOS);
408
				String alternateWS = getAlternateWS(fragmentWS);
376
			if (!(fragmentOS.equals(Constants.OS_MACOSX) && !Constants.ARCH_X86_64.equals(fragmentArch))) {
409
				libPath = getLibraryPath(getFragmentString(fragmentOS, alternateWS, fragmentArch), defaultPath);
377
				buffer.append('.');
410
				if (libPath != null) {
378
				buffer.append(fragmentArch);
411
					System.getProperties().put("osgi.ws", alternateWS); //$NON-NLS-1$
412
				}
379
			}
413
			}
380
			String fragmentName = buffer.toString();
414
		}
381
			String fragment = null;
415
		library = libPath;
382
			if (inDevelopmentMode) {
416
		if (library != null)
383
				String devPathList = devClassPathProps.getProperty(PLUGIN_ID);
417
			bridge = new JNIBridge(library);
384
				String[] locations = getArrayFromList(devPathList);
418
	}
385
				if (locations.length > 0) {
419
386
					File location = new File(locations[0]);
420
	private String getLibraryPath(String fragmentName, URL[] defaultPath) {
387
					if (location.isAbsolute()) {
421
		String libPath = null;
388
						String dir = location.getParent();
422
		String fragment = null;
389
						fragment = searchFor(fragmentName, dir);
423
		if (inDevelopmentMode) {
390
						if (fragment != null)
424
			String devPathList = devClassPathProps.getProperty(PLUGIN_ID);
391
							libPath = getLibraryFromFragment(fragment);
425
			String[] locations = getArrayFromList(devPathList);
392
					}
426
			if (locations.length > 0) {
427
				File location = new File(locations[0]);
428
				if (location.isAbsolute()) {
429
					String dir = location.getParent();
430
					fragment = searchFor(fragmentName, dir);
431
					if (fragment != null)
432
						libPath = getLibraryFromFragment(fragment);
393
				}
433
				}
394
			}
434
			}
395
			if (libPath == null && bootLocation != null) {
435
		}
396
				URL[] urls = defaultPath;
436
		if (libPath == null && bootLocation != null) {
397
				if (urls != null && urls.length > 0) {
437
			URL[] urls = defaultPath;
398
					//the last one is most interesting
438
			if (urls != null && urls.length > 0) {
399
					for (int i = urls.length - 1; i >= 0 && libPath == null; i--) {
439
				//the last one is most interesting
400
						File entryFile = new File(urls[i].getFile());
440
				for (int i = urls.length - 1; i >= 0 && libPath == null; i--) {
401
						String dir = entryFile.getParent();
441
					File entryFile = new File(urls[i].getFile());
402
						if (inDevelopmentMode) {
442
					String dir = entryFile.getParent();
403
							String devDir = dir + "/" + PLUGIN_ID + "/fragments"; //$NON-NLS-1$ //$NON-NLS-2$
443
					if (inDevelopmentMode) {
404
							fragment = searchFor(fragmentName, devDir);
444
						String devDir = dir + "/" + PLUGIN_ID + "/fragments"; //$NON-NLS-1$ //$NON-NLS-2$
405
						}
445
						fragment = searchFor(fragmentName, devDir);
406
						if (fragment == null)
407
							fragment = searchFor(fragmentName, dir);
408
						if (fragment != null)
409
							libPath = getLibraryFromFragment(fragment);
410
					}
446
					}
447
					if (fragment == null)
448
						fragment = searchFor(fragmentName, dir);
449
					if (fragment != null)
450
						libPath = getLibraryFromFragment(fragment);
411
				}
451
				}
412
			}
452
			}
413
			if (libPath == null) {
414
				URL install = getInstallLocation();
415
				String location = install.getFile();
416
				location += "/plugins/"; //$NON-NLS-1$
417
				fragment = searchFor(fragmentName, location);
418
				if (fragment != null)
419
					libPath = getLibraryFromFragment(fragment);
420
			}
421
		}
453
		}
422
		library = libPath;
454
		if (libPath == null) {
423
		if (library != null)
455
			URL install = getInstallLocation();
424
			bridge = new JNIBridge(library);
456
			String location = install.getFile();
457
			location += "/plugins/"; //$NON-NLS-1$
458
			fragment = searchFor(fragmentName, location);
459
			if (fragment != null)
460
				libPath = getLibraryFromFragment(fragment);
461
		}
462
		return libPath;
425
	}
463
	}
426
464
427
	private String getLibraryFromFragment(String fragment) {
465
	private String getLibraryFromFragment(String fragment) {

Return to bug 286453