Compiling differently for debug and release

I want to produce slightly different .class files for my debug and release compilations. For debug, methods like toString() should return rich information which should not be present in the release version. In fact, I want most of my debug specific code to not be included in the final release to keep ti's file size down.
I realise I can do this by creating something like
public interface MyGlobals {
    static final boolean DEBUG = false;
}and implementing this on any class that needs to do debug specific work. However, I'm in a bit of a chicken and egg scenerio. This file needs to exist during development time so that every class that needs it can implement it - however, this would prevent me from dynamically changing it based on whether I'm doing a debug or release build. On the other hand, if the file is generated automatically at compile time, all the classes that need to refer to it will need to refer to a non-existant source file, which will cause problems in my NetBeans IDE.
Is there a way around this? It would be nice if there was some sort of a configuration file you could specify to to alter how the code is generated. Something similar to C++ #ifdef.

I realise I can do this by creating something like
public interface MyGlobals {
static final boolean DEBUG = false;
/code]You should be careful about this, by the way, rember that this kind of constant value gets compiled in to classes that reference it, and java doesn't always pick up the need to recompile when the source of MyGlobals changes.
On the other hand, if you don't declare it final then the compiler can't optimise out code that you want it to exclude for you.

Similar Messages

  • Different environments created for Debug and Release libraries

    Environments created in Debug mode cannot be read by software compiled in release mode. The same is true for the reverse.
    Both libraries compiled with VS.NET 2005 (C++). The environment created in Debug mode is slightly different than the library created in the Release mode. I would assume that this is a bug?
    __db.001 - no change
    __db.002 - DIFFERENT
    __db.003 - no change
    __db.004 - no change
    __db.005 - DIFFERENT
    __db.006 - no change
    Aeronautical.dbxml - no change
    log.0000000001 - no change
    The environments are created using the following flags:
    // Flags required when opening the XmlDB Environment
    m_environmentFlags =      DB_CREATE |     // If the environment does not exist, create it.
                             DB_INIT_LOCK |     // Initialize the locking subsystem
                             DB_INIT_LOG |     // Initialize the logging subsystem
                             DB_INIT_MPOOL |     // Initialize the cache
                             DB_INIT_TXN |     // Initialize transactions
                             DB_THREAD;          // Ensure Environment is
                                                 // free-threaded
    The database contains a single XML document.
    An attempt to open() fails with the following error message:
    DbEnv::open: No such file or directory

    Hey Ron,
    Thanks for answering so quickly. Having release and debug builds able to manipulate the same environments is a requirement of convenience. Our project builds both release and debug versions of our software and distributes both versions to the development team daily. The team is encouraged and expected to run both debug and release builds to test their contributions and because the system opens the database (which is distributed with the build) upon startup, one of the two will always fail to load. That leaves us with two obvious solutions/workarounds. The first being to distribute the build with 2 environments and ensure that the build chooses the correct environment based on whether it is debug or release. The second is to rebuild the debug library without the --enable-diagnostic switch.
    We have no immediate need to enable the diagnostic information (that I am aware of...in fact I don't even know what types of checks are put in that would be helpful).
    Do you have an alternative solution that others have used as a work around for this?

  • Different behaviors of NSTask within Debug and Release configuraton

    Hey there,
    I am writing my first OSX application. It will be a starter helper for some daemons.
    In order to start the daemons I am using NSTask but this class behaves completely different within the two build configurations (Debug and Release).
    If I choose Debug - everything works fine, my daemon (apache) gets started. But if I choose Release, I get this error message in the log console:
    Jan 11 22:50:49 Synthomat [0x0-0x682682].com.yourcompany.PAMP[24421]: httpd (no pid file) not running
    I know, this is an apache specific error message. But why does it not appear when I choose the Debug environment? Are in Release some environment variables missing or so?
    Here is my code part:
    // get bundle path
    binDir = [NSString stringWithFormat:@"%@/Library/bin", [[NSBundle mainBundle] bundlePath]];
    // compose command path
    NSString *command = [NSString stringWithFormat:@"%@/apachectl", binDir];
    // run command
    [NSTask launchedTaskWithLaunchPath: command
    arguments:[NSArray arrayWithObjects:@"start", nil]];
    Any idea, anyone? - Thanks in advance

    synthomat wrote:
    My idea was to distribute a full web stack within my application. Thus there should't be touched other system directories or files except the ones in my application bundle.
    Launchctl is similar to xinetd. You can run it in user space out of your own directories.
    Its not the apache which comes with osx!
    Is it the same one in XAMPP?

  • What is the primary difference between Debug and Release build?

    I'm coming from the world of VS, where there's a clear distinction between a Release and Debug builds. In Xcode I can't seem to see how two are different and how would I benefit from, say, a Debug build. Can someone explain this for me?

    The differences between the Xcode debug and release builds are similar to the differences you'll find on any other system, though the Xcode interface might not present them as obviously. Basically, a debug build preserves all kinds of information that was developed during compilation but is no longer necessary at runtime. The presence or absence of this information (e.g. symbol tables and mappings which provide the original name of each source code variable and the source code line number corresponding to each instruction), becomes increasingly obvious as you use gdb and other debugging tools.
    We normally would never want to release a debug version (in the iOS case, of course, it would never be accepted) because the binary is usually much larger and the performance will probably be compromised as well. For example, a typical debug build will have many perfomance optimizations turned off because these can make debugging more difficult. It's also common to enable "assert" statements in a debug version. These will bring the program down rather than giving the user any options or attempting recovery.
    For more info specific to Xcode, see [Build Configurations|http://developer.apple.com/library/ios/documentation/DeveloperTo ols/Conceptual/XcodeBuildSystem/400-BuildConfigurations/build_configs.html#//appleref/doc/uid/TP40002692-SW7] in the +Xcode Build System Guide+. To get into lower level details, refer to the gcc docs, maybe starting with [3.9 Options for Debugging Your Program or GCC|http://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html]. You might also want to take a look at your Target Build Options for the Debug configuration (Project->Set Active SDK->Use Base SDK and Project->Edit Active Target->Build). There's a one-to-one mapping between many of these settings and the gcc options.
    \- Ray
    p.s.: Didn't mean to repeat Xnav's points. As usual, I was still editing long after he posted! To clarify one difference: Selecting the Edit Active Target menu item gets you to the same place as double clicking on the icon for the active target in the Targets group of the Groups & Files tree. - R
    Message was edited by: RayNewbie

  • I bought  my MacBook Pro in 2010. This is the first Mac I have owned and recently it is having some difficulty loading we pages, often timing out. This Mac environment is entirely different for me and I am not sure where to begin troubleshooting/clean-up.

    I bought  my MacBook Pro in 2010. This is the first Mac I have owned and recently it is having some difficulty loading we pages, often timing out. This Mac environment is entirely different for me and I am not sure where to begin troubleshooting and/ or clean-up. I have moderate computer skills and try not to download or access questionable material, however recently I visited the Ap Store and purchased a couple of different aps to use in record keeping and for making a flyer. I am not even sure how to remove these programs to see if it helps.
    Any tips or tricks are appreciated.
    Thank you!

    Time to see about the PRAM battery.
    By the way iOS and OS X are different systems.
    iOS is the operating system for iPads, iPhones, and iPod touch.
    Mac OS X is the operating system for Mac labelled computers.

  • Why is the Amber update different for ATT and Chin...

    Why is the Amber update different for ATT and China? For Lumia 520, it could tap to unlock but, in china, this function is disappeared disappear. Could you give an expain as the matching hardware, otherwise I think it's a definately discriminatory to Chinese.

    Double tap to unlock is not available for any 520, anywhere in the world. See link below. You should always check first before making allegations. 
    http://discussions.nokia.com/t5/Nokia-Lumia/quot-Missing-quot-new-features-in-Amber/td-p/2061872

  • USB sync cable different for CDMA and GSM version phones?

    I recently ordered a USB sync cable for Iphone 4S from ebay. I want to know whether the USB sync cable for Iphone 4S is different for CDMA and GSM version phones? And if they are then what are the likely consequences if they are interchanged and used inadvertantly.

    All recent iDevices use the same type of connector/cable.
    Stedman

  • What's the difference between task list release for order and release for c

    What's the difference between task list release for order and release for cost?

    Pallavi,
    The status of the task list determines in which other application areas the respective task list may be used.
    Release for costing: means that the task list can be used to calculate costs in Transaction IA16 i.e. the costs for the task list operations would be calculated if released for costing status is set.
    Release for use in the order: Released for Order means that you can use the task list in an order i.e. you could include operations from a task list in an order.
    Regards,
    Usman

  • How Long For Fixing and Release WPA/WPA2 on N900?

    Hay Nokia!!
    I use N900 Maemo PR1.2 Lasted update.
    At home i'm create WPA2-Shared-key (Belkin Router) it's worked.
    At Friend Home i'm used WPA2-Shared-key (Belkin, Lynksys, D-Link) it's  worked no problem.
    At Office i can not used WPA2-Shared-key with Lynksys difference model it's not worked, but many co-worker worked with iPhone.
    and My Friend use iPhone 3Gs worked with all WPA2 - Shared Key that i'm try with N900.
    i try change MAC by macchanger it's a same Not worked.
    i'm asking for Maemo.org they toll me it's BUGS -_-"
    How long For Fixing and Release??

    you will not get a response as other then the mods,  nokia folks do not really watch this blog.   your best bet is the maemo community where you were before.
    maemo.org

  • Conditional compile code for debug v.s. release

    Hi,
    Is there a pre-defined symbol (e.g., DEBUG, DEBUG) for conditional compile section of code for debug v.s. release?
    Thanks for your reply in advance!

    Take a look at TargetConditionals.h, I use TARGETIPHONESIMULATOR a lot.

  • Difference between debug and release

    Hallo,
    I'm in trouble with sending CAN-Message to servo-controllers (Lust).  In debug -mode all works fine, but in release it seem's that there some leaks in the message.
    I've already added some delays between send-orders, but it doesn't help.
    the CAN is a USB-adapter from PEAK.
    1. Does CVI make some changes as I include the peak.dll (included in my project) from debug to release?
    2. Is there some alternative of using the Delay-Command in windows?.
    greetings
    F.A.

    Debug mode and Release mode are different configurations for building your .Net
    project. Programmers generally use the Debug mode for debugging step by step
    their .Net project and select the Release mode for the final build of Assembly
    file (.dll or .exe). follow link for more information
    http://net-informations.com/faq/net/debug-release.​htm
    cros.
    http://net-informations.com

  • Debug and release desktop app as mobile

    I built an app in Flash Pro where I could easily export an AIR app for desktop and an Android app.
    I have now moved it to Flash Builder and am not sure how to accomplish this.
    It is currently a Desktop app that bilds a release fine.
    Now, how to get an Android version from it?

    The difference between an AIR application and a browser
    application is very small. Take a look at the Adobe training video
    on this subject.
    http://www.adobe.com/devnet/flex/videotraining/?sdid=DYOCT
    In particular, the last part of day three. It's quite clear
    and you can download the test setup for free. Be careful! I believe
    that the Flex Builder configuration info is out of date, because
    the paths for installation of LCDS have changed. I found a fix.
    My notes, maybe a bit cryptic:
    Make sure when you install LCDS, choose the Tomcat option.
    This will install the server application.
    If you're using the new version LiveCycle Data Services ES
    2.6, you'll have to adjust a few things:
    When you install LCDS, click the Tomcat option and continue
    with the installation.
    Instead of unzipping to C:\lcds\jrun4\servers\default.. use
    this folder to unzip the server.zip file instead to
    C:\lcds\tomcat\webapps\odt
    Original adobe forum post:
    http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=60&catid=833&threadid =1387349&enterthread=y
    Also, instead of using port 8700, the new version uses 8400.
    1. Start the Server: Programs > LiveCycle Data Services ES
    2.6 > Start LiveCycle Data Services Server. Allow the server to
    start up.
    2. Point your browser to
    http://localhost:8400/ to test
    the start page.
    3. Your URL for this example will be
    http://localhost:8400/odt/
    Flex
    I found that in many places you cannot use $(ENV_VARIABLE)
    successfully.
    Enter the exact string.
    c:/lcds/tomcat/webapps/odt - for the training apps
    Always, instead of /lcds/jrun4/servers/default/odt, use
    /lcds/tomcat/webapps/odt
    Start the data base
    cd c:/lcds/sampledb
    startdb.bat
    LCDS local URL
    http://localhost:8400/odt/adobeODT-debug/AdobeODT.html
    http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=60&catid=833&threadid =1387349&enterthread=y
    He knew what he was talking about. Thanks to rsadwick.

  • Java transports across different SPS, EHP and release

    Hi All,
    During an SPS/EHP upgrade, there is generally a transport freeze in the development landscape from DEV ->QA->PRD. This due to the incompatibility between the systems. SAP Note explaining the same is 1090842.
    I understand that same is true for the Java developments as well. As the SC imported into track are specific to release and SP levels of the WAS. These would have to be adjusted and re-build, (after SPS/EHP upgrade of WAS) so that it refers to the new versions. But these new builds are possible in NWDI, which has not been updated. But these releases cannot be transported to QA before QA is also upgraded to same SPS/EHP as for DEV.
    Please let me know if my understanding is correct. If yes, then is there a similar SAP Note/documentation available as for ABAP one explaining the same?
    Appreciate your inputs on the same.
    Thanks and Regards,
    Arundeep Singh

    Hi Mark,
    Thanks for your reply. Your reply seems to talk more on the different release of NWDI and runtime systems.
    My query is not about the relation of NWDI and Runtime Java systems compatibility. I want to know the restrictions on transports in which the Runtime system landscape, DEV->QA->PRD, when an SPS/EHP on release is being upgraded on runtime systems. The scenario where standard SAP developments has been modified is clear and there is good enough documentation available [here|https://cw.sdn.sap.com/cw/docs/DOC-17604]. Let me try to explain the case again.
    1. Only the Runtime systems landscape being upgraded. NWDI remains the same.
    2. No SAP standard development has been modified.
    3. There is only custom development, but it has build and/or runtime dependency on standard SAP SWCV. e.g. dependency on JTECH 7.00
    4. Now DEV runtime Java system is upgraded, lets say to EHP1. That means the JTECH will change from JTECH 7.00 to JTECH 7.01 in Runtime DEV system.
    5. Now, I beleive that custom development/ SLD configuration should be adjusted so that custom development now depends on JTECH 7.01 and not on JTECH 7.00.
    6. If this custom development is not modified and transported to QA system, it may not work as the JTECH version is different in DEV and QA.
    7. There could be another option at point 5. It may be chosen not to change the dependency to new JTECH 7.01. but then it may not build or run properly as JTECH in DEV is now JTECH 7.01.
    Similar case would be there in case of SPS as well. It is just in case of SPS it is more subtle. The SLD dependencies will remain same. But I wonder if any library/interfaces gets updated/deprecated then the applications may not run as expected. I understand the code is generally downward compatible, but not always.
    This is why, I was checking if there is some official document explaining such scenarios. I am still searching. If I came across something i will provide the links.
    Thanks and Regards,
    Arundeep Singh
    PS: I am not a Java developer. My judgement is purely based on the general logic.

  • Amount posted different for Invoice and Credit memo

    Hi Experts,
    The user has reversed only one line item of an invoice entry (RE), which was processed back in 2009. The invoice entry was processed with two Gl Accounts( Transit Comm.match and Com.Inv.GIT d.d) with amount allocated as 576.35 (5399.2 and -4822.85)with an input tax of 22%.But in the reversal entry the amount allocated to these account are different(-5851.62 and 5275.27), thought the total match to -576.35. Interesting thing is this entry was posted in a foreign currency (EUR) wherein the Local Currency values which is in PLN is same for both invoice and reversal entries. Exchange rate for both the entries are  4.20430.
    Please let me know your thoughts..

    Hi Ravi,
    Here by reversal I meant the credit memo processed against invoice.

  • RPT_MOPZ_COPY_STACK_XML shows SC version differs for JAVA and DUAL-Stack xml files

    Hi All,
    I am using the report/program RPT_MOPZ_COPY_STACK_XML to copy the stack xml file I used from a previous upgraded system. Systems are identical. However, report shows below..
    "Software Component Version KRNL64UC7.20 [01200615320200013056] differs between <System1> and <System2>"
    and
    Software Component Version SAPJVM6.1 [01200615320200012982] differs between <System1> and <System2>"
    However, this is not the case when checked, it's strange that this particular component has the same version between the two systems, but the report says they differs in version.
    Please help check how to resolve the issue.
    SAP notes mentioned in below KBA were already obsolete. Solution Manager system just upgraded to 7.1 SP11.
    1711612 - RPT_MOPZ_COPY_STACK_XML Report Troubleshooting.
    We would appreciate your response for us to resolve this issue. Thanks.
    Regards,
    Philip

    Hi Jansi, Divyanshu,
    Both system have the same patch levels.
    Here the situation, SYS1 is where we generated the stack xml file. Afterwards, used that stack file to upgrade SYS1.
    Now we built SYS2, ensuring it has the same components version with the un-upgraded version of SYS1, so yes they have same patch number for same components, for this issue, kernel and jvm.
    Thus, instead of running MOPZ for SYS2, we used RPT_MOPZ_COPY_STACK_XML to convert the stack file of SYS1 to be used for SYS2.
    This is where we encountered below messages, when performing the copy.
    "Software Component Version KRNL64UC7.20 [01200615320200013056] differs between <System1> and <System2>"
    and
    Software Component Version SAPJVM6.1 [01200615320200012982] differs between <System1> and <System2>"
    We previously used SOLMAN 7.0 SP23, and the report is working fine there. Then recently, solman was upgraded to 7.1 SP11, and now the report is not working with the above issue.
    We would appreciate if you could share actions on how we can fix the issue.
    Regards,
    Philip

Maybe you are looking for

  • Help trying to create a 2 page indesign doc with 1 landscape & 1 portrait page?

    I'm creating a double sided A5 flyer, how do I create a 2 page indesign document with one page portrait & the other landscape? Thank you in advance for anyone who can help with this ;-)

  • I just want my phone back.

    I purchased my Blackberry Z10 direct from Blackberry from an employee through their friends and family program. After owning the phone for only a little over 10 weeks it needed to be repaired/replaced. That was 4 weeks ago. Blackberry has had my phon

  • Please Help; Windows 7 Home Premium to Professional.

    In requirement for an IT class, I installed Windows 7 Professional over my Windows 7 Home Edition installation on my netbook. I have encountered a seriously problem though, as Windows 7 Professional seems to be stuck in Safe Mode and will not let me

  • SQL Call - Static Method

    Hello All: I am trying to run a sample code from the Oracle8i doc 'Hello World'. The program compiled and used 'loadjava' to load to the database. When I tried to create SQL Call Function from SQL*Plus, I am getting the error: PLS-00103: Encountered

  • SQL Insert Error - Please help. RESOLVED

    I have a page with several VOs and search options. One of the search options is a list of Emp IDs which (when one is selected and user clicks 'search') results in an editable table of profiles for that Emp Id. I have in the Footer of the results tabl