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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:06:59+00:00 2026-05-30T05:06:59+00:00

Goal Detecting where comparisons between and copies of variables are made Inject code near

  • 0

Goal

  • Detecting where comparisons between and copies of variables are made
  • Inject code near the line where the operation has happened
  • The purpose of the code: everytime the class is ran make a counter increase

General purpose: count the amount of comparisons and copies made after execution with certain parameters

2 options

Note: I always have a .java file to begin with

1) Edit java file


Find comparisons with regex and inject pieces of code near the line
And then compile the class (My application uses JavaCompiler)

2)Use ASM Bytecode engineering


Also detecting where the events i want to track and inject pieces into the bytecode
And then use the (already compiled but modified) class

My Question

What is the best/cleanest way? Is there a better way to do this?

  • 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-30T05:07:00+00:00Added an answer on May 30, 2026 at 5:07 am

    If you go for the Java route, you don’t want to use regexes — you want a real java parser. So that may influence your decision. Mind, the Oracle JVM includes one, as part of their internal private classes that implement the java compiler, so you don’t actually have to write one yourself if you don’t want to. But decoding the Oracle AST is not a 5 minute task either. And, of course, using that is not portable if that’s important.

    If you go the ASM route, the bytecode will initially be easier to analyze, since the semantics are a lot simpler. Whether the simplicity of analyses outweighs the unfamiliarity is unknown in terms of net time to your solution. In the end, in terms of generated code, neither is “better”.

    There is an apparent simplicity of just looking at generated java source code and “knowing” that What You See Is What You Get vs doing primitive dumps of class files for debugging and etc., but all that apparently simplicity is there because of your already existing comfortability with the Java lanaguage. Once you spend some time dredging through byte code that, too, will become comfortable. Just a question whether it’s worth the time to you to get there in the first place.

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

Sidebar

Related Questions

Goal: json_encode a PHP object that has private properties Send the encoded object as
Goal: Rolling/Running total for all statements at the end of each month. Code: select
Goal: To launch VLC player through PHP code, and play the specified video in
Does anyone have experience detecting identical text(); and class? here is my current code
Possible Duplicate: Circle line collision detection I'm trying to do collision testing between a
Goal: to programmatically determine the sizes (in bytes) of the fields of a class.
goal: I have the string 1234432144 I want to only replace the first 2
Goal Pass images generated by one process efficiently and at very high speed to
Goal To use a CREATE TYPE statement in HSQLDB 2.0.0 to create a user-defined
Goal : Our application is built using multiple types (e.g. Person, PersonSite(ICollection), Site -

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.