Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7949971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:07:25+00:00 2026-06-04T02:07:25+00:00

I’ve run into an interesting problem while developing an ORM framework for Android. I’m

  • 0

I’ve run into an interesting problem while developing an ORM framework for Android. I’m using a library called dexmaker for bytecode manipulation, which enables me to create proxies for persistent objects in order to implement lazy loading.

The proxied instance has an associated InvocationHandler such that when a method is called on the proxy, the invoke method is called on the InvocationHandler, which then calls the proxied object’s respective method assuming it’s been lazily loaded. Nothing too surprising — it’s just like Java’s Proxy class but allows me to proxy actual classes instead of interfaces (see dexmaker’s ProxyBuilder).

The part that’s become problematic is that I also use reflection to retrieve field values from persistent objects and — now that I’ve introduced lazy loading — proxies. Here is what I’m currently doing:

for (Field f : getPersistentFields(model.getClass()) {
    ...
    Object val = f.get(model); // model is either a persistent object or a proxy for one
    mapField(f, val, map);
}

This of course works for regular model instances, but for proxied instances, f.get(model) is not retrieving the proxied object’s field value. Instead, it’s returning the default value assigned in the class’s constructor. The access on the proxy’s field is not being intercepted obviously.

My question is this: is there any way I can intercept an access on a proxy’s member variable made through reflection? If not, how can I retrieve the value of a proxy’s field in a “reflection-like” way?

One possible workaround I’m thinking of would be to retrieve and then invoke the field’s getter method using reflection, but I’m wondering if there’s a more direct solution. This workaround, if it actually works, would require the object to have a getter method for all persistent fields — a requirement that should typically be followed from an OO-design point of view but also forces more work onto the user of the framework.

I’m open to any ideas.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T02:07:27+00:00Added an answer on June 4, 2026 at 2:07 am

    A good solution is to access the fields using setter/getters rather than using Field class. (I believe this is more than a workaround)

    On the other hand, if you want to go with the direct field accessing approach. As far as I see there is no easy way to intercept field accesses. Please check the answers to this question. Altough the question is related with intercepting field modification rather than reading
    the field, it may provide some insights and direction.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am currently running into a problem where an element is coming back from
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I would like to run a str_replace or preg_replace which looks for certain words
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.