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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:10:59+00:00 2026-06-14T09:10:59+00:00

The method DriverManager.getCallerClassLoader() in class java.sql.DriverManager is declared as native . I understand that

  • 0

The method DriverManager.getCallerClassLoader() in class java.sql.DriverManager is declared as native. I understand that all the class loaders references in an application are available in the current executing JVM. Also, my basic understanding about native method is that it’s used to call the method defined in native libraries and they execute outside the JVM execution environment.

My question is, what is that needed by DriverManager.getCallerClassLoader() which requires its implementation to be native?

  • 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-14T09:11:01+00:00Added an answer on June 14, 2026 at 9:11 am

    My basic understanding about native method is that its used to call the method defined in native libraries

    This is correct, native methods represent calls of the code that is part of a natively compiled library

    and they execute outside the JVM execution environment

    That is what native methods typically do. That is, the native methods that Java users write. However, native methods are not limited in what they can do: once you’re outside of JVM, you can do what you wish. In fact, Java’s built-in classes such as Class<T>, heavily rely on the ability to do so, with dozens of native method sprinkled around their Java code.

    One of these methods is package-private java.lang.Class<T>.getClassLoader0 (yes, with a zero). The implementation of ClassLoader.getCallerClassLoader ultimately refer to this method, which queries the internals of JVM to fetch the class loader.

    Note that DriverManager cannot forward the call to ClassLoader.getCallerClassLoader, because that would return the DriverManager‘s class loader (because DriverManager would be the caller of getCallerClassLoader). It is not possible for the DriverManager to repeat the “magic” of ClassLoader‘s getCallerClassLoader either, because it is located in a different package (i.e. not in the java.lang), so Class<T>.getClasLoader0 is not accessible. That is why it is forced to move the getCallerClassLoader into the native territory, where the native code can obtain the calling class and fetch its class loader without restrictions.

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

Sidebar

Related Questions

i have a java class :: package MyPackage; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet;
The method show(); in class Windows for java.awt in deprecated. What can I use
I have create a getDBConnection method in my Java application. This returns a connection
hey all, I'm new to Java and was wondering if I define a method
I just learned about java.sql package . It uses Class.forName() to dynamically load the
I have a small Java method that inserts short messages to a MySQL Database.
import java.awt.Panel; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.Statement;
import java.awt.Panel; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.sql.DriverManager; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel;
I have a Java class that accesses a MySQL database through JDBC that I
The following code is from java.sql.DriverManager : public static Connection getConnection(String url,String user, 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.