This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: SV: SV: Adding another configuration feature to libjava forarm-elfmetal configurations


chris burdess wrote:
why not just use cpp? e.g.:

public class t
{
  public static void main(String[] args)
  {
#ifdef MYVAR
    System.out.println("Compiled with MYVAR");
#endif
    System.out.println("Hello world!");
  }
}

What I'll be switching to in Kawa is this:


  public Class getReflectClass()
  {
  ...
    /* BEGIN JAVA2 - uses optional 'initialize' argument */
    reflectClass = Class.forName(getInternalName().replace('/', '.'),
				 false, getClass().getClassLoader());
    /* END JAVA2 */
    /* BEGIN JAVA1 */
    // reflectClass = Class.forName(getInternalName().replace('/', '.'));
    /* END JAVA1 */
  ...
  }

The default mode is that the Java 2 version of a piece of code
is active, and the Java 1 work-around is commented-out.  However,
it is easy to used a sed (for example) to convert the code for
the Java 1 version and comment-out the Java2 version.  One could
use make PATH rules to select the pre-processed version.

For multiple configurations, one could have multiple attributes,
instead of JAVA2 vs JAVA1.

An advantage of this scheme is that the source file is real Java,
which all editors and tools understand.  The normal full-featured
version is right there, but it is easy to make variants, and to
keep them in synch.  And if you decide to change add conditionals
to a file to didn't use to have them, just add them.  You don't
need to rename the file or even edit the Makefile.am.  Another
advantage is that it is less like that people will inadvertently
send you patches for the pre-processed file rather than the source
file - in the normal case, they're the same.
--
	--Per Bothner
per@bothner.com   http://per.bothner.com/



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]