Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!news2.arglkargh.de!news.musoftware.de!wum.musoftware.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Robert Klemme Newsgroups: comp.lang.java.programmer Subject: Re: preprocessor idea Date: Mon, 17 Oct 2011 18:53:34 +0200 Lines: 67 Message-ID: <9g34seFjqlU1@mid.individual.net> References: <4e94ce75$0$284$14726298@news.sunsite.dk> <9foia2FjbkU1@mid.individual.net> <4e97a33b$0$282$14726298@news.sunsite.dk> <9g127uF848U1@mid.individual.net> <4e9b93ce$0$284$14726298@news.sunsite.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable X-Trace: individual.net X06HgHu+Gfxo0ivOUMKAFgMjHR+h9IO6rg2St1uPigM8246zg= Cancel-Lock: sha1:6xFjOUnJ+Qkaovvcf72/5DLVpPo= User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.23) Gecko/20110922 Lightning/1.0b2 Thunderbird/3.1.15 In-Reply-To: <4e9b93ce$0$284$14726298@news.sunsite.dk> Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:8924 On 10/17/2011 04:32 AM, Arne Vajh=F8j wrote: > On 10/16/2011 5:56 PM, Robert Klemme wrote: >> On 10/14/2011 04:49 AM, Arne Vajh=F8j wrote: >>> On 10/13/2011 12:35 PM, Robert Klemme wrote: >>>> On 12.10.2011 01:17, Arne Vajh=F8j wrote: >> >>>>> Run the Java code through the C preprocessor with the same defines.= >>>>> >>>>> String[] javaarray =3D { >>>>> "None" >>>>> #ifdef lib1 >>>>> ,"lib1" >>>>> #endif >>>>> #ifdef lib1 >>>>> ,"lib1" >>>>> #endif >>>>> }; >>>> >>>> I do not think it's worthwhile to open that can of worms for this >>>> decision. After all getting rid of the CPP is one of the major >>>> advantages of Java over C++ (even Stroustrup regrets not having ripp= ed >>>> it out of C++) and complicating the Java build process just for that= >>>> decision seems too heavy - especially since there are other solution= s >>>> available. >>> >>> What other solution achieve the same? >> >> Please see elsewhere in this thread. > > Well - they do not seem to be on my news server. > > The only suggestion it carry are yours of: > * changing the logic, which may be a good idea, but is definitely > not the same Do you say that because of > Java does not support any preprocessor > flags, but in this case I need a tip for creating a flexiable Java code= during the class is compiled > (eg: ifdef1 =3D true =3D> String[] javaarray =3D {"lib1"}) ? Right, I took the liberty to ignore the specific requirement to=20 change the Java code because I consider the ultimate task to solve to=20 only load those libs which can be used. Changing the Java code is just=20 one means to that end. > * use JNI to get the info from the native side, which will > require approx. 10 as much code than this Well, but the solution to use CPP for Java code will probably need a=20 similar amount of code - even if it's not in Java but in ant scripts or=20 Makefiles. And it will be a dramatic change to the build process. One=20 also needs to decide whether to apply CPP to all Java files or just=20 selectively to a single one. The first option is probably cleaner from=20 a build process point of view but increases the risk of bugs (i.e. if=20 CPP starts replacing things in other files that it is not supposed to=20 change) while the second solution is an ugly crutch IMHO. Kind regards robert