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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:14:14+00:00 2026-05-26T10:14:14+00:00

I’m guessing the following two functions compile to the exact same byte-code, but I

  • 0

I’m guessing the following two functions compile to the exact same byte-code, but I beg to ask the question. Does qualifying a method call where it is not necessary degrade performance?

For example:

package com.my;

import android.app.Activity;
import android.os.Bundle;

public class Main extends Activity {

    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        this.setContentView(R.layout.main); // Fully qualified 
        setContentView(R.layout.main);      // Not fully qualified
    }

}

The standard is to use the latter, but does the fully qualified call this.setContentView() have any negative effects?

  • 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-26T10:14:14+00:00Added an answer on May 26, 2026 at 10:14 am

    No, there isn’t any sort of penalty. Both calls will use invokespecial in the bytecode to invoke the member method.

    In standard Java, the following code:

    public class TestQualified {
    
       private void someMethod() {
       }
    
       public void otherMethod() {
           this.someMethod();
           someMethod();
       }
    }
    

    yields the following bytecode:

    Compiled from "TestQualified.java"
    public class TestQualified extends java.lang.Object{
    public TestQualified();
      Code:
       0:   aload_0
       1:   invokespecial   #1; //Method java/lang/Object."<init>":()V
       4:   return
    
    private void someMethod();
      Code:
       0:   return
    
    public void otherMethod();
      Code:
       0:   aload_0
       1:   invokespecial   #2; //Method someMethod:()V
       4:   aload_0
       5:   invokespecial   #2; //Method someMethod:()V
       8:   return
    
    }
    

    As you can see, both calls are the same.

    Now Android converts the .class files into dalvik bytecode using the dx tool, which outputs .dex files. Since the .class files don’t show any distinction between the two invocations, the corresponding .dex file will show no difference either:

    Processing 'TestQualified.dex'...
    Opened 'TestQualified.dex', DEX version '035'
    Class #0            -
      Class descriptor  : 'LTestQualified;'
      Access flags      : 0x0001 (PUBLIC)
      Superclass        : 'Ljava/lang/Object;'
      Interfaces        -
      Static fields     -
      Instance fields   -
      Direct methods    -
        #0              : (in LTestQualified;)
          name          : '<init>'
          type          : '()V'
          access        : 0x10001 (PUBLIC CONSTRUCTOR)
          code          -
          registers     : 1
          ins           : 1
          outs          : 1
          insns size    : 4 16-bit code units
    0000e4:                                        |[0000e4] TestQualified.<init>:()V
    0000f4: 7010 0300 0000                         |0000: invoke-direct {v0}, Ljava/lang/Object;.<init>:()V // method@0003
    0000fa: 0e00                                   |0003: return-void
          catches       : (none)
          positions     : 
            0x0000 line=1
          locals        : 
            0x0000 - 0x0004 reg=0 this LTestQualified; 
    
        #1              : (in LTestQualified;)
          name          : 'someMethod'
          type          : '()V'
          access        : 0x0002 (PRIVATE)
          code          -
          registers     : 1
          ins           : 1
          outs          : 0
          insns size    : 1 16-bit code units
    0000fc:                                        |[0000fc] TestQualified.someMethod:()V
    00010c: 0e00                                   |0000: return-void
          catches       : (none)
          positions     : 
            0x0000 line=4
          locals        : 
            0x0000 - 0x0001 reg=0 this LTestQualified; 
    
      Virtual methods   -
        #0              : (in LTestQualified;)
          name          : 'otherMethod'
          type          : '()V'
          access        : 0x0001 (PUBLIC)
          code          -
          registers     : 1
          ins           : 1
          outs          : 1
          insns size    : 7 16-bit code units
    000110:                                        |[000110] TestQualified.otherMethod:()V
    000120: 7010 0200 0000                         |0000: invoke-direct {v0}, LTestQualified;.someMethod:()V // method@0002
    000126: 7010 0200 0000                         |0003: invoke-direct {v0}, LTestQualified;.someMethod:()V // method@0002
    00012c: 0e00                                   |0006: return-void
          catches       : (none)
          positions     : 
            0x0000 line=7
            0x0003 line=8
            0x0006 line=9
          locals        : 
            0x0000 - 0x0007 reg=0 this LTestQualified; 
    
      source_file_idx   : 3 (TestQualified.java)
    

    You can see that both calls are made using invoke-direct. Hence there is no performance penalty here either.

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

Sidebar

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I need to clean up various Word 'smart' characters in user input, including but
Does anyone know how can I replace this 2 symbol below from the string

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.