Access object attributes using other object JNI native method

Hi. I'm trying to change an attribute of object O1 from another object O2 without invoking a O1 method and without making the attribute as public or protected.
The only possibility that comes to my mind for doing so is writting a JNI native method
public class O1 {
static public native changeAttribute (Object O2, Object newAttributeValue) ;
that change the attribute memory reference, but all I've found about accesing attributes in JNI is about accessing the invoker attributes (in this case, O1).
�Does any one know if it's possible to do so? Thanks.

I know that is not a good practice but I cannot figure out another way.
I'll try to explain the whole problem so you see the reason. I'm working with transactions, using objects as the data. An object can be opened for write by several transactions because the granularity for conflicts is not the object, is each of its attributes. As long as two transaction don't write the same attribute, they both can write. For writing, each transactions uses a private copy of the object. At committing, the actual copy of the object must be replaced by the committer one, but as far as the granularity is the object attributes, only each written attribute must be replaced (if not, only the last commit would be visible).
This attribute replace must be done by the transaction manager as far as the transactional object is provided by the client. So what i was thinking was to use JNI or some trick like that to replace the object attributes transparently to the object.
I hope the explain is clear, my english is a little asleep :-(.
How to do it with reflection? I thought that was only for method calling. Anyway, there wouldn't be problems if the attributes are private?
Thanks for answering.
EDIT: I've been able to change a public field using reflection, but not the private one
import java.lang.reflect.*;
class Caca {
public static void main(String[] args) {
Integer r = new Integer(0);
System.out.println("original: " + r.toString());
modifyWidth(r, 300);
System.out.println("modified: " + r.toString());
static void modifyWidth(Integer r, int newValue ) {
Field valueField; Class c = r.getClass();
try {
valueField = c.getField("value");
valueField.set(r, newValue);
} catch (Exception e) { System.out.println(e); }
Message was edited by:
dfasdfsdafsadfasdf

Similar Messages

  • Error : Access not possible using "null" objects reference

    Hello.
    i am working with a zbapi.
    i called a external email program in this bapi,everything is working fine over here.
    In webdynpro java they mapped my bapi and starting working from there.
    every functionality is working fine but regarding this email stuff it is showing an error as access not possible using null objects reference.
    where could be the possible error.
    is it in webdynpro or in abap side.

    Raghu,
    You are right. When it comes from the WD Java, may be you are not passing any value at all. You can trace it by these ways.
    1. Check it using SE37, make sure everyhting is fine.
    2. Print all the values that you are passing to the RFC in the execute RFC method().
    3. using ST05 transaction in R/3, enable RFC and SQL trace, check what is passing in between web dynpro and R/3.
    Moreover paste your error message here.
    Thanks,
    Raj.

  • Trying to Clone an array object that contains other objects

    I have an employee object with the fields name (String), Salary (Double), and hireDay (Date). Since the date field contains many int fields (year, month etc..), using a straight clone will not work.
    What I want to do is copy an array of employees into a new array.
    For example:
    Employee [] newEmps = (Employee[])OldEmps.clone()
    In the employee class, I implement the Cloneable interface and my code so far will copy one Employee. How do I change this to copy an array of empoyees? Specifically, since hireDay contains many fields, a straight super.clone of the array won't work. Here is my clone code:
         public Object clone()
         try {
              // call Object.clone()
         Employee cloned = (Employee)super.clone();
              // clone mutable fields
    cloned.hireDay = (Date)hireDay.clone();
         return cloned;
         catch (CloneNotSupportedException e)
         { return null; }
    Any help is appreciated. Thanks!
    -Eric

    There's so much I don't understand about that, it just
    isn't worth asking. Let me spell out my previous post
    since it seems to have gone right over your
    head.Employee[] emps;
    // here you fill in the array of Employees
    Employee[] clonedEmps = new Employee[emps.length];
    for (int z=0; z<emps.length; z++) {I understand this next line of code. My question lies within the clone() function
    clonedEmps[z] = emps[z].clone();OK - Let me try to clear things up. If we take from your example the original array "emps". Now for me, emps, is already filled up in main().
    So in main() when I call emps.clone(), my clone function starts running:
    // the employee class (which I created) implements the Cloneable
    // interface
    // This clone function is inside my employee class
    public Object [] clone()
    try {
    Employee [] cloned = (Employee)super.clone();
    // IS THIS NEXT LINE OF CODE REQUIRED TO MAKE A DEEP COPY? IF SO, How would I implement perhaps a for loop that would copy the hireDay from each element in the original array to the elements in the the new array?
    // Obviously, each employee (element in the array) has a hireDay
    // Please modify this next line of code to show me how.
    cloned.hireDay = (Date)hireDay.clone();
    return cloned;
    catch (CloneNotSupportedException e)
    { return null; }
    If I wanted to access say the "hireDay" field of the 3rd element in the original employee array INSIDE THE CLONE FUNCTION - then how would i access it?
    Thanks
    -Eric

  • SAP object enhancement using abap objects

    Hi
    I am enhancing a standard SAP object using ABAP objects.
    I need to add 2 more fields to the struct in that object.
    My qn is : how to redefine the parameter type of a method in standard class?
    the code is
    DATA: lt_list TYPE RCF_T_LIST_MASS_PROC_ACT_X.
    CHECK me->start_selection EQ true.
    CHECK exist_exception( ) EQ false.
    DATA lo_ex TYPE REF TO cx_hrrcf.
    TRY.
    CALL METHOD me->ref_mass_proc_bl->get_mproc_cor_list_info
    EXPORTING
    mass_proc_cor_list = me->sel_mass_proc_cor
    IMPORTING
    mass_proc_list_info = lt_list.
    CATCH cx_hrrcf INTO lo_ex.
    add_exception( lo_ex ).
    ENDTRY.
    plz help me
    if anyone provides code for this is appreciable.
    Thanks

    Hi,
    either you can use the append technique <a href="http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ebc9446011d189700000e8322d00/content.htm">Append</a>
    or you can define an additional import parameter.
    Best Regards, Edgar

  • How to recover a state of  one objects threads by other object

    hi everyone
    how to recover a state of one object's threads by other object..
    i am creating a object in that i have 10 thread..... i have started it then i have closed that object ...then i am creating a new object for the same class ...i need to stop those thread which i have started earlier

    saiyath_babuhussain wrote:
    hi everyone
    how to recover a state of one object's threads by other object..Objects don't own threads so that's hard to understand
    >
    i am creating a object in that i have 10 thread..... i have started it then i have closed that object ...then i am creating a new object for the same class ...i need to stop those thread which i have started earlierWe don't so much stop threads as inform them politely that their services are no longer required. When you have a long running thread it's almost always a loop, often with a wait or sleep which causes it to wait until it's activitty is needed.
    So if you want to be able to wind up a thread from another thread then you put a boolean flag in which can break the loop. The other thread then changes that flag and calls interupt() on the thread it's trying to stop. Interupt will kick the thread out of wait or sleep if that's where it is, causing an InterruptedException. On discovering that the flag indicates it should stop, or on catching an InterruptedException the thread should then clean up and finish.
    The master thread can call join on the thread it's stopping if it needs to wait for it to terminate.

  • JNI native method

    Say I create a JVM from native code and use it to popup a GUI... kinda like the next 2 lines:
    res = JNI_CreateJavaVM(&jvm, (void **)&env, &vm_args);
    mid = (*env)->GetMethodID(env, cls, "showWindow", "()V"); // This MID will pop up gui
    Now, how do I make a button int he Java GUI call back down to the native code (C). Is this even possible without creating a shared library and doing System.loadLibrary() ?

    See JNI function RegisterNatives. This lets you put native methods in your main executable rather than needing a shared library.
    -slj-

  • How to access the attributes in an object using TestStand.?

    hi,
    I have a class named Status in C# that has 2 data members. There is another Class named Parameter and it has functions that return objects of type Status.
    I made the DLL of the class Parameter. Then i added that class to NI TestStand and called a fucntion and that function is returning an object of type Status.
    Is there any way by which i can access the Data Members of the returned Object in TestStand ??
    Thanx in advance
    Solved!
    Go to Solution.

    Yes, there is another alternative. If you make Status a value type (i.e. a struct in C#) then you can tell teststand to store it in a corresponding TestStand data structure rather than an object reference variable. This works even for private fields in your struct. To do this:
    1) First make Status a value type and make whatever other changes are necessary in your code to account for this (value types are copied when passed by value to another method, if this is not what you want you will need to pass them by reference - i.e. ref keyword in C#).
    2) Recompile your assembly.
    3) In the TestStand .NET module specification panel you should now see a new button next to the expression for the return value of type Status that looks like the TestStand data type icon. Push that button and it will prompt you to create a TestStand custom data type that corresponds to the .NET type. Select to save the type in MyTypes.ini type palette file. You only need to do this once. Once the type is in your MyTypes.ini type palette file it will be available from then on and you only need to update it if you change the .NET type.
    4) Create a local variable of the TestStand Custom data type instead of Object Reference. Note that you can expand it and see the properties underneath.
    5) Use this new local variable to store the Status return value. TestStand will copy/update the properties of the variable to correspond to those of the .NET struct that the method returns.
    NOTE: You can also just store the individual fields of a struct in separate variables by expanding the return value of type Status once it's a struct and specifying a separate variable for each field rather than creating a TestStand custom data type.
    Keep in mind that TestStand is making a copy when you store a struct this way so changes to the struct after this will not be reflected in the copy.
    Hope this helps,
    -Doug

  • How to access request content using MultipartMessage Object

    I want to take a file from the Client and upload it as a FileInputStream on the server.
    I have a simple form as follows:
    <form action="scan" name="scan_files" method="post"
    enctype="multipart/form-data">
    <input type="file" name="file1">
    <input type="file" name"file2"/>
    <input type="Submit" name="insert_scaned" value="Upload"/>
    </form>
    In my servlet I tried to use the com.sap.engine.services.servlets_jsp.lib.multipart.MultipartMessage
    class to parse the form information.
    protected void doPost(
    HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException {
    MultipartMessage multipartMsg =
    (MultipartMessage)request.getAttribute("com.sap.servlet.multipart.body");     
    if (multipartMsg != null) {
         multipartMsg.addFormParametersToRequest();
    The help said that once this is done the form information should be accessible via the
    request getParameter() method. However, I can't seem to get it working?
    How can I access the file so that I can parse it into a FileInputStream?
    Thanks.

    Hi Mat,
    first, welcome on SDN!
    About your question:
    From the APIDoc - https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/javadocs/nw04/sp12/j2ee%20engine/com/sap/engine/services/servlets_jsp/lib/multipart/multipartmessage.html - I would expect this as a solution:
    MultipartMessage multipartMsg = (MultipartMessage)request.getAttribute(MultipartMessage.MULTIPART_BODY_KEY);
    if (multipartMsg != null) {
      for (int i = 0; i < multipartMsg.getCount(); i++) {
        MultiPart mp = multipartMsg.getBodyPart(i);
        // mp.getInputStream, mp.getBody() or whatever you need
    Hope it helps
    Detlev
    PS: Please consider rewarding points for helpful answers on SDN. Thanks in advance!

  • How can I set time-out while accessing a url using URL object?

    Hi
    I'm trying to get the content of a URL using the following code. How can I set timeout
    (example, 10 secs), if the webserver takes a while to respond.?
    BufferedReader inbuf=null;
    URL url=null;
    try {      
         String urlString="http://host-machine/sms/index.jsp";          
         url = new URL(urlString);
         inbuf = new BufferedReader(new InputStreamReader(url.openStream()));
         String inputLine;
         String LongString="";
    while ( (inputLine=inbuf.readLine()) != null)
              LongString=LongString+inputLine;
              retString=LongString;          
              inbuf.close();
         catch (Exception e) {System.out.println(e)}
    Thanks a lot for your kind help
    Regards
    Kandasamy

    If you're using Java 5, see this thread (reply 10)
    http://forum.java.sun.com/thread.jspa?forumID=31&threadID=576157

  • How can I get the Doc object from any other object?

    Dear colleagues,
    in FrameScript it is dead-simple to get to the document part of any object, just add .Doc to the variable.
    How can I achieve the same with ExtendScript? I amtired of passing the document object next to AFrames or Pgfs along into subroutines, because those objects already contain the information about their document. But how do I access this?
    Thanks for pointers,
    - Michael
    PS: Almost the same is true for the page an object lives on. With FrameScript we use .Page, with ExtendScript you have to move up the object tree until you reach the UnanchoredFrame.PageFramePage…
    PPS: It would be great to see some convenience properties like .Doc and .Page implemented natively.

    I'll preface this response by admitting this far from an elegant solution, but I did write a function addressing this question, mostly as an exercise.
    If passed an object with an InTextFrame property (Pgf, AFrame, Cell, Fn) that resides in an open document, the function will return the Doc object. Otherwise, it returns undefined.
    function getParentDoc(testObj) {
        //Get object for current page
        try { var curPage = testObj.InTextFrame.FrameParent.PageFramePage; }
        catch(er) {return;}
        //Step backwards to first page in document
        var prevPage = curPage.PagePrev;
        while (prevPage.ObjectValid())
            curPage = prevPage;
            prevPage = prevPage.PagePrev;
        //Compare with first pages of open documents
        var testDoc = app.FirstOpenDoc;
        while (testDoc.ObjectValid())
            if (curPage.id==testDoc.FirstBodyPageInDoc.id) return testDoc;
            testDoc = testDoc.NextOpenDocInSession;    
        return;
    To your PPS: Rather than seeing the native framework grow bloated to address additional features, I would love to see Adobe and other developers publish libraries of useful functions and class extensions.

  • Ai CS6 - Skewing Objects To Match Other Objects

    Here is what i have.
    There are 3 elements there. the top of the clap board was placed before i started tryinbg to create the slanted dashes that are on the average clapboards. The white dash was skewed using Object > Transform > Shear. Then i atempted to rotate it to fit.
    I need 4 of these skwed white squares / trapazoids on the top along with 4 to match on the top of the larger potion of the clapboard. I do not want to eye it as it will be a part of a logo.
    What would be the best method to use?
    Is there a way to draw the 4 retangles on top of a perfectly horizontal long black rectangle and skew the white dashes at the same time?
    Is there a way to skew based on the demensions of the longer black rectangle?

    PC,
    Clapboards come in quite different designs.
    Presuming you wish to make one with the white diagonal lines inside the clapstick and reverse lines on the slate, you may, using fill/nostroke paths:
    1) Create the black clapstick rectangle in its horizontal position and the slate right beneath it;
    2) Create the leftmost white rectangle with the desired length (of the horizontal edges) and height on top of 1), placed vertically as desired, then Object>Transform>Shear using the desired angle, then Object>Transform>Move by the desired distance, equalling the desired length of the (of the horizontal edges) of the black lines in between; this will give you the 4 white lines, which you may group;
    3) Select the white lines and Object>Transform>Reflect horizontally ticking Copy, then Object>Transform>Move by the height of the clapstick to place the copied lines on the slate;
    4) Select 1) and 2), which you may group, then
    4a) With the bottom left Reference Point ticked in the Transform palette insert the desired rotation angle, or
    4b) Switch to the Rotate Tool and click the bottom left corner to set the centre of rotation there, then ClickDrag (anywhere) to rotate (you may hold Shift after starting to rotate to limit to the predetermined angles), or
    4c) Rotate in other ways.

  • How could I pass object to the other object

    Hi,
    How could I pass an object to the new initializing object, so that I can reference to the first object later?

    You mean something like
    MyClass1 myclass1 = new MyClass1();
    MyClass2 myclass2 = new MyClass2(myclass1); // <-- myclass1 is being passed to the constructor of myclass2                                                                                                                                                                                                                                                                                                                                                       

  • Using Shared Object Libraries

    How (or what) do we set when using shared object libraries?
    We have Java Native Methods which are implemented using C++ and stored in shared object libraries. We can build our project, but when trying to execute the project, the shared object libraries are not found. We had tried to set the external execution settings to include the library paths, but nothing seems to take affect.
    What do we need to set to run with the shared object libraries?

    RK,
    I appreciate your responce, hopefully we'll get this worked out. I will try to give you as much information as I can so you will hopefully understand the problem.
    We have added a Library Reference to our project - which is a jar file - this jar file contains our Business Objects which are implemented in Java. Within this Library Reference, there is a Java class which has a Native method. The method is implemented in C++ The C++ implementation of this method is within a C++ shared object library (libname.so).
    How do we let Creator know that we need to link in this C++ Shared Object Library at run time?
    The Modifers Properties for the method in the library reference are correctly set - that is they are set to Native. For a method within a java element, selecting or un-selecting this modifier simply changes the method declaration. It does not tell Creator where the actual implementation is (shared object library in this case).
    As originally stated, we tried to include our shared object library in the Execution Property of the properties window for the Java Element. Here is what we have done so far - all unsuccessful....
    Under the External Execution Property - we added the environment variable LD_LIBRARY_PATH set to our shared object library path. We also selected the Append Environment Variable (set to true). We are not able to modify the Library Path of the External Execution Property - it will not allow changes - all buttons are disabled in the pop up window.
    There are no properties for the Internal Execution within the Executor Properties, so there is nothing we can set there.
    We have tried to set the Debugger Execution properties in the same manner as the External Execution properties to run the project in Debug mode - and have the same problem - while executing the project, we get the error message which indicates that our shared object library can not be found.
    There are no property settings available on the J2EE Server Execution Properties to set.
    What do we need to set so that this Shared Object Library will be located during execution of our project under SJSC?
    Thank you for any suggestions you may have.
    --Scott                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Using Date objects in PDV tables

    Hi,
    Using SAP EP 6.0, SP9 and MSS 6.1.3, we're having at bit of trouble using other object types than String i PDV tables. The Java syntax allows for specifying other types by means of
    table.getColumn( "colName" ).setDataType( DataType.DATE );
    But nothing shows in the table; the cells are just left blank.
    Has anyone succeeded in specifying the data type?
    Thanks in advance,
    Rasmus

    I had some problems by just fetching a date and pushing it back to a MS SQL Database.
    I used the following reformating step to fix it:
    if (o instanceof Timestamp)
    String time = o.toString().substring(8,10)+"."+o.toString().substring(5,7)+"."+o.toString().substring(0,4)+" "+o.toString().substring(11,19);
    ht.put(columnName, time);
    o is the object i receve from the select statement and ht is a Hashtable where i put my data.
    To write the data back i now can use:
    UPDATE table SET columnname = 'valueOfColumn'
    This means i use the value i created above in Quotes to write it back.
    Format of Timestamp.toString() is something like yyyy-mm-dd hh:mm:ss.xx
    Format used by MS SQL (and i think by Access to) 'dd.mm.yyyy hh:mm:ss'

  • As3 get position from object in other object

    please i need help, i have a object inside this object i have other objects, (MC.Part1,MC.Part2,MC.Part3...etc), the MC rotate in the escene, that with interpolation, with the tools of flash,that is ok, the object parent rotate and the childs with he, but i want obtain the coordenate from the childs (MC1.Part1.x, MC1.Part1.y,MC1.Part1.z, etc), i try with trace(MC1.Part1.x), and always give me the same coordenate, i think is the coordenate in the parent, but i want the coordinate of the child when the parend is rotating.
    Please help me

    The coordinates of the child objects do not change relative to the parent that holds them if the parent is being moved, so they will report the same values all of the time.  If you want to know the location relative to the main stage, then you need to make use of the localToGlobal() method.  Try searching Google using terms like "AS3 localToGlobal tutorial" to get an explanation of how to use it.

Maybe you are looking for

  • Using Lab view ver 6,How can I read a cell of excel file right after I write to it

    How can I read a specif cell of an Excel file using Labview VI.

  • Problem in Report Output ( Batch )

    Hi , We have a batch job ( a report ) that runs everyday , till friday the output in the spool was as expected , we were getting the output of everyline item in the same line ( single line ) but from monday onwards the same report output in the spool

  • Ipad4 photo stream issues

    Newly activated ipad4 here. All our devices are on ios7.. On the iPad, there is no photo sharing setting under photos&camera. Only photo stream/on off. All other devices have the option. So, I can't see any shared streams on the iPad Also not getting

  • Dead session with dead processes

    Hi Technet guys we have sometimes users which cannot be logged off or the processes be killed. The users are connected to the Windows Terminal Server (W2K8R2) latest patches installed. They connecting with Citrix XenApp 6.5 to the Windows Terminal Se

  • Graphical display of hierarichal structure (ALV)

    Hi Friends, I have the requirement of displaying the hierarchical data in graphical mode. For this I am using the FM CNET_GRAPHIC_HIERARCHY, now the problem is that I want to navigate on to some screen when user clicks any node of the graphical struc