Byte Code Manipulation vs. Preprocessor

Hello,
I'm not sure if I'm asking this in the right forum or not, but if I'm not, please let me know and I'll change it asap.
I�d like to know what the advantages associated with byte code manipulation are.
For instance, if one had the option, why wouldn�t anyone prefer to use traditional pre-processor methods of altering java code as oppose to byte code manipulation (ie. with javassist or ASM)? -- in respects to porting J2ME apps over a variety of cellphones.
Thanks,
Mark

see I was just trying to use BCEL to learn about it. I
want to manipulate the class files. So no point comes
of a different solution.Why nobody is giving me the
solution that I want...Is it b'coz its not possible
with BCEL or what....Please help...
Kindly and please give the replay based on the BCEL.
Thanking you,Initially, you stated that your problem was how to debug production code that may or may not have debugging code present - to which you have been given an answer. If, however, your goal is a purely academic exercise (this has all the earmarks of one, especially since this won't do one bit of good in real life) then you are perhaps misunderstanding what BCEL is. You can't insert System.out.println(...) statements with it, since those are uncompiled java source lines - instead you need to insert compiled bytecode instructions, which will look more like this:
  34 invokevirtual #9 <Method java.lang.String getQuery()>
  37 invokevirtual #7 <Method void println(java.lang.String)>
  40 getstatic #5 <Field java.io.PrintStream out>which I wouldn't think is very useful. I can't suggest strongly enough that you consider not running a binary classfile mutating application on production code - that is a very bad idea.
As I see it, you have two options: compile two different binaries, one for debug and one for release; or use a flexible logging system (which I have done in every case). A third option of course is to continue playing around with BCEL for the purpose of learning the java bytecode world (but if you really want to do that, I suggest you write your own classfile disassembler using the Sun VM spec - it isn't as hard as you think and extremely educational) - but don't inflict a production application with a poor design simply to satisfy a whim.

Similar Messages

  • Connecting to EMS fails with No mapping for the Unicode character exists in the target multi-byte code page

    I am getting the following error when trying to connect to both my exchange servers.
    New-PSSession : [ex2013-002.nafa.ca] Connecting to remote server ex2013-002.nafa.ca failed with the following error
    message : No mapping for the Unicode character exists in the target multi-byte code page. For more information, see
    the about_Remote_Troubleshooting Help topic.
    At line:1 char:12
    + $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri ht ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotin
       gTransportException
        + FullyQualifiedErrorId : 1113,PSSessionOpenFailed
    EMS used to connect ok. I am not sure if there is any connection but Outlook was installed recently on the exchange server to enable mailbox level backups.
    Any help would be appreciated.
    Steve Hurst

    Hello Steve,
    Firstly, you cannot install Outlook with Exchange because they share certain dll files.
    About the EMS question, I suggest we try rebuilding the powershell virtual directory. If it still does not work, check the application log for more referernce.
    Thanks,
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Simon Wu
    TechNet Community Support

  • No mapping for the Unicode character exists in the target multi-byte code page

    hi,
    i have an issue with sharepoint 2013 and IE 10.
    im using the sharepoint  rest web service and make an ajax data call to retrive data from sharepoint lists, the call fail and return a server error: "No mapping for the Unicode character exists in the target multi-byte code page". 
    i have to say that everything works fine with chrome and firefox. 
    what can i do for fixing it?
    Thanks a lot
    alon

    Hi,
    From your description, I know you get an issue with IE 10 in SharePoint 2013 when you use SharePoint REST API to retrieve data from SharePoint list.
    I am not quite sure what cause your issue. Could you provide your code, so I could test it in my environment and troubleshoot for you.
    In addition, you could test your issue in another computer or another version of IE.
    Best Regards
    Vincent Han
    TechNet Community Support

  • Managed system Configuration : The JMX metrics of this Host / Byte Code Adapter are missing

    Hi Friends
    While Configuring EP system with SOLMAN 7.1 SP12 it is giving below message in self Diagnosis Phase.
    1. Solman system is already having ISAGENT version 8 and 9 installed (but Managed system is having 8)
    2. I have followed the automatic Process as below
    ==========================================
    Automated Installation of the Introscope Agent via SMD
    The Solution Manager provides an application that performs the setup of the Introscope
    byte code agent for Java automatically. This section explains the steps to run the setup.
    Before you can run the Introscope agent setup, the setup wizard for the managed system
    must have been executed.
    1.
    2.
    3.
    4. Launch the Introscope Setup application: SAP Solution Manager Configuration 
    Managed Systems Configuration  Step 7 Configure Automatically  Automatic
    Activity “Byte Code Adapter Installation”  “Open Java URL” (only available in edit
    mode). Your screen will look similar to the image below:
    5. Check the Enterprise Manager Settings at the top of the screen. These are the
    connection parameters that will be used by the agent to connect to the Enterprise
    Manager.
    6. In the pane Introscope Agent Setttings, select the system that you want to instrument
    with the agent. Check “select all” and click “Retrieve Current Settings”. This will display
    the current status of the agent setup.
    7. To initially setup or update the agents, click Setup Introscope Agent …. This will open
    the setup dialog as shown below. Select the desired agent version (by default only one
    available) and choose the profile. Next, check the desired instrumentation areas, and,
    in the case of AIX, review the AIX settings to match your environment (J9 or classic
    mode).
    8. Finally, hit Apply to perform the necessary changes in the agent configuration. Agent
    config files will be adapted and the Java VM parameters will be set as required for the
    managed system.
    ================================================================
    3. Restarted SAP but error still present.
    Please help to resolve the issue.
    Thanks

    Found the solution :
    1819577 - Workload Analysis data missing for Java systems when using ISAGENT 8.2.4.0
    Cause
    l This issue has been identified as product defect and documented in note 1273028
    Resolution
    l As mentioned in note 1273028, update to ISAGENT 8.2.4 Patch 1 timestamp: 2012-06-26, please proceed as described below)
    1. Enable the Maintenance Mode in the Agent Administration UI (http://solmanserver:port/smd/AgentAdmin)
    2. Deploy the file to the Solution Manager JAVA stack using the Software Deployment Manager (SDM)
    3. Disable the Maintenance Mode in the Agent Administration
    4. Execute again the activity 'Byte Code Adapter Installation' of the step 'Configure Automatically' in the 'Managed System Configuration' for the
    affected systems. This activity will deploy the new version of the
    Introscope JAVA agent in the managed system servers and reconfigure the JVM parameters to use the new version of Introscope JAVA
    Agent;
    5. Check from Introscope Agent Admin if "IS Agent State" contains value "Running but needs restart"
    6. Restart the affected managed system(s)
    Finally Solution is update your SOLMAN system patch ISAGENT 8.2.4.0 from patch 0 to 1 via SDM.
    Thanks
    Mukesh

  • Question about Byte Code

    Hello...can anyone tell me how I write a java program, compile it and get my byte code written into another file??
    Thanks in advance!

    I am looking to write my bytecode into a .bc file and
    open it and actually be able to read the bytecode
    instruction...(stuff like iload_2, i2d etc.,)I see... that was not clear from your first question. What you want is a disassembler. The SDK comes with one called 'javap': http://java.sun.com/j2se/1.4.1/docs/tooldocs/windows/javap.html

  • Question about compiled byte code

    Howdy folks,
    I have a client who wants to run an application in both
    on-line and off-line modes. The user could run the application
    locally on their laptop making changes and such which would get
    stored to local database files (probably FoxPro free tables just to
    make it easier on me). Then when the user got back to their
    internet connection they could run the application and it would
    sync with the online tables (probably MySql tables at that point).
    So the question is, if I compile Cold Fusion code into Java
    byte code, will it be able to execute independantly of the Cold
    Fusion Server? I realize that I could load ColdFusion on the user's
    laptop, but I don't think I want to do that. I'm assuming that the
    answer to my question will be "No. You can't do that. Cold Fusion
    isn't meant to work like that." To which my next question would be,
    "Well, what language would be best for the type of application I
    have described above? Action Script, maybe?"
    Any thoughts are welcome, especially if you've written an
    application like the one I've described.
    Thanks very much,
    Chris

    Well, rats.
    I wrote a nice reply to your message BKBK, but lost it
    because, apparently, my session timed out.
    The basic jist, was that I've been working on AJAX, and have
    been implementing some AJAX-like techniques at some other clients
    (using hidden iframes combined with innerHTML -- I know not a
    standard, but darn handy otherwise), but I couldn't see how that
    would solve my on-line/off-line problem (unless I stuck with the
    cookies idea).
    I also did some reading on cookies last night (obviously, I
    don't use cookies very often if at all in my daily coding), and I'm
    a bit put off by the different browser limitations. I'd hate my
    client to be chugging along, entering appointments into the
    "database" (read: data being stored as cookies to be sync'd later
    when the user goes online), and then suddenly run into the cookie
    limitation. On top of that, if I'm reading right, IE (my client's
    most likely choise of browser), will not let you know that you've
    reached this limit, but will just begin dropping the older cookies
    in favor of the newer ones. If I could programmatically sense this
    limitation and then write the cookies to some file before
    continuing that'd be geat, but since JavaScript can't write files
    (that I know of) this isn't feasable. Also, if I could write a file
    like that, I wouldn't bother with the cookies.
    I think I'm going to end up writing it in FoxPro since my
    company has a bunch of copies of it (and it's licenced per
    developer and not per copy), and there are lots of folks in my
    company who can help me get up to speed. That also means that I'll
    probably need to write a web version of the code for when my
    client's client's (does that make sense? :-) ) connect to the app
    via the internet.
    Anyway, I'm really enjoying everyones comments on the
    subject. Can anybody think of a technique for a way around the
    cookie limitations? Or perhaps another language that this whole
    thing could be written in?
    I really wish that I could compile my ColdFusion code for use
    independant of the CF server. I know, that's not the way it works
    and typically not what scripting languages like this are used for.
    I suppose I could always install the developer's version of CF on
    the user's local machine, write the code in CF and then just detect
    whether or not the user is online and behave accordingly.

  • Inheritance and byte-code...

    My coworker and I were having a discussion today that I imagine someone here will be able to resolve for us: we were talking about how wonderful inheritance is (when used properly, of course), and the issue of the compiled byte-code came up.
    Basically, it was my conclusion that a subclass contains only the byte code that differentiates it from the superclass; in other words, if a superclass is modified and recompiled, there is no need to recompile the subclass for the changes to take effect. My coworker disagreed, however, arguing that there would be linking problems between the two classes if the subclass was not recompiled (sign of an old assembly programmer, if you ask me).
    Anyone know the answer to this?

    I created a trivial Parent class and extended it with an
    even more trivial Child class. I compiled both classes
    and then made a change to the Parent class. After
    compiling the Parent class only, the change took effect
    in the Child class. This indicates that you are right and
    your co-worker is wrong. Here are the classes if you
    would like to show him.
    import java.awt.*;
    public class Parent
         Dimension d;
         Parent() {
              d = new Dimension(333, 777);
         public Dimension getDimension() { return d; }
    import java.awt.*;
    public class Child extends Parent
         Dimension d;
         public Child() {
              d = getDimension();
              System.out.println(d.height + " " + d.width);
         public static void main(String[] args) {
              new Child();
    }Mark

  • Is there a way to convert JVM 1.1x byte code to JVM 1.3+ byte code

    I dont have the source code from a program that is used in my company. The original writers went out of business... so we cant ask them.
    I was thinking of decompiling the code and then recompiling it... but I was wondering if there wasnt just a byte code updater?
    Or if anyone could come up with a better method.
    -S. Bob.

    er.. well I dont think you understand. I have been assigned to get it functional... I mean, its my task to come up with a solution. :[
    Unless of course you have a credible documented source that states 'NS 6.1 is a hot steaming pile of crap' and that no one should use it. I could leverage off of that to help my claim that any support for this browser is pointless.
    Do you have a link that talks about the applets and why they dont function in NS 6.1 vs 4.7x ?
    That or does anyone know why or how to get NS 7.0 working on Windows 95. (yes I do understand what I ask here... I wish it werent true.)
    -S. Bob
    'life in the corporate wheel, grinding one day at a time'

  • Strange Error - 5005: Unknown error optimizing byte code.

    Hello flashcoders,
    I am facing strange problem since long time. This error code
    even doesn't exist in the list of error codes.
    This is the exact error I am getting while I compile the FLA
    from flash CS3.
    Location : , Line 1
    Description : 5005: Unknown error optimizing byte code.
    Source :
    I don't know exact reason about its generation, But here are
    the some possible reasons / hints:
    Case 1) Overloading:
    1.1) Size of .fla is 10.5 MB and its document class contains
    more than 60 classes to import and has more than 100 variables.
    1.2) Even if I put In document class - only variable
    initialization and class importing are there. Nothing in its
    constructor + no other functions are defined. Still error is there.
    1.3) If we import all classes and has all variables then it
    gives this compile error. But if we remove some particular numbers
    of variable, it's start working. In this we can remove any type of
    variables.
    1.4) After reducing variables, application starts working
    till that it won't.
    Case 2)
    2.1) Size of .fla is 1.75 MB and its document class is same
    as above one.
    2.2) All assumptions are same as above.
    2.3) Now this class contains all functions and have
    initialization of all variables + classes.
    2.4) In this If we remove 3-5 variables, it will start
    functioning else it won't.
    Its a huge application so I am even confused that what is the
    cause of error and this error stopped our working for a week now.
    Bit more information about the project that may help the team to
    identify the reason.
    1. Project development started with flash public alpha 3.
    When we started using Flash CS3, we had some design problem if we
    do open the FLA in CS3, so we completely redesigned the Movieclips
    etc., in Flash
    CS3 IDE.
    2. Project contains approx 250 classes.
    3. In main application, it imports 67 classes. (it works if I
    keep 63 classes in document class).
    4. In the case 3 above, if that works with 63 classes and If
    I do add 3 frames in existing movieclip, it stops working.
    5. In the case 3 above, if that works with 63 classes and If
    I do add / declare few more variables, it stops working.
    It would be humble appreciation if someone can come up with
    some light in the dark tunnel.
    Best Regards,
    Ashvin Savani - "arckid"
    Founder & CTO - Avinashi.com
    Adobe Community Expert
    We Never Give Up!

    I've posted an article on this problem -
    http://www.negush.net/blog/5005-unknown-error-optimizing-byte-code/
    - and here are a few ideas on how to handle it (check out the
    comments):
    - try turning off the optimizer
    - delete ASO files
    - also it seems that changing the java vm heap memory size
    could help (find he environment variables in the Windows computer
    properties and search the JAVA_TOOL_OPTIONS variable)

  • Byte Code Instrumentation with -javaagent in JCAPS 5.1

    Hello All,
    Has anyone successfully used Byte Code Instrumentation using the -javaagent switch in JCAPS 5.1?
    I have 3 instances of JCAPS and two are reporting metrics fine the third is Not!
    I am trying to instrument but my agent code is not being started and I am not seeing metrics...

    Tags in JCAPS Repository are primarily used with deployment profiles. They are not the traditional CVS or SVN Tags. As far as I know, you cannot export projects based on Tags. The only place they are useful is when you are creating deployment profiles and want to use an older Tagged version of the connectivity maps etc and the components used within them such as JCDs, eWays, BPs etc. The caveat here is that if you used any external JARs within your JCDs, earlier versions of those would not be references corresponding to the repository Tag.
    Hope that helps.
    Z.

  • Is Java Byte Code is 100% platform independent

    Hi all
    A my room fellow is disturbing me about the platform independency of JAVA.
    Now i only wan to know that generated Byte Code will be same if it is generated on different platforms (Window,Linux,Unix etc)using their respected JVM
    Thanks in advance

    The "Platform Independency" of Java is a bit of a joke
    to me. You need a JVM that is platform dependent to
    run it. Now granted, you can write one application
    and itll run on any platform, but that's only assuming
    they have the JVM installed on them. Not to say that
    Java isn't cool and all, but the "platform
    independency" solution still has a reliance on
    something that is platform dependent... It's like
    driving an automatic and saying you can drive....Sure,
    you are making the car go, but something is doing the
    shifting for you....(C: I guess I'm just arguing for
    the sake of arguing...Well if you want to argue that point then no language is platform independant. C code for instance needs a compiler for the platform you want to compile it to run on and that compiled code won't work on any other platform. Ultimately every program has something that ties it to a particular platform, that's just the nature of things in computers.
    The idea of platform independance was the removal of the need to re-compile a program with a native compiler just to get it to run on that platform.
    Instead Sun opted to have a compact JVM to interpert the byte code and have the byte code standard across all implementations of the JVM.

  • Executing tiny programming language compiled byte code with the JVM

    Hello,
    For a project, I am developing a simple programming language, with a syntax not unlike Pascal, which compiles to Java Byte Code. Currently I execute the compiled byte code using my own interpreter. This works OK, but what I'd like to do now is to execute the compiled byte code using the actual existing JVM. The compiled byte code resides in a text file upon compilation of a sample program written in my tiny programming language. Does anyone know how I may start to go about this? Thanks in advance.
    adam

    The only way of getting a standard Java virtual machine to execute your java byte code, is to wrap it up into a completely valid java class file.
    Any constants you use, must be put into the classes constant pool.
    Any local variables will have to go into the local variable table of the method which uses them... etc, etc.
    Something like ASM, would let you dynamically create a Java class file.
    http://asm.objectweb.org/
    regards,
    Owen

  • Problem-Loading Byte code from DB

    Dear all,
    have any one tried to load the bytecode read from the database. If so, please suggest me a way to do it. Iam developing a frame-work where nothing except a servlet would reside on the disk as a file. after designing the frame work, i've encountered this problem...plz suggest me a way.

    Yes! You are correct. My Intention is Exactly the Same. If The byte code is residing in a database, with the classname as key, i would load all the class tree from the DB and execute the program....Please Help me
    Thanks
    Sasi

  • JDK 64k byte code limitation for methods

    Concerning the JDK 64k byte code limitation for methods (actually 65535 bytes): While the Java compiler doesn�t care for that problem, the Java VM does. Hence, an violation of the 64k limit is dedected at run time, too late, of cource. Is it possible to detect the violation at (or immetiately after) compile time? Are there any tools that support the perception of the violations as early as possible?

    Thanks to the authors of the answers. I agree to you as far as hand-written code is concerned. However, we generate our java classes, thousands of files, each java class with a lot of methods. We do have rules to keep things as smal as possible. Nevertheless, some methods become very large. Thus the problem is to detect such methods. Once the methods are known, we are able to modify our generator. We implemented a small program that looks for large methods in terms of source code, but there is just a week correlation between source code and byte code. Hence, again the question: Is there a tool that supports the detection of methods larger than 64k byte code before installation?

  • Can we invoke a method using BCEL(byte code engineering library)

    Hi i am new in Java bcel,So can anyone guide me in this problem.
    I am searching for some techniques in BCEL to invoke a method of some class just like we use to invoke methods using Java Reflection.I have also tried a Java Assembler named "Jasmin" that used to interact with Operand Stack,Local variable array & Constant Pool etc so i guess this is the same containers with which our BCEL also interact with so then i am wondering why not then there exists a way through which we can invoke a method using BCEL IF this will happen in any case then kindly point it out some direction of help.
    thanks in advance

    856989 wrote:
    I think i have clearly mentioned that "Tell me any way in doing this invocation in BCEL not in Reflection."
    Why i not want to use reflection because it have "invocation overhead"Wrong.
    If I dynamically load a class and reference it via a interface there is absolutely no difference in that and if I referenced the class statically and used it via an interface. The load and use process is exactly the same.
    And the first uses "reflection".
    If you use a proxy interface via something like java.lang.reflect.Method
    then of course there is some overhead because there is in fact more classes involved. Just as if you had any other layer in any other code.
    And even so unless you have actually profiled the application and found an actual bottleneck (and not just a measured impact) then even looking at it is a waste of time.
    If it was me I would be far more concerned that inserting byte codes was correct for all cases.

Maybe you are looking for

  • Can't see network drive attached to AirPort

    Hi All I'm a newbie Mac user (just got my MacBook Pro last Thursday, in fact-- OS X 10.5.7). While I've got most of my issues doped out, I'm running into a problem connecting to a network drive that's plugged directly into my AirPort Extreme. I have

  • 40GB Orignal IPod suddenly not showing in Windows or iTunes on Toshiba

    I recently had to reinstall my Windows XP operating system on my Toshiba laptop and when I tried to sync my 1st or 2nd generation 40GB iPod in the USB port, my computer no longer acknowledges the iPod. The Apple website solution for Toshiba laptop pr

  • Can you create a datamerge to the pasteboard?

    Using InDesign CS5 is there anyway you can create a datamerge to the pasteboard? I want to place the docket number in the bleed section for newspaper ad series. When I try to create a merged document, I am notified that there are no placeholders pres

  • Output of Sapscript in Chinese language

    I have a Purchase order in english and now i want its output in chinese. I want the output of my script in chinese language. I have tried logging in chinese language but the output comes in German. I have also tried through se63. An output type is at

  • Documentation on N1 OSP plug-in

    Hi, I am trying to figure out what to do next. I am trying to provision to bare metal via SPS OSP plugin via ALOM. I have installed SPS 5.2 MS and SPS 5.2 RA on different physical hosts. I have imported the OSP plug-in. I was able to setup a host rec