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 6600483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:37:44+00:00 2026-05-25T18:37:44+00:00

I am looking for a way to dynamically define classes and instantiate them in

  • 0

I am looking for a way to dynamically define classes and instantiate them in Android, at runtime. From my understanding, this is already done in Android, I just need some help figuring it out.

I can a similiar result in Javascript and PHP. I know it can be done in Java using something like ASM, BCEL or CGlib. However, I do not know enough about any of these to understand if they will work on Android. Or, of they will work, what are the implications?

If, hypothetically, all three will work in Android, can someone point me in the correct direction as to where to start understanding which to use, and how to use it?

I haven’t done much Java programming, and I have only just recently been working with it in Android, so, I appreciate all of the help/correction I can get. With that said, I would appreciate if your answer is NOT simply: Don’t do this. I am looking for how to do this specifically, not how to do it right. At least, not until my app comes crashing down. 🙂

I believe that this already happens in Android in the following situations: (Not 100% SURE)

Creating an object from JSON.
AIDL

  • 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-05-25T18:37:44+00:00Added an answer on May 25, 2026 at 6:37 pm

    Don’t do this 🙂

    I actually doubt there are JSON libraries that behave this way; the two accepted ways I know (I am not an expert on this, though) are either to create some sort of data structure holding name-value pairs – i.e. add stuff to a data structure but not create a new class – or prepare a template of a class which will be populated from a JSON object.

    Java, being statically-typed, is not really suitable for creating whole new classes at run-time, and there is no reflection support for that – though there is support for accessing objects of unknown types (e.g. querying for all their fields / methods).

    What you can do is to manually write a java class to a file – either in Java code and then compile it somehow, or directly in bytecode – and then load that file at runtime. It’s ugly, but it will work. Then it’s just the same as any runtime loading of classes – either you rely on the base class / interface of the loaded class, or you have to use reflection to do anything meaningful with it.

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

Sidebar

Related Questions

I am looking for a way to edit data and have values dynamically calculated
I'm looking for way to PHP to detect if a script was run from
I am looking for the best way to dynamically arrange the location of labels
I'm prototyping the best way to dynamically connect web parts at runtime. Essentailly, the
I'm looking for a way to dynamically load a master page in order to
I am looking for a way to format a floating point number dynamically in
I am looking for a very quick way to render dynamic images from small
I'm looking for a way to return a single JSON/JSONP string from a cross-domain
What I am looking for is to dynamically create two textboxes from the C#
Im looking for a way to dynamically create banners who can get placed on

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.