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

  • Home
  • SEARCH
  • 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 8814427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:07:13+00:00 2026-06-14T04:07:13+00:00

Consider two lines from code: … rs.next(); //rs is ResultSet interface. rs.getString(name); … Byte

  • 0

Consider two lines from code:

...
rs.next();  //rs is ResultSet interface.
rs.getString("name");
...

Byte code generated by javap is :

...
35:  invokeinterface #9,  1; //InterfaceMethod java/sql/ResultSet.next:()Z
   40:  pop
   41:  aload   4
   43:  ldc     #10; //String name
   45:  invokeinterface #11,  2; //InterfaceMethod java/sql/ResultSet.getString:
(Ljava/lang/String;)Ljava/lang/String;
   50:  pop
   51:  aload_2
   52:  invokeinterface #12,  1; //InterfaceMethod java/sql/Connection.close:()V

 ...

I am trying to interpret this bytecode.

For line rs.getString("name"); bytecode starts from line 43 to 51.

1)At line 45 method is INVOKED and a string object is returned as represented by Ljava/lang/String.Is this right OR here, only method is being loaded from constant pool with index #11 TO STACK and executed at line 50 ???

2) where does the string object returned by rs.getString("name"); lies? on stack or on heap as i think aload_2 is pushing some value on stack.

Actually here, i am confused in the following:

If suppose i have :

 ...
rs.next();
rs.getString("name");
rs.getString("name");
rs.getString("name");
rs.getString("name");
...10 more times...
...

and all return a same name. Then there will be 10 different string objects with same value.So it will be memory wasting and is a case for using intern(). But if these will be on stack then will it still be considered as memory wastage and need intern()???

3) I think string object returned by rs.getString("name"); is not an interned string so definitely it will not be on Permanent Generation memory area??

  • 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-14T04:07:14+00:00Added an answer on June 14, 2026 at 4:07 am

    The relevant part of the bytecode for the call

    rs.getString("name")
    

    is

    41:  aload   4
    43:  ldc     #10; //String name
    45:  invokeinterface #11,  2; //InterfaceMethod java/sql/ResultSet.getString:(Ljava/lang/String;)Ljava/lang/String;
    50:  pop
    

    Taking this line one opcode at a time:

    41:  aload   4
    

    pushes the object stored in local variable #4 (rs) onto the stack

    43:  ldc     #10; //String name
    

    pushes the string constant "name" onto the stack

    45:  invokeinterface #11,  2; //InterfaceMethod java/sql/ResultSet.getString:(Ljava/lang/String;)Ljava/lang/String;
    

    pops the top 2 items off the stack to call the interface method java/sql/ResultSet.getString:(Ljava/lang/String;)Ljava/lang/String; and pushes the result (a Ljava/lang/String;) onto the stack.

    50:  pop
    

    then pops the result from the previous method off of the stack.

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

Sidebar

Related Questions

I'm a bit puzzled about the conditional operator. Consider the following two lines: Float
Consider the following two EXPLAINs: EXPLAIN SELECT * FROM sales WHERE title != 'The'
I currently have an odd problem with ASP.Net authentication. Consider the two following lines:
RDBMS SQL Server, T-SQL Consider a table that links information from two different tables:
Consider two tables: Transactions , with amounts in a foreign currency: Date Amount =========
Consider two methods on the controller CustomerController.cs : //URL to be http://mysite/Customer/ public ActionResult
Consider two dates 2010-03-18 22:30:45 and 2010-03-19 03:30:15 .... How to get the number
let's consider two views that use the same layout composed of: A left column
consider the two template functions below: template <typename T, typename A> T* create(A i)
Consider these two classes mapped to the same table. One is readonly via mutable=false.

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.