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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:51:53+00:00 2026-05-24T22:51:53+00:00

I am using the Wrapper Class method to allow me to handle a class

  • 0

I am using the Wrapper Class method to allow me to handle a class either existing or not. When using this technique, it is important to know what will cause my Proxy class to be initialized. In particular, what if I:

  1. Declare an instance of Proxy without setting it to anything

    public class myClass{
    …
    Proxy myInst;
    }

  2. Declaring an instance of Proxy locally inside a never run if statement

    public void myMeth{
    if(ProxyIsAvailableWhichItIsNot){
    Proxy myInst;
    …
    }
    }

Update: As pointed out by Henning, I am interested in when a class is initialized (and static blocks run), rather than when it is loaded. I updated the question to reflect this.

  • 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-24T22:51:55+00:00Added an answer on May 24, 2026 at 10:51 pm

    A Java implementation has a choice of either loading a class as soon as another class that references it is loaded, or postponing this until it becomes necessary to initialize the class. In the first case, the class can sit around for a considerable amount of time (perhaps forever) being loaded but not initialized.

    In contrast, there are precise rules for when a class is initialized (static initializers run), namely the first time an object of the class is created, or a static method called, or a non-constant static field is accessed.

    The only completely sure way to prevent a JVM from trying to load a class is not to mention it explicitly in the code and use Class.forName() and reflection to request loading at some definite point in time, at which time ClassNotFoundException may be thrown and handled. However, modern JVMs typically load classes much more lazily than the language specification allows them to, so more optimistic strategies will often work in practice.

    The “wrapper class” technique described in your link is not guaranteed to work by Java (see §12.1.2 of the Java Language Specification, 3rd edition), but it’s entirely possible that Android/Dalvik gives stronger guarantees of its own.

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

Sidebar

Related Questions

I'm using a Java wrapper for accessing Sqlite but I assume this is a
I'm using a Java wrapper for SQLite called SQLiteJDBC - this may have some
I'm working on an iphone app that uses Abbyy OCR. Using the wrapper class
I am writing a wrapper class for an activex control using a FireBreath plugin.
I'm writing a pythonic web API wrapper with a class like this import httplib2
I'm using a third party library class that has the following (abbreviated) method: public
I'm using a wrapper class to represent a network connection. My implementation contains a
I have installed SQLite and am using the wrapper from: http://sqlite.phxsoftware.com/ I have created
how can I set embed parameters for html wrapper using Flex Builder ? For
i am using the ghostscriptsharp wrapper for c# and ghostscript. I want to generate

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.