How to write into a private fiald from the outer world?

Hello,
I have just got some strange rerults and want to share them with you.
I'm writing a bean class. Each field of the bean conforms to a column in a table of the database. The bean is filled with a record of database from database by Entity Factory and is returned to me. I have not seen the sources of the Entity Factory system. The beans are entities that have setter and getters.
All my colegues use a standard scheme with private field (named as a column in the database) and setter/getter for it. I have deriviated from this scheme creating a virtual property; that is only setter and getter with no private field. And the Entity Factory started crushing! It cannot find the private field anymore to write data from a table into it!
I had an experiment adding the private field with the final modifier. And what do you think I've got in effect? The entity Factory started complaining that it CANNOT SET A PRIVATE FIELD BECAUSE IT IS MARKED WITH FINAL! Removing the final has solved the problem.
Can you beleive this story? As the system is Enterprise, I would think that application server would sublass my implementation. But the privates should be inaccessible anyway. I'm going to look into source codes tomorrow.

As Kayaman says, you can get around the restriction described in the JLS by use of Reflection.
Consider the following example:
class SimpleKeyPair {
    private String privateKey = "original"; // private field
public class ReflectionChecker {
    public static void main(String[] args) throws Exception {
        SimpleKeyPair keyPair = new SimpleKeyPair();
        Class c = keyPair.getClass();
        // get the reflected object
        Field field = c.getDeclaredField("privateKey");
        // set accessible true
        field.setAccessible(true);
        System.out.println("Value of privateKey: " + field.get(keyPair)); // prints "original"
        // modify the member varaible
        field.set(keyPair, "altered");
        System.out.println("Value of privateKey: " + field.get(keyPair)); // prints "altered"
}

Similar Messages

  • How do I get to private mail from the forum?

    This forum is really lame. I don't see a way to read my private forum messages. It ought to be on the main forum page. I'm not about to go exploring the entire site to see me messages. This forum sucks as does the entire verizon web site!

    The envelope on the upper right of your screen turns gold when you have a message. It's easy to see!

  • My 12" powerbook logics card crashed. I have a 17". How do i retrieve my internet bookmarks from the 12" by putting it into Target mode on the 12" and looking into the hard drive on the 12"?

    My 12" powerbook logics card crashed. I have a 17". How do I retrieve my internet bookmarks from the 12" by putting it into Target mode on the 12" and looking into the hard drive on the 12"? Where on the 12" hard drive do I go to search for them?

    If the 12's logic board is trashed, I don't think you can get into FireWire Target Disk Mode. The computer has to start to get to FWTDM. Will it starte and run at all?
    If it won;t start, you will have to go inside and extract the hard drive. Then get this gadget:
    Newer Technology Universal Drive Adapter USB 3.0/2.0 - connects any 2.5", 3.5" or 5.25" drive
    It allows you to connect a bare drive to another computer that has USB. It will act just like an external disk drive. Assuming the 12's drive is not damaged due to the LB failure, you can retrieve files quickly.

  • HELP!!!!!! - How to write into a file?

    How to write into a file?
    I want to make a script that will connect(not enter) to my website[for example, www.vasa.com] every time i connect to the internet.
    Now i have 3 problems:
    1. i dont know how to write into a file
    2. i dont know how to make it connect to my 'server' without entering the website
    3. i dont know what file to write it to
    so if someone can help me, please do.

    Well, how about RTFM?? In this case that can be found here:
    http://developer.java.sun.com/developer/onlineTraining/
    BTW - these things have been asked azillion times, search the forum.

  • How do I delete old email addresses from the pop up list that comes up when I put a letter into the "To" box. These addresses are not in my address book.

    How do I delete old email addresses from the pop-up list that comes up when I put a letter into the "To" box? They are not in my Address Book.  Wrong addresses get in the way and I sometimes select the wrong one.

    Edit the list the comes up when you go to the Window menu and select "Previous Recipients".
    charlie

  • How do I remove an old file from the Finder Favorites list?

    Good Afternoon.
    I have a shiney new MBPro with 10.7.1.
    On my old machine running Snow Leopard, I had two .xls files I used often that I had dragged to the left side into the favorites. The truth is, I hadn't used them in months, but hadn't bothered to remove them. Then about ten days ago, the Bad Thing happened, and I had to replace my laptop rather suddenly. The nice folks at the Apple store transferred all the data and I was off an running in just a few hours.
    Now, I thought to myself, I should remove those two files since I don't use them any more. But how?
    If I click on them nothing happens. If I right-click on them, nothing happens. I can't drag them out because they don't drag and they aren't listed on the list of favorites that can be toggled on and off in preferences.
    I checked. The files did still exist but deleting them didn't remove their names from the favorites list.
    Any suggestions as to how to remove these two .xls files from the Finder's Favorites list?
    Thanks. A picture is below.

    The msot amazing person ,just posted an answer to my other question which worked here too.
    Three cheers for Kappy!
    Just hold down the CMD key and drag them off. How simple is that?? They didn't klnow this at the Genius bar when I asked this morning. I am amazed.
    I wish I knew how to send Kappy cookies.
    Thank you Kappy.

