Bug 12818 - API: Expose OS/ARCH/WS values
Summary: API: Expose OS/ARCH/WS values
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Resources (show other bugs)
Version: 2.0   Edit
Hardware: Other other
: P3 normal (vote)
Target Milestone: 2.0 M6   Edit
Assignee: DJ Houghton CLA
QA Contact:
URL:
Whiteboard:
Keywords: api
Depends on:
Blocks:
 
Reported: 2002-04-04 13:26 EST by DJ Houghton CLA
Modified: 2002-05-07 18: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 DJ Houghton CLA 2002-04-04 13:26:53 EST
It would be useful (for PDE) to expose the os/ws/arch constants in BootLoader.
Proposed names would be:

String[] getOSList();
String[] getWSList();
String[] getArchList();
Comment 1 John Arthorne CLA 2002-04-04 14:47:30 EST
Why is this useful?

It's a dangerous game to be exposing these values in general.  It requires 
us to have complete knowledge of all OS and ARCH configurations that Eclipse 
will run on (which we don't).  We would be playing a constant game of catchup to 
maintain these lists.  For example, we only currently have an ARCH constant for 
x86.

These constants also bind us to supporting values that the JDK itself does not 
guarantee.  It is not specified anywhere (that I know of) what value is returned 
for the properties os.name and os.arch across VM implementations.  We already 
play games internally to handle some VMs that print different values for x86 and 
SunOS than Sun VMs do.  This could get much worse as the number of target 
platforms increases.
Comment 2 Dejan Glozic CLA 2002-04-04 14:56:07 EST
PDE has a preference page that allows users to set the values of os/ws/nl/arch 
variables. By default, the combo boxes are set to the values returned by the 
design-time instance BootLoader, but can be changed. This is important for 
resolving variables in library entires that contain $<var>$ entries, like SWT 
($ws$/swt.jar). 

Since PDE uses combo boxes, it must populate these combo boxes with some fixed 
list. Combo boxes are editable i.e. users can set variable values that are not 
in the list. However, it is not appropriate for PDE to supply the list values 
because BootLoader knows better what values are currently supported. As new 
values are added, the list can be updated. We are not asking for a list of ALL 
values that will EVER be supported. We are asking only for the list of values 
that are CURRENTLY supported by the platform. Users developing code for new 
OS/WS/ARCH combinations can enter the values manually (i.e. not from the list).
Comment 3 John Arthorne CLA 2002-04-15 14:49:37 EDT
Is it even possible for the OS and ARCH values to change between development 
workspace and runtime workspace?
Comment 4 Dejan Glozic CLA 2002-04-15 14:58:04 EDT
It is possible although not for the purpose of launching. This is the scenario:

1) A large plug-in contains some common and some platform-specific code
2) The developer starts with default (design-time) variables. All the 
classpaths are resolved to point to Win32 libraries.
3) The developer switches target environment to linux, updates the classpath. 
All the libraries now point to linux versions. Of course, the developer cannot 
run (on Windows) but can compile correctly.

The plug-in in question is SWT.
Comment 5 DJ Houghton CLA 2002-05-02 18:50:37 EDT
Adding Jeem to CC for comments on API changes.
Comment 6 Jim des Rivieres CLA 2002-05-03 14:19:51 EDT
/**
 * Returns a list of known system architectures.
 * <p>
 * Note that this list is not authoritative; there may be legal values
 * not included in this list. Indeed, the value returned by 
 * <code>getOSArch</code> may not be in this list. Also, this list may 
 * change over time as Eclipse comes to run on more operating environments.
 * </p>
 * 
 * @return the list of system architectures known to the system
 * @see #getOSArch
 * @since 2.0
 */
public static String[] knownOSArchValues();

/**
 * Returns a list of known operating system names.
 * <p>
 * Note that this list is not authoritative; there may be legal values
 * not included in this list. Indeed, the value returned by 
 * <code>getOS</code> may not be in this list. Also, this list may 
 * change over time as Eclipse comes to run on more operating environments.
 * </p>
 * 
 * @return the list of operating systems known to the system
 * @see #getOS
 * @since 2.0
 */
public static String[] knownOSValues();

/**
 * Returns a list of known windowing system names.
 * <p>
 * Note that this list is not authoritative; there may be legal values
 * not included in this list. Indeed, the value returned by 
 * <code>getWS</code> may not be in this list. Also, this list may 
 * change over time as Eclipse comes to run on more operating environments.
 * </p>
 * 
 * @return the list of window systems known to the system
 * @see #getWS
 * @since 2.0
 */
public static String[] knownWSValues();
Comment 7 Dejan Glozic CLA 2002-05-03 14:58:17 EDT
I would advise changing APIs to match Java naming conventions as follows:

Change:

public static String[] knownOSArchValues();
public static String[] knownOSValues();
public static String[] knownWSValues();

to:

public static String[] getKnownOSArchValues();
public static String[] getKnownOSValues();
public static String[] getKnownWSValues();



Comment 8 Jim des Rivieres CLA 2002-05-03 15:41:39 EDT
"get" and "set" are standard prefixes for accessor methods.
In a case like this, where there is no field being accessed (not even 
conceptually), it is common to not consider such methods as accessors.

The names without the "get" prefix are shorter and just as clear
as the ones with.
Comment 9 DJ Houghton CLA 2002-05-06 11:45:37 EDT
Implementation for OS (and WS) basically is the following:

if (user didn't specify -os) then
  if (System.getProperty() value is one we know) then
    os = BootLoader.constant_value;
  else
    os = BootLoader.UNKNOWN;
  endif
endif

Should we create an ARCH_UNKNOWN constant as well to remain consistent?
Comment 10 Jim des Rivieres CLA 2002-05-06 12:04:46 EDT
osArch cannot be unknown - if user does not specify, it is 
whatever the value of the java "os.arch" System property.
Comment 11 DJ Houghton CLA 2002-05-07 17:27:36 EDT
Fixed and released.
Added new BootLoader API:
  public static String[] knownOSArchValues();
  public static String[] knownOSValues();
  public static String[] knownWSValues();
Comment 12 Dejan Glozic CLA 2002-05-07 18:38:06 EDT
PDE updated from fixed lists to calls to these static methods.