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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:49:33+00:00 2026-06-13T20:49:33+00:00

I am developing an instrumentation engine with ASM and I need to intercept the

  • 0

I am developing an instrumentation engine with ASM and I need to intercept the invocation of methods, which receive parameters of array type. For that purpose I implemented a MethodVisitor and in its visitMethodInsn I check if the desc parameter specifies any parameter of array type. If the target method has no parameters of array type, then I have nothing to do and I insert the original method invocation: super.visitMethodInsn(opcode, owner, name, desc);

On the other hand, if the target method has parameters of array type, then I must perform a specific action for its arguments. The easiest solution I got to access each argument was to invoke a mediator method, with the same descriptor of the target method, and in this mediator I can easily access its parameters (corresponding to the arguments passed to the target method).

Yet, a problem arises when the target method is an instance constructor (<init>). In Java the new XXX() is translated to bytecode as follows:

  NEW XXX 
  DUP 
  INVOKESPECIAL XXXX.<init>()

According to the approach that I explained above, I am moving the INVOKESPECIAL call into a mediator method and the newly instantiated object is the first argument of this mediator. Yet, the verifier raises an error for this mediator, reporting that the first parameter of the mediator (which will be the first argument of the target method – <init>) is not an “unitialized object”. More precisely I got the error: Exception in thread "main" java.lang.VerifyError: Expecting to find unitialized object on stack”.

Once I split the bytecodes NEW and INVOKESPECIAL in two different methods, then the verifier claims that the argument passed to the INVOKESPECIAL has been already initialized.

Any suggestion to work around this problem? (please, do not answer me to avoid the mediator and access directly the arguments in the stack, because it is not simple to duplicate and replace arguments that occupy an arbitrary position in the stack.)

  • 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-13T20:49:34+00:00Added an answer on June 13, 2026 at 8:49 pm

    The verifier is correct to reject your code (see JVM specification). There is no way to bypass bytecode verifier.

    One way around is to inline the mediator code at the point of constructor invocation. You still can invoke parts of mediator as method calls before or after the invocation of the constructor, but the very constructor invocation has to be in the same method as the new instruction.

    Another way is to make special mediators for every class being instantiation, so the mediators invoke the new instruction themselves, along with the constructor call.

    You can also look at existing AOP libraries if they can do the required job correctly.

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

Sidebar

Related Questions

I am developing a Java instrumentation engine with ASM and there is a situation
iam developing one application.In that i need to get the music files from the
Developing for iPhone, I have a collection of points that I need to make
I am developing a C# application from which I need to execute a process
I am developing a restlet server inside a Glassfish server that will receive petitions
Developing a project of mine I realize I have a need for some level
Developing a C# .NET 2.0 WinForm Application. Need the application to close and restart
Iam developing one application.In that iam placing the radio buttons(uiimageview) on table view and
Developing a site that requires monthly subscriptions via PayPal. If a buyer has an
Developing a series of POCOs on my project, and just realized that some of

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.