  • Ok I can't seem to get my apps,music, or photos from my iCloud from when I first setup iCloud on a iPhone 4. How do I get my things back from the iCloud and get them to my new device?

    Ok I can't seem to get my apps,music, or photos from my iCloud from when I first setup iCloud on a iPhone 4. How do I get my things back from the iCloud and get them to my new device?

    If you no longer have the phone or have any Backup of it at all, you can re-download your apps and your content from the iTunes Store by logging into your Apple ID at settings> iTunes & App Store. Unfortunately you can no longer recover the data that was associated with those apps.
    So far as your photos go, you can recover any photos that were in photo stream and taken less than 30 days ago by logging in with your Apple ID to settings> iCloud> photos. Unfortunately you will be unable to recover any photos from your camera roll.

  • The logic board on my MacBook Pro has failed. How do I retrieve all my data from the hard drive?

    The logic board on my MacBook Pro has failed. How do I retrieve all my data from the hard drive?

    Remove the drive and put it in an external enclosure. Backup the drive completely. Repartition and format the drive. Replace the drive into the computer. Take the computer in for the logicboard replacement.

  • How do you get old emails back from the cloud storage

    how do you get old emails back from the cloud storage

    How did you get them into cloud storage?

  • How do I import an image directly from the internet without printing and scanning it in first?

    How do I import an image directly from the internet without printing and scanning it in first?

    You can also Ctrl click on the image, save the image to your desktop and open it in Photoshop.
    1.
    2.
    3. Open in Photoshop by double-clicking on the saved image on your Desktop or Cmd o in Photoshop.
    I don't see any point to copying and pasting from a browser into a new file in Photoshop.
    If you want to put an image onto an already open image in Photoshop, use the File > Place... command and select your saved image.
    Gene

  • How can i lookup a session bean from the client side

    how can i lookup a session bean from the client side...........i am using sun appserver..............
    this is my code.................[B]
    private final static String JNDI_NAME="ejb/LmsBean";
    private static String url="ldap://localhost:4848";
    Hashtable h=new Hashtable();
    h.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
    h.put(Context.PROVIDER_URL,url);
    System.out.println("Before Loading Context in Delegate");
    Context ctx=new InitialContext(h);
    System.out.println("Loaded Context in Delegate");
    Object obj=ctx.lookup(JNDI_NAME);
    System.out.println("Loaded Object in Delegate");
    System.out.println("Before Loading Home in Delegate");
    LmsHome home = (LmsHome )PortableRemoteObject.narrow(obj,com.parx.lms.controller.LmsHome.class);
    System.out.println("Loaded Home in Delegate");
    lms = home.create();
    System.out.println("Loaded remote in Delegate");
    [B]and i got the exception........
    Inside Client before calling delegate
    Before Loading Context in Delegate
    javax.naming.CommunicationException: Request: 1 cancelled
    javax.naming.CommunicationException: Request: 1 cancelled
    at com.sun.jndi.ldap.LdapRequest.getReplyBer(LdapRequest.java:60)
    at com.sun.jndi.ldap.Connection.readReply(Connection.java:405)
    at com.sun.jndi.ldap.LdapClient.ldapBind(LdapClient.java:340)
    at com.sun.jndi.ldap.LdapClient.authenticate(LdapClient.java:171)
    at com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:2640)
    at com.sun.jndi.ldap.LdapCtx.<init>(LdapCtx.java:290)
    at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(LdapCtxFactory.java:175)
    at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(LdapCtxFactory.java:193
    at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(LdapCtxFactory.ja
    va:136)
    at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(LdapCtxFactory.jav
    a:66)
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
    62)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243
    at javax.naming.InitialContext.init(InitialContext.java:219)
    at javax.naming.InitialContext.<init>(InitialContext.java:195)
    at com.parx.lms.lmsdelegate.LmsDelegate.getController(LmsDelegate.java:3
    0)
    at com.parx.lms.lmsdelegate.LmsDelegate.addUserDelegate(LmsDelegate.java
    :50)
    at com.parx.lms.client.consoleClient.Client.main(Unknown Source)
    pls go tru the exception and pls help.........

    That url string should be having the server name or ip instead of localhost.

  • How to upload words, exel, PDF file from the pc via itune to the iPad, and where will the uploaded file be saved? In the apps?

    How to upload words, exel, PDF file from the pc via itune to the iPad, and where will the uploaded file be saved? In the apps?

