Java bytecode generation

I am a student and am doing a project on converting java syntax which is in english into my own language which is urdu. the problem is that i am not able to read a single word from java class file inorder to get the specified bytecode. please provide me guidance.

My interpretation of your question, is that you want to extract the constant strings out of a class file, translate them from English to Urdu, and rewrite the class file ?
Basically, localisation, without the source code ?
Here's a link to the detailled format of the class file format.
http://java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html#80961
You probably only need to know how to read the constant pool.
It stores all the constant strings in a class file.
You won't need to touch the byte code itself.
( The byte code is the actual instructions stored in a code tag within the method attribute )
So, in theory, you could read in the constant pool, translate the strings and write out the translated string to a new classfile.
( has to be same name, but in a different directory )
It would require at least intermediate Java skills though.
regards,
Owen

Similar Messages

  • Bytecode generation

    Hi,
    Does exists any API for bytecode generation? I read internal API for proxy objects generation and I like it. But that was specific API. Generally speaking I want to create a proxy object for some abstract class (java.awt.Graphics, etc).

    Yes, but generating and compiling is made through file system and it isn\t very good.
    I\ve already seeked solution for this problem in tools.jar in package com.sun.tools.javac.v8.code. But client must have whole JDK, not only JRE and it is not very good too. Of course, I can try redistribute separately, but it is about 4.8Mb - too much!

  • Error in java proxy generation due to xs:choice tag

    Hi all,
    I'm trying to generate a java proxy in the SAP XI design.
    The message interface I'm using is based on an external definition which i imported from an xsd file.
    The problem is that XI doesn't allow me to generate the java proxy because in the xsd schema the tag <xs:choice> is present and XI cannot handle it (just in this case, because the external definition works fine).
    Does anybody know how to solve the problem or manage to generate the javaproxy anyhow?
    Thanks in advance,
    Daniele

    > Replace <xs:choice> tag with  <b><xsd:choice> tag
    > </b>
    > that should solve the prob.
    I tried to change the tag (replacing also other <xs:...> tags in order to obtain a valid xsd) but the problem didnt change.
    i'm almost convinced that tag is not supported in java proxy generation (but it is for external definitions...)

  • Java Proxy Generation not working - Support for Parallel Processing

    Hi Everyone,
    As per SAP Note 1230721 - Java Proxy Generation - Support for Parallel Processing, when we generate a java proxy from an interface we are supposed to get 2 archives (one for serial processing and another suffixed with "PARALLEL" for parallel processing of jaav proxies in JPR).
    https://websmp230.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/sapnotes/index2.htm?numm=1230721
    We are on the correct patch level as per the Note, however when we generate java proxy from the IR for an outbound interface, it genrates only 1 zip archive (whose name we ourselves provide in the craete new archive section). This does not enable the parallel processsing of the messages in JPR.
    Could you please help me in this issue, and guide as to how archives can be generated for parallel processing.
    Thanks & Regards,
    Rosie Sasidharan.

    Hi,
    Thanks a lot for your reply, Prateek.
    I have already checked SAP Note 1142580 - "Java Proxy is not processing messages in parallel" where they ask to modify the ejb-jar.xml. However, on performing the change in ejb-jar.xml and while building the EAR, I get the following error:
    Error! The state of the source cache is INCONSISTENT for at least one of the request DCs. The build might produce incorrect results.
    Then, on going through the SAP Note 1142580 again, I realised that the SAP Note 1230721 also should be looked onto which will be needed for generating the Java proxy from Message Interfaces in IR for parallel processing.
    Kindly help me if any of you have worked on such a scenario.
    Thanks in advance,
    Regards,
    Rosie Sasidharan.

  • Where to learn about the java bytecode?

    I want to learn the JAVA bytecode. Where to find information about that?

    The list of opcodes, list of data types, and how to use them is here:
    http://java.sun.com/docs/books/jvms/second_edition/html/VMSpecTOC.doc.html
    I personally use BCEL to manipulate class files.
    http://jakarta.apache.org/bcel/
    Some report they prefer Soot.
    http://www.sable.mcgill.ca/soot/

  • Synchronous interfaces missing in Java proxy generation

    Hi,
    In PI 7.1 ESR, in "Java proxy generation" wizard, it only lists the Asynchronous interfaces from the software component version. None of the synchronous interfaces are listed.  how can I solve this? I need to generate a java proxy for a syncronous interface.
    thanks and regards,
    Raghu

    Make sure that the inteface pattern is "stateless (XI 3.0 compatible)".

  • Java Bytecode error

    I am programming a program in Java Bytecode as an assignment. I am using Jasmin to compile the code.
    My program generates a random int between 0-1000 then converts that number into a string that is the binary equivalent of that number, then prints it out.
    I am getting an error though and I am not sure what the error means, or where the error is happening...so I heard the people here on the java forums can be very helpful so I decided to see if you could help me. Any Suggestions?
    Error:
    Exception in thread "main" java.lang.NoClassDefFoundError: java/util at IntToBinary.main(IntToBinary.j)
    .class public IntToBinary
    .super java/lang/Object
    ; standard initializer
    .method public <init>()V
       aload_0
       invokenonvirtual java/lang/Object/<init>()V
       return
    .end method
    .method public static main([Ljava/lang/String;)V
           ; set limits used by this method
           .limit locals 4
           .limit stack 4
           ;generates a Printsteam and stores it
           getstatic java/lang/System/out Ljava/io/PrintStream;
           astore_0
           ;Generates a Random Object
           getstatic     java/util/Random Ljava/util/Random;
           ;Push 1001 on stack, cause we only want numbers inbetween 0-1000
           sipush 1001
           ;This now gets me a random integer between 0-1000
           invokevirtual     java/util/Random.nextInt(I)I
           ;This takes in the int and puts out the binary equivalent in a string
           invokestatic     java/lang/Integer/toBinaryString(I)Ljava/lang/String;
           ;These are the methods/variables to print our result off
           astore_3
           aload_0    ; push the PrintStream object
           aload_3    ; push the string we just created - then ...
           invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
           ; done
           return
    .end method

           ;Generates a Random Object
           getstatic     java/util/Random Ljava/util/Random;The comment's wrong. It doesn't generate anything. Instead it tries to get the field Random from the class java.util - hence the error you're seeing.

  • Help reading java bytecode

    I need read java bytecode to understand the structure of a class. I need know the variable and the method of a class.
    I do this using the library javassist. I would like to know wich method are called inside a method. I think I should interpratate the javabytecode. Is it technical possible do this? Any idea o useful link to read?
    Edited by: orsvon on Sep 10, 2010 5:02 AM

    Thanks for your useful link!
    I get the method called inside a method using javap -c ClassFileName. Then I parse the output looking for the instraction invokevirtual.
    Is there a clen way to do this?

  • Hi, where can i find specification of the Java ByteCode language ?

    Hi all.
    I need the java Bytecode language RFC/Specification i must create an sample language which must be translated to Java Bytecode but i cant fnid java bytecode specification
    i mean what structures and operations are available under Java Interpretator language and etc.

    here

  • Comments inside java bytecode

    I have heard rumors of a way to add a comment block inside java bytecode. Can anyone point me to a reference that spells this out more clearly?

    Thanks for the help Owen.
    I'd like to add comments to bytecode so that I can create add annotations than an extended java bytecode typechecker can check. See SafeJava
    http://www.eecs.umich.edu/~bchandra/publications/phd.pdf
    Can you tell me more about using the CODE attribute?
    I'm sure they're talking about java source code, not
    byte code.
    Java bytecode is a strict list of approx 200 byte
    code instructions.
    What you "might" be able to do (but only you could
    read them) is to create your own "custom attribute"
    attached to a CODE attribute in the Java class file.
    The VM ignores any attributes it doesn't recognise.
    So, if you write your own dissassembler, it would
    recognise the custom attributes. But I don't see
    what this would accomplish for you....
    Why would you want comments in byte code ? ( the
    class file )
    It would only help people greatly to reverse engineer
    and decompile your code.
    regards,
    Owen

  • Java ByteCode

    Hi guys,
    I have some questions about java bytecode..
    1-java bytecode is cointained in the .Class file,that is autogenerated by Ecliplse(the ide I'm using) or by javac.
    I need to extract the bytecode from a .class file,and actually I'm using this piece of code :          //leggo il codice dal file java e lo memorizzo come byte
              file=new File(path);
              InputStream is;
              try {
                   is = new FileInputStream(file);
                   long length = file.length();// Get the size of the file
                   // You cannot create an array using a long type.
                   // It needs to be an int type.
                   // Before converting to an int type, check
                   // to ensure that file is not larger than Integer.MAX_VALUE.
                   if (length > Integer.MAX_VALUE) {
                        // File is too large
                   // Create the byte array to hold the data
                   dati = new byte[(int)length];
                   // Read in the bytes
                   int offset = 0;
                   int numRead = 0;
                   while (offset < dati.length
                             && (numRead=is.read(dati, offset,dati.length-offset))>=0) {
                        offset += numRead;
                   // Ensure all the bytes have been read in
                   if (offset < dati.length) {
                        throw new IOException("Could not completely read file "+file.getName());
                   // Close the input stream and return bytes
                   is.close(); Is it right?(I think so..)
    2-Then my program will serialize and send through TCP socket the bytes loaded from the .class.The receiver need to create an instance of the .class received...how do I do this...(note that I know the name of the class)?
    Thanks a lot guys...BYE!--JAVA ROCKS

    1. Looks okay.
    2. Create a suitable subclass of ClassLoader. The API doc for it is reasonable helpful.

  • Enhancement request: Remote interface java file generation

    Problem:
    In release 9.0.3, If you want to write a method that is suppossed to be exposed in the remote interface, you have to first right click on the ejb-jar.xml's appropriate EJB name node and then add the method, specify the argument types (say about 25 in number in a small width textbox), return type, etc and check the check box 'Expose in remote interface'. Then only remote interface's java source gets updated and only after doing all this can you actually sit down to write the business logic in that method. If you first code the method and then try to add the same, it gives an error saying "duplicate method exists"
    Suggestion:
    The similiar feature in release 9.0.2 was much better and flexible as it allowed the generation of remote interface source after coding the actual method in the EJB source. You can first write the method and then expose it in the interface by just choosing it from a method browser and opting for exposing it in the remote interface. You donot have to write the name and number of arguments like we have to currently do in the 9.0.3 release.
    (1) Actually, all public methods in the EJB source should by default be exposed in the remote interface because EJB are supposed to be used by other EJBs and JSPs only and all methods that are public but not exposed in the remote interface should actually be private or protected.
    (2) Leave it up to the developer to edit the remote interface
    (3) When the EJB source file is changed (public methods changed) compiled the remote interface should also be updated automatically. Why? already you have provision to change the remote interface source, so just dump all the public methods in the remote interface source when the EJB source is compiled.
    (4) Ditto for EJB Homes
    (5) Actually whenever the developer changes and compiles the EJB source, the remote and home source should automatically be updated AND COMPILED. (Refer: Pramati Studio 3.0 SP3 :- URL: www.pramati.com )
    I was very happy with the earlier option. If anybody other then the JDeveloper Team finds this interesting, please respond. A suite like developer should be more User-friendly.
    And yes expect more like this from me in the future

    Hi Raghu,
    Thanks for the quick response. This flexiblity in Remote interface generation and choice of methods in it at any given point in the development cycle is very much desired feature.
    The other thing I would like to suggest is you look at another enhancement request in my name regarding batch updates of the "web.xml" file. You will find the thread updated today i.e. on 15th September with a reply
    I will shortly post one more for lack of modularity in EJB components descriptors.
    My Company Four Soft Pvt. Ltd. (www.four-soft.com) is Oracle's development partner and we use and support Oracle products. They are good but naturally we would like them to be better and more User-friendly.
    Thanks once again.
    Amit

  • How to visualize java bytecode?

    Hey guys
    I'm here again with another question for you.
    That you know, is there a way to visualize and see the bytecode of a program in Java? if yes can you please tell me how to do this?
    Thanks in advance.
    Maddy

    I dont think u can insert anything into to a .class file.So not true. How do javac, jikes, jasmin and several other compilers / translators work then?
    There are several APIs for doing that. Check the link I gave. And this: http://directory.google.com/Top/Computers/Programming/Languages/Java/Class_Libraries/Data_Formats/Java_Class_Files/
    CafeBabe is a graphical tool but it is far from finished right now: http://jfa.javalobby.org/projects/CafeBabe.html
    I'm sure there are lots of others... I was browsing the 'net the other day and became momentarily intressed in this. I found a myriad of different tools - even graphical ones - but I can't seem to be able to find them now :(
    infact as far as i know, even if u delete a char and retype the same char the verifier will complain.If you use a text editor, of course. The different character encodings and null bytes mix things up pretty badly, you know... You can't even open and save an casual GIF file in Notepad so that the result will be valid GIF!

  • Java Bytecode Obfuscator

    When I used Bytecode Obfuscator to confuse my java code.
    They were business rules which write in Actions and Entities.
    But the confuguration in xmls such as Entities.xml or struts-config.xml does not mach the reference of my Obfuscated classes.
    Are there any solutions about this??

    Migolia,
    This question is not related to JHeadstart. Please post your question on the JDeveloper forum.
    Thank you,
    Steven Davelaar
    JHeadstart Team.

  • Java bytecode manipulation (help!)

    I would want to do the following but do not know which tool is able to provide the facilities.
    1) A class with 2 methods with instructions inside e.g. a=b+c; c=2+b; a=5+c;
    2) Randomly choose one of the instructions from each method
    3) Swap the 2 instructions
    4) Create a new class that contains the 2 new methods (with one of their instructions swapped)
    Is objectweb's asm able to achieve this? Or cglib would be easier? I am still researching the feasibility of implementing such cases.
    Thanks in advance!
    Stan

    Hi, I agree it is a good model for building expressions (tree like structure), but in this case there will be alot of instances being created thus consumes alot of memory for genetic programming. This is why I wanted to go into explore the ways of manupilating at the bytecode level (the idea a class is a generation, its methods are the individuals). I wanted to operate without having to consume too much memory. But of course, to do this there is a high trade off in terms of extensibility.
    Nevertheless thanks for the reply, now I had learned it is also possible to do it using Composite.
    Recently I had managed to find out how to swap the instruction codes using asm. Next is to see whether I can group the bytecode instructions as one expression in the source level e.g.
    at source level
    a = 3.5 + b
    at bytecode level
    LDC 3.5
    DLOAD 2
    DADD
    DSTORE 1
    and do the swaping by group. It seems like there is no easy way on this if I still want to enforce to build a lightweight engine.

Maybe you are looking for

  • Oracle Report Error (string buffer too small) in Portal

    Hi, I have registered an oracle report (.rdf) with portal which works fine outside in Reports Builder, but when I try to run it in Portal it keeps throwing this error: SQL-6502: ORA-06502: PL/SQL: numeric or value error: character string buffer too s

  • I have some problems with keyword "package"...

    I am studing Java, and studing package now. I created 2 files to try the package concept, but I met some runtime errors, although I don't think that it has anything wrong. Does anyone can pointed out where is wrong in my code? //============== file 1

  • Account Assignment Category in VOV6

    People, Can any one explain the meaning of Account Assignment category in VOV6. Found some answers on Google but were not explaining the real use of it. Can any one use a real scenario to explain the answer Ahmed

  • Format Plug-In : problem loading a 4 channels image with CS4

    Hi! I wrote a format plug-in to support our own in-house file format. That plugin works fine with CS2 but I have some problems with CS4. Since my plug-in behaves exactly as the "simpleformat" provided with the CS4 SDK, we can center the discussion ar

  • Liquify filter in CS4 doesn't work at all -- other filters do!

    Does this mean I have to re-load the whole program?  I work on a Mac Pro with 10.5.8.  Had no problem with CS3 liquify, but that pixel size is limited to 600 and I want to use the larger size in CS4.  Am I missing something?