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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:31:45+00:00 2026-05-23T17:31:45+00:00

How comes that it is possible to write this.class in the fields declaration of

  • 0

How comes that it is possible to write this.class in the fields declaration of a class and it will actually do what is expected?

E.g.:

private static final logger = Logger.getLogger(this.class)

P.S.: Seems like a great place for Schroedinbug. 🙂

  • 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-23T17:31:45+00:00Added an answer on May 23, 2026 at 5:31 pm

    In Groovy this is bound to the class in a static context, and you can call static methods on it. Logger.getLogger(this.class) would be equivalent to just Logger.getLogger(Class).

    class C {
        static final staticThis = this
        static final thisClass  = this.getClass()
        static final someResult = this.someMethod()
    
        static someMethod() { 'static' }
    }
    
    assert C.staticThis == C.class
    assert C.thisClass  == Class
    assert C.someResult == C.someMethod()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to come up with an algorithm that will print out all possible
This is something that comes up so often I almost stopped thinking about it
Given this hash that comes though :params positions=>{ 1=>{x=>50, y=>30}, 2=>{x=>22, y=>53}, 3=>{x=>68, y=>35}
Would it be possible to write Eclipse plugin, that: Whenever in our code we
I have been asked to write a GUI that will allow objects to be
I'm trying to write some wrapper class or function that allows me to execute
Edit : Note that my final purpose here is not having the class working,
I'm trying to come up with the largest possible group of friends that would
Dear Masters! Is it possible to ensure, that only characters with codes between 0
One advantage that comes to my mind is, if you use Poco classes for

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.