    You will need an app (or apps) on your iPad that is capable of reading the documents, as they will be saved with the app - if you don't have such an app then there is nothing to transfer them to or to read/access them.
    One method of transferring them is toconnect your iPad to your computer's iTunes, select it's app tab, and then scroll to the bottom of it - you should the apps That you've got that are capable of file-sharing (if you've got any).  Selecting/high-lighting one of them should then allow you to add files to it via the box to the right of it.
    An alternative way to get the documents onto your iPad is if the app that you want to transfer them to has a wifi setting, which will then allow you to transfer the documents wirelessly. You can also send the documents to yourself as attachments and then use Mail's 'open in' facility to copy them into your chosen app.
    Edit : more info on file sharing from the manual :
    File Sharing lets you transfer files between iPad and your computer. You can share files created with a compatible app and saved in a supported format.
    Apps that support file sharing appear in the File Sharing Apps list in iTunes. For each app, the Files list shows the documents that are on iPad. See the app’s documentation for how it shares files; not all apps support this feature.
    Connect iPad to your computer.
    In iTunes, select iPad in the Devices list, then click Apps at the top of the screen.
    In the File Sharing section, select an app from the list on the left.
    On the right, select the file you want to transfer, then click “Save to” and choose a destination on your computer.
    Transfer a file from your computer to iPad:
    Connect iPad to your computer.
    In iTunes, select iPad in the Devices list, then click Apps at the top of the screen.
    In the File Sharing section, click Add.
    Select a file, then click Choose (Mac) or OK (PC).
    The file is transferred to your device and can be opened using an app that supports that file type. To transfer more than one file, select each additional file.
    Delete a file from iPad: Select the file in the Files list, then tap Delete.
    Message was edited by: King_Penguin

  • How do I get a page count from the HP Photosmart 5514?

    How do I get a page count from the HP Photosmart 5514?

    Simple.  Access the printer web gui by typing in the printers IP address into your browsers address bar.  Select Tools/Usage reports.  Done.

  • How do I export words and definitions from the glossary widget in C7?

    How do I export words and definitions from the glossary widget as XML? I need to use the same glossary in several projects. When I copy and paste the widget to a different project about 1/2 of the definitions disappear. Figured I would try exporting the words then importing them back in new glossaries in each project. Using 7 on a Mac.

    Yes i read, and the answer to the main question is still the same, you cannot export, you just can import definitions if you previously have structured them into an xml file. So, first of all it would be useful to warn the user to ALWAYS start from an xml file BEFORE starting populating the glossary. Furthermore, not all users are supposed to manage easily an xml editing, and the widget itself has been programmed to insert the definitions with a simple method, so it would be necessary also to have an instrument to export to xml for importing purpose. Storyline has the same lack, you cannot move glossary from one project to another but you are forced to start from an old project or insert the glossary itself into a master project. You will agree with me that an xml export feature is not something so difficult to add for the widget. In my personal example, i added about 200 definitions, then i discovered that the glossary of captivate 7 does not work well in html5, the new one in captivate 8 is little bit better, but still not working on chrome (at least on ipad it shows, but you cannot show a button over it since it goes always on the top of everything, so at the moment i inserted a big transparent square behind it to close everyting like a lightbox). This widget is still very buggy and need to be improved.

  • I lost my I phone 4 , how to track it's imei number from the apple id that  I used in that lost iPhone

    I lost my I phone 4 , how to track it's imei number from the apple id that  I used in that lost iPhone

    The only way to locate/disable/erase any lost/stolen iPhone/iPod Touch is through Find My Phone or a similar app. However, this requires that Find My Phone be setup/activated, on your phone, before it was lost/stolen. You would then login at iCloud.com & try to locate it. This requires the phone be turned on & have an Internet connection. There is no other way to locate a lost/stolen iPhone. Apple can't/won't help you, nor will your carrier. Report the loss to the Police, your carrier & Insurance company. Change all of your passwords.
    If your carrier offers Blacklisting & they Blacklist the phone, it will be unusable as a phone.
    If locked with a passcode, and running iOS 7.0, then phone cannot be activated or the passcode removed without knowing your Apple iD/Password. It will be nothing but a useless paperweight.
    If not running iOS 7.0, the phone can be forced into recovery mode & restored.

Maybe you are looking for

  • Screen Shadow (Macbook Pro mid-2010)

    Hi, I just today replaced my lcd (just the screen, not the whole assembly) because of an issue I've had for a while now with pink lines appearing on the screen. After first replacing the LVDS cable without resolving the issue, I took the next step an

  • Photoshop elements 5.0 program error message

    I cannot save in jpeg format. I keep getting an error message when I try. The error message says cannot complete your request because of a program error. Please help as soon as possible.

  • Deploying ApplicationModule as Session Bean

    I am trying to deploy an ApplicationModule as a EJB Session Bean. How should I set up the InitialContext if I am testing this using the embedded OC4J in JDeveloper? Should I be using JboContext.PLATFORM_EJB (this is giving me a ClassNotFoundException

  • Itunes backup disc error

    I made a complete back-up of my itunes library (I have the disc). After reformatting my computer and loading all my programs back in; I started to reload my itunes. itunes took all of my back-up disc except for one (1). All of the information is on t

  • Date Fields in CN60 Report

    Hi, I need to have the Basic Start and Finish dates fields of the WBS elements in the CN60 Transaction. How to get the the dates fields? Regards