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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:31:34+00:00 2026-05-29T10:31:34+00:00

Our project does some Java bytecode instrumentation. And we stumbled upon some strange behavior.

  • 0

Our project does some Java bytecode instrumentation. And we stumbled upon some strange behavior. Suppose the following code snippet:

  public void a() {
    new Integer(2);
  }

Oracle’s javac compiles the above into the following bytecode:

   0:   new #2; //class java/lang/Integer
   3:   dup
   4:   iconst_2
   5:   invokespecial   #3; //Method java/lang/Integer."<init>":(I)V
   8:   pop
   9:   return

and Eclipse’s compiler into:

   0:   new #15; //class java/lang/Integer
   3:   iconst_2
   4:   invokespecial   #17; //Method java/lang/Integer."<init>":(I)V
   7:   return

As you can see, Oracle compiler produces “dup” after “new”, whereas Eclipse doesn’t. Which is totally correct in this use case, as newly created Integer instance is not used at all, so no “dup” is required.

My questions are:

  1. Is there some overview of differences between different compilers? An article/blog post?
  2. Can I safely conclude, that if there is no “dup” between “new” and “invokespecial” then object is not used after initialization?
  • 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-29T10:31:35+00:00Added an answer on May 29, 2026 at 10:31 am
    1. Can I safely conclude, that if there is no “dup” between “new” and “invokespecial” then object is not used after initialization?

    I’m not sure what you mean exactly, but a reference to the created object might be stored somewhere by the constructor. Therefore the calling method might not use the object after initialization but the object might still be reachable and might be not garbage collectable therefore.

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

Sidebar

Related Questions

In our project the Java webservice communicate with the backend program written in C
Our team is willing to unit-test a new code written under a running project
We have some XSDs in our project that define types that use attributes, as
We have some auto-generated resource files in our project in Visual Studio 2008, with
We've just newly decided to use NServiceBus on our project and we're experiencing some
Our project in eclipse approximately shows the following folders: application - src - JRE
Some thoughts about writing custom html helpers. In our project everywhere you can find
Our project is running on Windows CE 6.0 and is written in C++ .
Our project is held in a SourceSafe database. We have an automated build, which
Our project has one folder that is not part of the solution. How can

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.