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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:01:39+00:00 2026-06-01T22:01:39+00:00

Given the .class file of Java Class A, is there a way (with BCEL,

  • 0

Given the .class file of Java Class A, is there a way (with BCEL, ASM, etc. for instance) to extract a given bytecode sequence (assuming it’s a basic block), place it in a separate location, and then later execute that sequence of bytecodes?

Example:
Source code has the lines …
a += b;
b += 21;
.
.

I only have access to the bytecode representation. I want to extract those bytecodes and treat them as a black box. In Class A’s instructions, instead of the source line ‘a += b;’ I want it to point to this external black box X which holds the appropriate missing bytecode sequence. I want to feed the black box all necessary variables on the stack frame (for instance, the current values of a, b, perhaps method parameters to be used in black box X…) and then, after execution of the bytecode sequence, the black box will return control to the original Class A along with the newly updated frame variables…

Thanks for any ideas.

Edit:

As suggested below, the black box most reasonably would be a stub method inside of a stub class file. The question then becomes, how do I most reasonably create this well formed stub class and method from this instruction sequence, and how to do the transfer of control to, from the original Class A. Ideally this would be done ‘offline’, at compile time.

  • 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-01T22:01:41+00:00Added an answer on June 1, 2026 at 10:01 pm

    The tricky part is how you going to identify your instruction sequence. I can think of doing that by line number or some marker method call at the beginning and end of the sequence.

    When you get that sorted out, you can use ASM’s analysis package to calculate types of local variables and stack slots and expose them as parameters of some method where you’d copy your bytecode sequence.

    My article from AOSD’07 should give you a good starting point with ASM. Replace Method Body and Inline Method sections describing transformations very similar to what you may need to use.

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

Sidebar

Related Questions

I was wondering if there is a way to measure a given bytecode (class
I have a data structure which is as given below: class File { public
Possible Duplicate: How do you find all subclasses of a given class in Java?
I'm attempting to extract a given pattern within a text file, however, the results
Is there a way to easily create Java Input/Output streams for unnamed pipes created
Given: class A { public void m(List l) { ... } } Let's say
Given: class example { public: std::vector<std::vector<int>> a; int b; } func() { example e;
i have been given class with int variables x and y in private, and
I understand that CoCreateInstance finds the COM server for the given class id, creates
I want to override the tree_id field as following: Given: class Thing(MPTTModel): thing_id =

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.