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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:07:54+00:00 2026-05-13T22:07:54+00:00

Examining bytecode, I’ve noticed javac seems to duplicate checkcast instructions when casting to array

  • 0

Examining bytecode, I’ve noticed javac seems to duplicate checkcast instructions when casting to array types.

Cast.java:

    class Cast {
      void test(Object a) {
        Object[] b = (Object[]) a;
      }
    }

javap disassembly of the javac compiled version

    void test(java.lang.Object);
      Code:
       0:   aload_1
       1:   checkcast   #2; //class "[Ljava/lang/Object;"
       4:   checkcast   #2; //class "[Ljava/lang/Object;"
       7:   astore_2
       8:   return

Testing jikes shows the expected single cast

    void test(java.lang.Object);
      Code:
       0:   aload_1
       1:   checkcast   #10; //class "[Ljava/lang/Object;"
       4:   astore_2
       5:   return

checkcast is supposed to raise an exception if the object can’t be treated as the requested type and otherwise does nothing, so I don’t see why it might help to double the cast. I haven’t looked at the JDK sources to see how it’s produced, and if that helps explain the why (maybe it’s meant as a hint).

  • 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-13T22:07:54+00:00Added an answer on May 13, 2026 at 10:07 pm

    It is a known bug of javac. But it is mostly harmless.

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

Sidebar

Related Questions

Without examining each method, how can I find duplicate methods in a class? Duplicate
I am examining a core dump, and noticed that in one frame the 'this'
Examining a Java runtime with CMS (Concurrent-Mark-Sweep) GC enabled, what is the definition of
From examining the documentation for Ruby 1.9.3, both Array#<< and Array#push were designed to
I've been examining the Java Language Specification here (instead I should be out having
I've been examining some PHP code today and I've noticed the usage of do-while
This is almost exactly a duplicate of Examining a single changeset in Mercurial ,
Possible Duplicate: Why should I bother about serialVersionUID? I was examining the Struts2 validation
I've been examining the code of CodeIgniter and CakePHP and I noticed that some
Examining Zend Framework, I found that all setter methods (of those I’ve examined) return

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.