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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:32:21+00:00 2026-06-05T03:32:21+00:00

Reading on class loading, http://onjava.com/pub/a/onjava/2005/01/26/classloading.html , came across – ……Whenever we compile any Java

  • 0

Reading on class loading, http://onjava.com/pub/a/onjava/2005/01/26/classloading.html, came across –
“……Whenever we compile any Java file, the compiler will embed a public, static, final field named class, of the type java.lang.Class, in the emitted byte code. Since this field is public, we can access it using dotted notation, like this:

java.lang.Class klass = Myclass.class;
…………”

i tried accessing this field (Myclass.class) using reflection, which is plain insane i agree but still 🙂 and i get java.lang.NoSuchFieldException: class

Myclass myObject = new Myclass; 
System.out.println(myObject.getclass().getField("class"));

Is it then the runtime and not the compiler that adds the static .class field? Even then why is it not accessible using reflection?

  • 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-05T03:32:22+00:00Added an answer on June 5, 2026 at 3:32 am

    This is not a field access, per se, but rather an expression of the Java language syntax that merely looks like a field access. I suppose it’s possible for a compiler to put such a synthetic field into the classfile, though I don’t know of one that does.

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

Sidebar

Related Questions

After reading about dynamic class loading (that is, loading a .class file from disk)
I was reading the XMLSerializer class. This is in context of serializing the session
I have a file in .gz format. The java class for reading this file
Reading through the Wikipedia article on First-Class functions, there is a nice table of
I was reading Threading from within a class with static and non-static methods and
I was reading up on singleton class design in C# on this great resource
I've been reading that the static methods of the File Class are better used
I'm reading some XML with PHP and currently using the DOMDocument class to do
I was reading the following text from Stanford's Programming Paradigms class , and I
I was reading LYAH and read that the Num class isn't a subset of

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.